Ticket #931 (closed defect: fixed)

Opened 9 years ago

Last modified 6 years ago

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) (diff)

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

Attachments

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

Change History

Changed 9 years ago by sgillies@…

  • status changed from new to assigned
  • milestone set to 4.4 release
for 4.4

Changed 9 years ago by sgillies@…

  • status changed from assigned to closed
  • resolution set to fixed
a few new tests in clonetest.py to demonstrate the fix, all the rest of the
work confined to msCopySymbol in mapsymbol.c.

Changed 6 years ago by ljfong@…

The mapfile used.

Changed 6 years ago by ljfong@…

Symbol definition file

Changed 6 years ago by ljfong@…

  • status changed from closed to reopened
  • resolution fixed deleted
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.

Changed 6 years ago by ljfong@…

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

Changed 6 years ago by ljfong@…

Symbol image prior to call to clone()

Changed 6 years ago by ljfong@…

Symbol image after call to clone()

Changed 6 years ago by sgillies@…

  • owner changed from sgillies@… to sdlime
  • status changed from reopened to new

Changed 6 years ago by sdlime

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

Steve

Changed 6 years ago by szekerest

  • cc szekeres.tamas@… added

Changed 6 years ago by hobu

  • description modified (diff)

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

Changed 6 years ago by hobu

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.

Changed 6 years ago by sdlime

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

Changed 6 years ago by tunatuni

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 2. 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.

Changed 6 years ago by tunatuni

Original Highway symbol

Changed 6 years ago by tunatuni

Highway symbol after map clone in map tile

Changed 6 years ago by hobu

tunatuni,

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

Changed 6 years ago by tunatuni

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.

Changed 6 years ago by tunatuni

Also symobol in symbol file is defined as

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

Changed 6 years ago by sdlime

  • status changed from new to assigned
  • milestone changed from 5.0 release to 5.0.1 release

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

Changed 6 years ago by sdlime

  • status changed from assigned to closed
  • resolution set to fixed
  • milestone changed from 5.0.1 release to 5.0 release

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

Steve

Changed 6 years ago by sdlime

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

Changed 6 years ago by aalbarello

  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 5.0 release to 5.0.1 release

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.

Changed 6 years ago by hobu

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

Changed 6 years ago by aalbarello

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

Changed 6 years ago by aalbarello

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

Changed 6 years ago by aalbarello

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

Changed 6 years ago by sdlime

Yes, will apply shortly...

Steve

Changed 6 years ago by sdlime

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

Steve

Changed 6 years ago by aalbarello

  • status changed from reopened to closed
  • resolution set to fixed

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

Thanks,

Andreas

Note: See TracTickets for help on using tickets.