[
https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619392#action_12619392
]
Kevin Theisen commented on SANSELAN-9:
--------------------------------------
Charles,
I have tested the snapshot and see the same behavior. The wikipedia image is a
jpg, but all images in my apps are saved and then subsequently loaded as only
pngs to easily transfer embedded images on all platforms (after the initial
read to a BufferedImage). This, however, does explain why the buffered image
that is loaded from the jpg does not have alpha.
The code I use is as follows:
TO READ:
final byte[] dataArray = Base64.decodeBase64(entire.getBytes()); //entire is
just the Base64 string
final BufferedImage bi = Sanselan.getBufferedImage(dataArray);
//I use org.apache.commons.codec.binary.Base64 to convert the binary to and
from Base64 for ease in embedding into the text files, although I have used my
own algorithms (which are 100% correct) for converting into HEX instead, and I
still see the same problem
TO WRITE:
//image is the BufferedImage
final byte[] bytes = Sanselan.writeImageToBytes(image,
ImageFormat.IMAGE_FORMAT_PNG, null);
final byte[] base64Bytes = Base64.encodeBase64(bytes);
sb.append(new String(base64Bytes));
I should also mention that between the reading and the display of the image,
the BufferedImage passes through this function to obtain an image compatible
with the current hardware (for rendering speed)
public static BufferedImage toCompatibleImage(BufferedImage image) {
if (isHeadless()) { return image; }
if
(image.getColorModel().equals(getGraphicsConfiguration().getColorModel())) {
return image; }
final BufferedImage compatibleImage =
getGraphicsConfiguration().createCompatibleImage(image.getWidth(),
image.getHeight(), image.getTransparency());
final Graphics g = compatibleImage.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
return compatibleImage;
}
This may, in fact, be the factor that differentiates us.
As mentioned above, I removed the Base64 package from the implementation and I
still saw the same problem. I am not quite sure what I am doing wrong, but it
may be that I am not specifying the correct attributes for the writer?
Thanks,
Kevin
> Loading Black and White PNGs produces darker images.
> ----------------------------------------------------
>
> Key: SANSELAN-9
> URL: https://issues.apache.org/jira/browse/SANSELAN-9
> Project: Sanselan
> Issue Type: Bug
> Affects Versions: 0.94-incubator
> Environment: Mac OSX 10.5+, Java 1.5+, Sanselan 0.94
> Reporter: Kevin Theisen
> Attachments: PNGDarker.png, testImage.png, testImageNoAlpha.png
>
>
> When saving and loading pngs with Sanselan, black and white images get
> darker with each save and load. All images are held in
> memory as BufferedImages (ARGB). Have you ever seen this weird behavior
> before or how I may fix it?
> The affected images may be all PNGs, but I see this effect happening in
> images that contain mostly black and white pixels. The image I use to
> demonstrate this problem is from a wikipedia page of Linus Pauling:
> http://en.wikipedia.org/wiki/Linus_Pauling
> The image basically goes to black after saving and loading 3/4 times.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.