[ https://issues.apache.org/jira/browse/IMAGING-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14266612#comment-14266612 ]
Gary Lucas commented on IMAGING-141: ------------------------------------ I agree that using 32 bits when 1 would suffice is rather silly. I will look into this a bit. Does anyone have sample images? One of the issues here is speed. Originally, the TIFF layer depended on the setRGB() method to set pixels in a BufferedImage. Unfortunately, this method was SLOW. I replaced it with a class called ImageBuilder which composed an image in plain-old integer memory and then transferred it to a BufferedImage using some fairly obscure Java API elements (I cannot take credit for figuring them out, someone told me about them on a discussion group). This change resulted in a factor of 10 improvement in loading time (I'm not exaggerating here... I clocked it). But it did result in 32 bit images. I speculate that the reason that BufferedImage.setRGB() was so slow is that each time it was called it had to process a lot of different options for internal image formats. There's a long history of that kind of thing in computer image representations that dates at least back to the old X-Window System developed in the early 1980's. I want to avoid a solution that would re-introduce the kind of performance issue that made the old Sanselan code unusable. In the back of my mind, I've got a suspicion that on a modern computer, 1-bit-per-pixel images might turn out to be a bit slow. I've never tried this, but I can imagine it might happen. I'll have to do some testing. Would you be content with 1 byte per pixel? It's still wasteful, but not quite so bad. My plan is to refactor ImageBuilder as an interface, and to create alternate classes depending on what kind of image the TIFF file describes. I'm not sure which BufferedImage formats to support. Does anyone have suggestions in this regard? Gary > BufferedImage from TIFF is always 24 or 32 bpp > ---------------------------------------------- > > Key: IMAGING-141 > URL: https://issues.apache.org/jira/browse/IMAGING-141 > Project: Commons Imaging > Issue Type: Bug > Components: Format: TIFF > Reporter: Josh Highley > Fix For: Patch Needed > > > When getting a BufferedImage from a TIFF, TiffImageParser.getBufferedImage > gets the TIFF's BPP from the TIFF tags, but at the end > ImageBuilder.getBufferedImage() will always set the BufferedImage ColorModel > BPP to 32 for images with alpha and 24 bpp otherwise. Many TIFFs are 1 bpp > (G3 and G4) so the BufferedImage should also be 1 bpp. -- This message was sent by Atlassian JIRA (v6.3.4#6332)