sws_scale YUV --> RGB distorted image

前端 未结 1 1634
遇见更好的自我
遇见更好的自我 2020-12-16 02:58

I want to convert YUV420P image (received from H.264 stream) to RGB, while also resizing it, using sws_scale.
The siz

相关标签:
1条回答
  • 2020-12-16 03:31

    When you make a bitmap image, the width of image MUST be multiple of 4.

    So you have to change width like 480, 484, 488, 492 ...

    Here is method to change to multiple of 4

    #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
    
    void main()
    {
        BITMAPFILEHEADER bmFileHeader;
        BITMAPINFOHEADER bmInfoHeader;
    
        // load image
        // ...
    
        // when you use the method, put parameter like this.
        int tempWidth = WIDTHBYTES(width * bmInfoHeader.biBitCount);
    }
    

    I hope you solve the problem.

    0 讨论(0)
提交回复
热议问题