mickleness / pumpernickel

This Java project includes classes related to desktop applications, Swing, performance, image processing, data structures, and other misc topics.
https://mickleness.github.io/pumpernickel/
MIT License
66 stars 12 forks source link

BmpDecoder: Reverses byte order twice #86

Closed mickleness closed 1 year ago

mickleness commented 2 years ago

While exploring a separate issue I noticed:

The BmpDecoder uses BufferedImageIterator.RGBtoBGR to switch the byte order once, and then when we call getRaster().setDataElements(..) that inner code reverses the byte order again.

We should try to avoid this extra work.

When you don't specify what type of BufferedImage you want: I think (?) the solution may involve using new ImageType constants to help create a custom BufferedImage (that is: an image of TYPE_CUSTOM) that creates a ByteInterleavedRaster where the #inOrder field is true.

And if you do specify the type of BufferedImage you want: we should make sure that image is written with only one pixel type conversion.

mickleness commented 1 year ago

Closing as resolved. Recent PixelIterator work addressed this.

To test: I put in a debugger breakpoint in ByteInterleavedRaster to make sure we didn't enter branches of code where inOrder == false. That would indicate we were swapping channels. (Or worse: we may be double-swapping... if I had other code that un-swapped what ByteInterleavedRaster already swapped...)