You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sanselan-dev@incubator.apache.org by "Kevin Theisen (JIRA)" <ji...@apache.org> on 2008/08/03 20:33:44 UTC
[jira] Created: (SANSELAN-9) Loading Black and White PNGs produces
darker images.
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
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.
[jira] Updated: (SANSELAN-9) Loading Black and White PNGs produces
darker images.
Posted by "Kevin Theisen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kevin Theisen updated SANSELAN-9:
---------------------------------
Attachment: testImageNoAlpha.png
testImage.png
PNGDarker.png
After further testing, this problem occurs on Windows as well. However, I did discover that only images WITHOUT alpha experience this problem. I am uploading the original darkening demonstration as well as two images I created, testImage.png and testImageNoAlpha.png. I release these images (testImage.png and testImageNoAlpha.png) to the public. If you read and write testImage.png, you will notice no change, which reading and writing testImageNoAlpha.png will experience the mentioned darkening. Is there a way to specify that a created PNG should always have transparency enabled?
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Charles Matthew Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619697#action_12619697 ]
Charles Matthew Chen commented on SANSELAN-9:
---------------------------------------------
Its very possible the problem lies in that toCompatibleImage() method. I would write some code that examines whether that method is darkening the image.
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Kevin Theisen (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Charles Matthew Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620542#action_12620542 ]
Charles Matthew Chen commented on SANSELAN-9:
---------------------------------------------
Thanks Kevin,
Please do let us know - using "compatible" images is a common performance technique, so unraveling this problem would definitely be interesting.
I suppose my one guess would be that the compatible image might be doing some gamma correction to the specific gamma or even icc profile of that device - your monitor.
Charles.
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Craig Russell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619379#action_12619379 ]
Craig Russell commented on SANSELAN-9:
--------------------------------------
Would it be possible to reproduce this issue with an image that can be licensed to Apache? Not a huge problem if not, but it would be nice to have a regression test case that can be checked into svn...
> 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
>
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Charles Matthew Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619389#action_12619389 ]
Charles Matthew Chen commented on SANSELAN-9:
---------------------------------------------
Also, I notice that image you linked is a Jpeg, not a Png.
http://en.wikipedia.org/wiki/Linus_Pauling
> 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.
[jira] Issue Comment Edited: (SANSELAN-9) Loading Black and White
PNGs produces darker images.
Posted by "Kevin Theisen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619380#action_12619380 ]
bakeryreject edited comment on SANSELAN-9 at 8/3/08 2:43 PM:
--------------------------------------------------------------
After further testing, this problem occurs on Windows as well. However, I did discover that only images WITHOUT alpha experience this problem. I am uploading the original darkening demonstration as well as two images I created, testImage.png and testImageNoAlpha.png. I release these images (testImage.png and testImageNoAlpha.png) to the public. If you read and write testImage.png, you will notice no change, while reading and writing testImageNoAlpha.png will experience the mentioned darkening. Is there a way to specify that a created PNG should always have transparency enabled?
was (Author: bakeryreject):
After further testing, this problem occurs on Windows as well. However, I did discover that only images WITHOUT alpha experience this problem. I am uploading the original darkening demonstration as well as two images I created, testImage.png and testImageNoAlpha.png. I release these images (testImage.png and testImageNoAlpha.png) to the public. If you read and write testImage.png, you will notice no change, which reading and writing testImageNoAlpha.png will experience the mentioned darkening. Is there a way to specify that a created PNG should always have transparency enabled?
> 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.
[jira] Closed: (SANSELAN-9) Loading Black and White PNGs produces
darker images.
Posted by "Kevin Theisen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kevin Theisen closed SANSELAN-9.
--------------------------------
Resolution: Won't Fix
Not a problem with Sanselan.
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Charles Matthew Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619388#action_12619388 ]
Charles Matthew Chen commented on SANSELAN-9:
---------------------------------------------
I can't reproduce this issue. I can
Kevin, can you please post a code snippet that reproduces this issue?
Also, I've made source and binary snapshots. You might want to try to see if you can reproduce with them:
http://people.apache.org/~cmchen/apache-sanselan-incubating-0.95-04082008-snapshot-bin.zip
http://people.apache.org/~cmchen/apache-sanselan-incubating-0.95-04082008-snapshot-src.zip
Thanks.
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Kevin Theisen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619393#action_12619393 ]
Kevin Theisen commented on SANSELAN-9:
--------------------------------------
Forgot to add the getGraphicsConfiguration() function:
// Returns the graphics configuration for the primary screen
private static GraphicsConfiguration getGraphicsConfiguration() {
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
> 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.
[jira] Commented: (SANSELAN-9) Loading Black and White PNGs
produces darker images.
Posted by "Kevin Theisen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANSELAN-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620515#action_12620515 ]
Kevin Theisen commented on SANSELAN-9:
--------------------------------------
Hi Charles,
Sorry for the late update, things got busy. I short-circuited the function and yes, the image no longer gets darker. Since this is not a problem with Sanselan I will close this issue, thanks for your help.
I will look into this and hopefully find out what is going on, as that function is very important for applications painting many images. Hopefully I can figure it out soon. Let me know if you have any ideas.
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.