-
Notifications
You must be signed in to change notification settings - Fork 45
Image.toarray change rgb to bgr on the Linux #191
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
Comments
This problem can be solved by passing the "colorType=kia. ColorType. kRGBA_8888_ColorType" parameter when calling toarray |
that's interesting. I just encounted a somewhat similar issue - pretty sure internally skia does kN32_8888 by default. FreeType internally does kBGRA actually, so I have to specify kBGRA to render directly from Skia into a freetype bitmap based memory canvas. You are basically saying that conversion to/from, one of them is not N32. |
It is actually documented in one of skin's design document that libjpeg and libpng does RGBA and platform neutral, while skia's internal image format is platform dependent, and on intel/small-endian, it is happens to be BGRA . There are different way of getting at it, and some will invoke auto-swap, some won't. So this behaviour is apparently documented. I found something similar in my situation. I have a buffer maintained by freetype and I wanted skia to fill it. The default doesn't work, and I have to explicitly tell skia that freetype wants BGRA and so please do it as such. I was doing a SkBitmap canvas with a freetype buffer backing and just ask Skia use the SkBitmap as a Canvas. I guess in my case, because jpeg/png buffers are RGBA, so SkBitmap probably has a default of being RGBA. |
@kyamagu Hmm, looking at this again, why does |
@HinTak Don't remember why they are different. As |
Hmm, this seems to relate to #250 . |
@kyamagu @Polyisoprene after looking at #323, I think maybe the idea of a single default value is wrong - clearly reading png and jpeg, vs making a Image in a different way, result in an image which is different internally inside skia. But skia knows what it is internally, as it is available as |
In any case, examples, etc should be updated to look like |
The same should apply to alphatype, actually - again images from different sources have different defaults - made from cpu surfaces are transparent by default, but read from jpeg are opaque. They should be passed along by toarray, really. |
Agreed. |
The methods are templated for image, surface and canvas. |
Describe the bug
On Linux platform use Image.toarray convert image to array ,then use Image.fromarray convert array to image, R and B chennel of the image will switch
To Reproduce
Steps to reproduce the behavior:
Expected behavior
R chennel and B chennel will not switch
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: