Opened 16 years ago
Closed 10 years ago
#1576 closed defect (fixed)
Certain images with 1-bit-alpha channel lose their transparency
Reported by: | anonymous | Owned by: | team |
---|---|---|---|
Priority: | minor | Milestone: | 14.09 |
Component: | Core | Version: | latest |
Keywords: | bad icon; mappaint | Cc: |
Description (last modified by )
With 4938/josm applied, images with none or full alpha transparency should work fine. Certain images (e.g. ./images/styles/standard/accommodation.png optimized with optipng -o7) are rendered opaque with a white background instead of transparent.
Attachments (8)
Change History (50)
comment:1 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
Ok, but i think they looks now terrible. For example the fuel sign have a white frayed border and if the background is black you can't see them very well.
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
comment:4 by , 16 years ago
Owner: | changed from | to
---|
comment:5 by , 16 years ago
Priority: | major → critical |
---|
I'm 1/3 through the preset menu. Shall I continue to test every preset for the used icon and then look for icons that have no preset? Or do you see the problem and revert or fix the change that caused it?
comment:6 by , 16 years ago
Owner: | changed from | to
---|---|
Priority: | critical → minor |
Summary: | Images with white backgrounds are defect → Images without alpha channel should not get a transparent background |
The change has been reverted to have a hotfix. Neverthelesse the reason is not yet fixed.
BTW: This is in no way a criticial bug. Even if it is major would be subject to discussion.
Error cause: When a PNG image has no alpha channel, JOSM takes the background as alpha channel and makes it transparent. The image optimization removed empty alpha channels from the icons thus triggering that bug in JOSM.
comment:7 by , 16 years ago
Priority: | minor → major |
---|---|
Version: | → latest |
Replying to anonymous:
In the latest Version of JOSM all images with white background (telephon/toilets) are defect. (I think white is now transparent)
Both in JOSM 1043 and JOSM 1042 I see that nodes that are assigned amenity | toilets are not visible in the normal mode. Only in wireframe mode these nodes can be seen in the map window. I just entered a toilet once more where I knew I already entered one last week. Switching to wireframe mode I saw there already was a toilet node. So to save OSM from dublicate nodes, I think the priority should be increased.
by , 16 years ago
Attachment: | 01_toilet not visible.png added |
---|
Series of screen shots where we see that a toilet node is only visible in wire frame node.
by , 16 years ago
Attachment: | 02_if_you_know_where_to_klick_box_appears.png added |
---|
Series of screen shots where we see that a toilet node is only visible in wire frame node.
by , 16 years ago
Attachment: | 03_only_in_wireframe_mode_the_node_is_shown.png added |
---|
Series of screen shots where we see that a toilet node is only visible in wire frame node.
comment:8 by , 16 years ago
Keywords: | bad icon mappaint added |
---|
another attempt to fix this by providing the same icons black on white without alpha channel found in ticket duplicate #1692
however, this is really annoying, to me too
Q.: I it really a problem to get hands on not-too-much optimized icons with alpha channel? I could make them from the bad ones with The GIMP on the fly ... (please ask hoff dot st at web dot de)
comment:9 by , 16 years ago
Owner: | changed from | to
---|
comment:10 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → needinfo |
Apparently this is fixed.
Some images are still without alpha channel, e.g. /transport/taxi.png, /misc/landmark/tower.png
However they are displayed correctly on the map.
Maybe the issue is still present for an OS other than Linux. Could someone please check on Windows?
comment:11 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | needinfo → new |
comment:12 by , 15 years ago
I think it depends on Java version. We didn't change anything regarding image display.
comment:13 by , 15 years ago
42 of 523 images in
styles/standard have no Alpha channel:
./leisure/garden.png ./leisure/nature_reserve.png ./sport/bicycle.png ./sport/chess.png ./sport/centre.png ./sport/riding.png ./hunting_stand.png ./rendering/quarry2.png ./rendering/beach.png ./rendering/quarry.png ./nautical/lock_gate.png ./nautical/marina.png ./nautical/anchor.png ./sightseeing/archaeological.png ./vehicle/cattle_grid.png ./vehicle/motorbike.png ./vehicle/gate.png ./vehicle/car_sharing.png ./vehicle/toll_booth.png ./service/administration/court_of_law.png ./service/emergency_access_point.png ./health/eye_specialist.png ./historic/boundary_stone.png ./religion/muslim.png ./religion/hinduism.png ./religion/jainism.png ./transport/airport/terminal.png ./transport/airport/helipad.png ./transport/turntable.png ./transport/taxi.png ./transport/car.png ./money/bank/vr-bank.png ./misc/information/guidepost.png ./misc/landmark/power.png ./misc/landmark/power/hydro.png ./misc/landmark/survey_point.png ./misc/landmark/water_tower.png ./misc/landmark/tower.png ./misc/landmark/beacon.png ./education.png ./accommodation/camping.png ./accommodation/guest_house.png
Would it help to update them?
comment:14 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Some of these images are looking rather ugly with the plain white background (imho), but working.
comment:15 by , 13 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:16 by , 13 years ago
Status: | reopened → new |
---|
I don't think this is fixed. We did not change a single bit of code for this. It can be it is a Java issue. If so, we need at least to find out and document when Java fixed it. Otherwise this issue still exists.
The included icons have always been adapted properly. Issue was always when optipng or pngcrush has been run to reduce icons size.
comment:17 by , 13 years ago
It isn’t fixed. If you optimize ./images/styles/standard/accommodation.png it will still get a transparent background. This may be fixed by using ImageIO.read instead of Toolkit.getDefaultToolkit().createImage in ImageProvider. While ImageIO works for images w/ or w/o alpha channel it does not work for images with only transparency (i.e. 1 bit alpha channel).
If you want to try it out yourself, the following three images should contain all cases:
- ./images/styles/standard/accommodation.png; image w/o alpha if optimized (use with node; tourism=hotel)
- ./images/styles/standard/sport/soccer.png; image w/ alpha (use with node; sport=soccer)
- ./images/presets/soccer.png; image with transparency (1 bit alpha) (see it in top layer presets menu)
comment:18 by , 13 years ago
hm… the 1 bit alpha bug seems to be present with createImage as well… so in other words: switching to ImageIO would fix some of the PNG alpha bugs…
comment:19 by , 13 years ago
Maybe we also get rid of these spurious error messages in PNG code which appear sometimes?
comment:20 by , 13 years ago
I’m not sure which messages you are referring to? Anyway, I’ll attach the wip-patch shortly so you can try if it fixes those errors. It only changes how local images are loaded, but applying it to the other cases is trivial.
Given the large amount of 1-bit-alpha images, I’m not sure switching will be of any help. We still can’t run optipng on these images and I haven’t measured how large the impact would be if only the non-1-bit-alpha ones are optimized.
by , 13 years ago
Attachment: | 1-bit-alpha.txt added |
---|
List of 1-bit-alpha images (+command which finds them)
comment:22 by , 13 years ago
I measured the time it takes to init the presets menu. The difference is negligible, so switching won’t regress startup time.
imageio toolkit 1512 ms 1299 ms 1535 ms 1302 ms 1288 ms 1528 ms 1676 ms 1265 ms 1488 ms 1343 ms 1494 ms 1435 ms 1499 ms 1362 ms AVG 114 ms 91 ms STDDEV
Next up: space savings w/ non-1-bit-alpha PNGs optimized
comment:23 by , 13 years ago
7358312 josm-normal.jar 7338405 josm-opti-non1bitalpha.jar 7334603 josm-all-opti.jar
so 19907 bytes (~19 KiB) saved. Could save another 3802 bytes (~4 KiB) if all images could be read properly.
Script used:
#!/bin/zsh for x in images/**/*.png; do identify -quiet -verbose "${x}" | grep "alpha: 1-bit" || optipng -o7 "${x}" done
comment:24 by , 13 years ago
I suggest using ImageIO because it fixes the originally reported issue. The 1-bit-alpha bug exists in both implementations, so no change here. Speed regression is negligible. There is a remote chance this might also fix #2904 and similar.
While the space savings are minimal, I can now provide a working shell script that compresses the images automatically without causing a transparency bug (hopefully, at least). The savings are now at ~27 KiB, although I have no idea why the new method saves more than optimizing all images.
Are there any objections? If not, shall I add the script to SVN?
by , 13 years ago
Attachment: | optimize-images added |
---|
Script that optimizes all PNGs in images/ without causing an alpha transparency bug
comment:25 by , 13 years ago
Are there any objections?
No.
If not, shall I add the script to SVN?
I think so.
comment:29 by , 13 years ago
Description: | modified (diff) |
---|---|
Priority: | major → minor |
Summary: | Images without alpha channel should not get a transparent background → Certain images with 1-bit-alpha channel lose their transparency |
comment:30 by , 13 years ago
comment:31 by , 13 years ago
Is there any guideline on how to handle the images in images/styles/standard, which are located on OSM’s SVN. I would like to contact the other consumers before blindly committing the compressed variants (also I don’t want to be the one to update the debian/ dir)
comment:32 by , 13 years ago
In the past josm was the only one with problems. We sometimes needed to revert optimizer runs. So I think there should be no problem to optimze the images.
comment:33 by , 13 years ago
This is interesting. I always had the problem, that TexturePaint requires a BufferedImage, but Toolkit.createImage returns sun.awt.image.ToolkitImage.
There's a lot of code, just to handle this efficiently (the sanitize stuff). It seems, we can get rid of this now since all image data we get is a BufferedImage anyway.
follow-up: 37 comment:34 by , 13 years ago
Nice. Will you do the follow up then? I noticed that I forgot to change sanitized to true once; but if that whole code is going to be removed anyway…
comment:35 by , 13 years ago
Seems not to affect outside code, so can be simply removed when not needed anymore.
comment:36 by , 13 years ago
new ImageIcon(bytes).getImage()
still returns ToolkitImage. To make it explicit, better use BufferedImage directly for the cache:
-
src/org/openstreetmap/josm/tools/ImageResource.java
23 21 /** 24 22 * Caches the image data for resized versions of the same image. 25 23 */ 26 private HashMap<Dimension, ImageWrapper> imgCache = new HashMap<Dimension, ImageWrapper>();24 private HashMap<Dimension, BufferedImage> imgCache = new HashMap<Dimension, BufferedImage>(); 27 25 private SVGDiagram svg; 28 26 public static final Dimension DEFAULT_DIMENSION = new Dimension(-1, -1);
comment:37 by , 13 years ago
Replying to xeen:
Nice. Will you do the follow up then? I noticed that I forgot to change sanitized to true once; but if that whole code is going to be removed anyway…
Maybe wait a few days, to see if it works ok on all platforms. This only affects the MapCSS property fill-image
which isn't used much at the moment (just in Mapnik style, AFAIK).
comment:38 by , 13 years ago
The file images/preferences/toolbar.png now looks ugly (preferences tab).
comment:39 by , 13 years ago
Sorry, I did accidentially checkin the nosan patch. Please revert or fix when necessary.
comment:42 by , 10 years ago
Milestone: | → 14.09 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
They are not defect. They have been changed to no longer so omnipresent. If you have special problems with individual icons, name these problems directly and reopen the report.