Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8238287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:45:35+00:00 2026-06-07T19:45:35+00:00

By decoder transform H264 video to rgb24 file, it can be displayer well on

  • 0

By decoder transform H264 video to rgb24 file, it can be displayer well on Windows, but when I use UIImage to display it on UIImageView its color is not right.
The code I use as this:

- (UIImage *)imageFromAVPicture:(const UInt8 *)pict width:(int)width height:(int)height
{
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
    CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, pict, width*height*3,kCFAllocatorNull);

    CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

    CGImageRef cgImage = CGImageCreate(width, 
                                       height, 
                                       8,
                                       24, 
                                       width*3, 
                                       colorSpace, 
                                       bitmapInfo, 
                                       provider, 
                                       NULL, 
                                       YES, 
                                       kCGRenderingIntentDefault);

    CGColorSpaceRelease(colorSpace);

    UIImage *image = [self scaleImage:cgImage];
    //UIImage *image = [[UIImage alloc] initWithCGImage:cgImage];
    CGImageRelease(cgImage);
    CGDataProviderRelease(provider);
    CFRelease(data);

    return image;
}

But before create CGImage, add code as following, its show will be right, what following code do is transform betweent rgb and bgr.

UInt8 tmpBuff1,*tmpBuff2;
tmpBuff2 = (UInt8 *)pict;

for(int i =0;i<height;i++)
{
    for(int j=0;j<width;j++)
    {
        tmpBuff1 = *tmpBuff2;
        *tmpBuff2 = *(tmpBuff2+2);
        *(tmpBuff2+2) = tmpBuff1;
        tmpBuff2 += 3;
    }
}

After transform from rgb to bgr, its show will be right.

So I want to know why, why the same RGB24 file can play well on PC, but wrong on iOS before transform from RGB24 to BGR24.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:45:37+00:00Added an answer on June 7, 2026 at 7:45 pm

    This is a standard endianness issue. Which byte represents which color is not standardized for RGB. Windows uses R in the MSB and Mac/iOS uses R in the LSB. So you always need to do the byte order transform you showed when moving RGB between Windows and Mac/iOS. Note that you will likely find it more efficient to use the Accelerate framework’s vImagePermuteChannels_ARGB8888 to do this type of transform instead of writing your own code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According the decoder sample in Windows SDK, I realize myself decoder MFT, but there
<video id=myVideo src=2.mp4 controls= tabindex=0>decoder not found</video> this code show ' decoder not found'
I have a class that contains decoded video frames. I would like my decoder
I have a task to wrap a 3rd party video decoder library in a
If I goto http://site.com/uploads/file.pdf I can retrieve a file. However, if I have a
I am trying to write my own Protobuf frame decoder and I'm basing it
I'd like to create a Base16 encoder and decoder for Lion's new Security.framework to
I'm trying to code a simple base64 encoder/decoder (to test my programming skill). I
I am working on creating a Snappy Encoder and Decoder for Netty. I am
json_decode function is not part of PHP 5.1, so I cannot use it. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.