Opened 20 years ago

Closed 16 years ago

#931 closed defect (fixed)

After map.clone(), pixmap symbol loses transparency

Reported by: sgillies@… Owned by: sdlime
Priority: high Milestone: 5.0.1 release
Component: MapScript-SWIG Version: 4.3
Severity: normal Keywords:
Cc:

Description (last modified by hobu)

See testClone.png after unit tests.  Problem is almost certainly in 4.2.

Attachments (7)

Odessa.map (29.9 KB ) - added by ljfong@… 17 years ago.
The mapfile used.
symbology.sym (1.9 KB ) - added by ljfong@… 17 years ago.
Symbol definition file
symbol_before_losing_transparency.JPG (2.1 KB ) - added by ljfong@… 17 years ago.
Symbol image prior to call to clone()
symbol_after_losing_transparency.JPG (2.5 KB ) - added by ljfong@… 17 years ago.
Symbol image after call to clone()
interstate.gif (122 bytes ) - added by tunatuni 17 years ago.
Original Highway symbol
maptile.gif (15.5 KB ) - added by tunatuni 17 years ago.
Highway symbol after map clone in map tile
mapsymbol.diff (859 bytes ) - added by aalbarello 16 years ago.
Diff against rev 6998 of svn trunk which swaps the gdImageCopy and gdImageFilledRectangle calls.

Download all attachments as: .zip

Change History (31)

comment:1 by sgillies@…, 19 years ago

Milestone: 4.4 release
Status: newassigned
for 4.4

comment:2 by sgillies@…, 19 years ago

Resolution: fixed
Status: assignedclosed
a few new tests in clonetest.py to demonstrate the fix, all the rest of the
work confined to msCopySymbol in mapsymbol.c.

by ljfong@…, 17 years ago

Attachment: Odessa.map added

The mapfile used.

by ljfong@…, 17 years ago

Attachment: symbology.sym added

Symbol definition file

comment:3 by ljfong@…, 17 years ago

Resolution: fixed
Status: closedreopened
Doing:

Dim p_mapObj As mapObj = m_mapObj.clone()
p_mapObj.draw()

causes the PNG symbols to lose transparency. MapServer is compiled from 4.10
release sources using MS Visual Studio 2005 SP1 and runs against .NET framework 2.0.

comment:4 by ljfong@…, 17 years ago

I'll attach the images of the symbol before and after it loses transparency today.

by ljfong@…, 17 years ago

Symbol image prior to call to clone()

by ljfong@…, 17 years ago

Symbol image after call to clone()

comment:5 by sgillies@…, 17 years ago

Owner: changed from sgillies@… to sdlime
Status: reopenednew

comment:6 by sdlime, 17 years ago

COuld be a GD problem too. What version of GD are we talking?

Steve

comment:7 by szekerest, 17 years ago

Cc: szekeres.tamas@… added

comment:8 by hobu, 17 years ago

Description: modified (diff)

The symbols in your example are jpg. These don't carry transparency, right?

comment:9 by hobu, 17 years ago

testDrawClonePNG24 in clonetest.py of the MapScript tests seems to render a transparent png just fine with the latest GD. I don't understand what the issues could be. I suggest we close this bug.

comment:10 by sdlime, 17 years ago

I believe this was a known bug in GD that has been resolved. If the rotation/resize functions of GD also are fixed then that would be terrific too. Does the test pass with an older version of GD?

Steve

comment:11 by tunatuni, 17 years ago

Today, I tested this issue with mapserver 4.10.2 and GD-2.0.34. Issue still exist. I did try this with mapserver 5.0 beta 3. Same Issue there. Operating system tested on Fedora core 4 , Fedora core 6 and windows XP service pack2

I am using Java mapscript to show US street maps. All the pixmap symbols which happens to be GIF files lose tranparency after mapObj.clone().

Attaching two files. 1 Actual gif file interstate.gif

  1. GIF shown in map output maptile.gif

Here is the code mapObj tileMap = (mapObj)oMap.cloneMap(); .... oImg = tileMap.draw(); oImg.save(szMetaImg, tileMap);

This is my first post, please let me know if you need any additional info. I will be happy to test things on my end.

by tunatuni, 17 years ago

Attachment: interstate.gif added

Original Highway symbol

by tunatuni, 17 years ago

Attachment: maptile.gif added

Highway symbol after map clone in map tile

comment:12 by hobu, 17 years ago

tunatuni,

Is there any chance you can test this with GD-2.0.35?

comment:13 by tunatuni, 17 years ago

Operating system -Fedora Core 4. Mapserver 4.10.2 gd -2.0.35

