Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong byte order for RGB565 #422

Closed
r-downing opened this issue Jul 18, 2022 · 5 comments
Closed

Wrong byte order for RGB565 #422

r-downing opened this issue Jul 18, 2022 · 5 comments

Comments

@r-downing
Copy link

If I take a framebuffer from the camera in jpeg format, and pass it through jpg2rgb565(...), then back through fmt2jpg(...) the colors are all screwed up - the rgb channels seem to be swapped and shifted.

For context I was capturing high-res images, then passing them to the jpg2rgb... to scale them down and do some image processing.

But if I take the output buffer of jpg2rgb565(...) and swap every alternating byte before passing it back to fmt2jpg(...) then the image appears correct.

uint8_t rgbBuf[...];

jpg2rgb565(fb->buf, fb->len, rgbBuf, JPG_SCALE_8X);

// swap the byte order and the image looks ok
size_t i;
for(i = 0; i < sizeof(rgbBuf); i+=2){
    const uint8_t tmp = rgbBuf[i];
    rgbBuf[i] = rgbBuf[i+1];
    rgbBuf[i+1] = tmp;
}

fmt2jpg(rgbBuf, ...)

So I believe either the output of jpg2rgb565() or the expected input format of fmt2jpg(...) is wrong, but I'm not sure which. If you guys know, I can make a fix

@WangYuxin-esp
Copy link
Contributor

Yes, my test here is the same as yours. The problem may be caused by the wrong byte order of the jpg2rgb565() function, because when the camera outputs data in standard RGB format, the fmt2jpg() function is normal.

@r-downing
Copy link
Author

r-downing commented Jul 21, 2022 via email

@github-actions
Copy link

This issue appears to be stale. Please close it if its no longer valid.

@AIWintermuteAI
Copy link

Bump.

@github-actions
Copy link

This issue appears to be stale. Please close it if its no longer valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants