YUV422转RGB888,缩小,转换一步搞定

这篇博客分享了使用QT5进行YUV422格式图像到RGB888转换并进行尺寸缩小的代码实现,适合需要处理视频图像的开发者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

直接上代码

 

void CodeReaderHelper::Yuv422_toRGB(unsigned char *yuv, unsigned char *rgb, int source_width, int source_height, int target_width, int target_height)
{
    float scale_x;
    float scale_y;

    if (target_width >= source_width) //不能放大,只能缩小
    {
        scale_x = 1;
    }
    else
    {
        scale_x = (float)source_width / target_width;
    }

    if (target_height >= source_height) //不能放大,只能缩小
    {
        scale_y = 1;
    }
    else
    {
        scale_y = (float)source_height / target_height;
    }

    float y_t = 0, x_t = 0; //目标行列是否取样判断

    int y_t_count = 0; //目标行
    int x_t_count = 0; //目标列

    int r, g, b;
    int y0, y1, u, v;

    int p, p_t;   //指针
    int p0, p_t0; //每一行开始的指针

    scale_x = scale_x * 4; //一次处理2个点,4个数据

    for (int h = 0; h < source_height; h++)
    {
        if (h >= y_t) //取样条件满足
        {

         
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值