Result is same. I mean transpareny is lost after map clone. Compiled gd.2.0.35 today. For that I have to upgrade my autoconf to autoconf.2.61. Previously I had autocnf 2.59-5. After compiling & install gd2.0.35, a) ./configure b) make c) sudo make install

My /usr/local/lib dir shows

-rwxr-xr-x 1 root root 922 Aug 15 10:11 libgd.la

lrwxrwxrwx 1 root root 14 Aug 15 10:11 libgd.so -> libgd.so.2.0.0

lrwxrwxrwx 1 root root 14 Aug 15 10:11 libgd.so.2 -> libgd.so.2.0.0

-rwxr-xr-x 1 root root 532653 Aug 15 10:11 libgd.so.2.0.0

Now I recomipled mapserver 4.10.2

./configure --with-httpd=/www/http/bin/httpd \

--with-wfsclient \ --with-wmsclient \ --enable-debug \ --with-curl-config \ --with-proj \ --with-gdal \ --with-tiff \ --with-png \ --with-gd=/usr/local \ --with-freetype \ --enable-ignore-missing-data \

--with-threads

After mapserver install, ran my application, map.clone() still removes transparency. While not using map.clone preserves pixmap tranparency.

I am writing detailed info so that it can be of some help to mapserver developers. Please let me know if u need any screenshots or any other info.

comment:14 by tunatuni, 17 years ago

Also symobol in symbol file is defined as

Symbol Name 'interstate' Type PIXMAP IMAGE "../etc/markers/interstate.gif" Transparent 4 END

comment:15 by sdlime, 17 years ago

Milestone: 5.0 release5.0.1 release
Status: newassigned

Something weird is going on. This probably is the same problem as the "losing transparency after rotation" bug. I think what may be happening is that the color palette is getting shuffled in the copy and simply re-using the transparent index from the original doesn't work. I've tried copying the palette using a GD function but I'm not having much luck. I'm going to defer until 5.0.1 unless I have success in the next few minutes...

Steve

comment:16 by sdlime, 17 years ago

Milestone: 5.0.1 release5.0 release
Resolution: fixed
Status: assignedclosed

I finally figured out how to copy a paletted symbol and preserve transparency...

Steve

comment:17 by sdlime, 17 years ago

I also fixed the truecolor cloning. Key is to fill the new image with a fully transparent color and then copy into it. That way anything in the source image that is transparent will also be transparent in the new image.

Steve

comment:18 by aalbarello, 17 years ago

Milestone: 5.0 release5.0.1 release
Resolution: fixed
Status: closedreopened

What you say in your last comment is very true, Steve, unfortunately the implementation doesn't reflect this logic properly. Most likely something got screwed up.

In fact, http://trac.osgeo.org/mapserver/changeset/6789 shows that the image is filled with a transparent color after it has been copied, thus making the copied image disappear. And that is what I am actually getting on my cloned maps.

Simply swapping lines 980 and 982 of mapsymbol.c fixes this again here.

comment:19 by hobu, 17 years ago

aalbarello,

Can you provide a patch? In my mapsymbol.c, line 980 is an if statement, and I'm a bit confused as to what to rearrange.

Howard

comment:20 by aalbarello, 17 years ago

Sorry Howard, I should have been more specific, but I see you've figured out yourself what I meant (http://trac.osgeo.org/mapserver/changeset/6919). I was referring to lines 980 and 982 in the mapserver 5.0.0 source distribution, not in the svn 5.0 branch, where there have apparently been some changes to mapsymbol.c in the meantime. I was indeed talking about swapping the gdImageFilledRectangle and gdImageCopy call.

If you still need a patch, let me know.

Thanks, Andreas

comment:21 by aalbarello, 16 years ago

Any chance this can make it into 5.0.1? I'm including a patch against svn trunk which fixes this new issue introduced with rev 6789.

Thanks,

Andreas

by aalbarello, 16 years ago

Attachment: mapsymbol.diff added

Diff against rev 6998 of svn trunk which swaps the gdImageCopy and gdImageFilledRectangle calls.

comment:22 by sdlime, 16 years ago

Yes, will apply shortly...

Steve

comment:23 by sdlime, 16 years ago

Patch applied to both the main trunk and the 5.0 branch. Could someone please confirm the fix and close this sucker? Thanks!

Steve

comment:24 by aalbarello, 16 years ago

Resolution: fixed
Status: reopenedclosed

Confirming the fix, everything works as expected now. Closing.

Thanks,

Andreas

Note: See TracTickets for help on using tickets.