Skip to content

Support 24-bit RGB/BGR raw pixel data on iOS#160

Open
mrousavy wants to merge 2 commits into
mainfrom
fix/ios-load-rgb-bgr
Open

Support 24-bit RGB/BGR raw pixel data on iOS#160
mrousavy wants to merge 2 commits into
mainfrom
fix/ios-load-rgb-bgr

Conversation

@mrousavy

Copy link
Copy Markdown
Owner

What

UIImage(fromRawPixelData:) hardcoded 4 bytes per pixel, so loading a 3-byte RGB or BGR buffer computed bytesPerRow as width * 4 against a width * height * 3 buffer and failed to create a CGImage.

Fix

  • Derive bytes per pixel from the resolved pixel format.
  • Build a native 24-bit CGImage for RGB.
  • Expand BGR to BGRX first, because Core Graphics has no 24-bit BGR format.

🤖 Generated with Claude Code

UIImage(fromRawPixelData:) hardcoded 4 bytes per pixel, so loading a
3-byte RGB or BGR buffer computed the wrong bytesPerRow and failed to
build a CGImage.

Use a native 24-bit CGImage for RGB, and expand BGR to BGRX first
(Core Graphics has no 24-bit BGR format). The initializer now derives
bytes per pixel from the resolved pixel format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant