-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
DiscreteAlphaIndexColorModel.getNumComponents is giving the wrong information #693
Comments
|
Thanks for reporting! I'm currently on summer holiday with my family, but will look into it when I'm back in the office. -- |
Hi Jim, I agree with you on I'm less sure about the Are there any specific cases where the current implementation here ( Best regards, -- |
I have a project with a conversion from a BufferedImage to an OpenCV mat. In the test for the conversion I compare the pixel values from the original BufferedImage to the resulting Mat pixel-by-pixel. That compare fails because of the number of channels. Here is my workaround in the test code: If I'm misinterpreting what that method means on the color model, then I can just use: |
|
I think your workaround with the Wether or not the current behavior is strictly "correct", is hard to say, as this is something the Java2D API doesn't seem to take into account at all... Any way, closing this for now. |
Thanks. Sounds great. |
Describe the bug
According to my understanding, the
ColorModel.getNumComponents
should return the number of components/channels in the final image, not in the sample buffer.DiscreteAlphaIndexColorModel.getNumComponents
' implementation is giving sample size.Version information
3.8.2
More details:
If you look at the documentation for
getNumComponents
you can see that this is the number of channels in the final image. E.g. RGB would be 3. RGB with Alpha would be 4. This can be verified by looking at the implementation for anIndexColorModel
(which defaults toColorModel
s implementation). Usually, with anIndexColorModel
, the sample buffer would contain an single array of 1 byte per pixel. That means the "number of samples" per pixel is 1. However, if I have an RGB image with an IndexColorModel, the.getNumComponents
is 3.DiscreteAlphaIndexColorModel
is basically a 2 "sample" per pixel model (one sample is an RGB image with anIndexColorModel
and the other is the Alpha channel). Therefore, under almost all circumstances, thegetNumComponents
should return 4 (unless it somehow got constructed for an image without an alpha channel, in which case it should return 3 since it should act just like anIndexColorModel
without an alpha channel).Instead, it always returns 2 (potentially 1 if it doesn't have an alpha channel).
It's possible there's a misunderstanding on my part. If so, please let me know.
The text was updated successfully, but these errors were encountered: