Ticket #931 (closed defect: fixed)

Opened 4 years ago

Last modified 10 months ago

After map.clone(), pixmap symbol loses transparency

Reported by: sgillies@frii.com Assigned to: 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

Odessa.map (29.9 kB) - added by ljfong@sdf.lonestar.org on 01/22/07 19:20:46.
The mapfile used.
symbology.sym (1.9 kB) - added by ljfong@sdf.lonestar.org on 01/22/07 19:23:01.
Symbol definition file
symbol_before_losing_transparency.JPG (2.1 kB) - added by ljfong@sdf.lonestar.org on 01/22/07 19:55:27.
Symbol image prior to call to clone()
symbol_after_losing_transparency.JPG (2.5 kB) - added by ljfong@sdf.lonestar.org on 01/22/07 19:56:10.
Symbol image after call to clone()
interstate.gif (122 bytes) - added by tunatuni on 08/14/07 17:13:59.
Original Highway symbol
maptile.gif (15.5 kB) - added by tunatuni on 08/14/07 17:15:15.
Highway symbol after map clone in map tile
mapsymbol.diff (0.8 kB) - added by aalbarello on 11/02/07 16:48:17.
Diff against rev 6998 of svn trunk which swaps the gdImageCopy and gdImageFilledRectangle calls.

Change History

10/21/04 12:56:45 changed by sgillies@frii.com

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

10/27/04 14:16:46 changed by sgillies@frii.com

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

01/22/07 19:20:46 changed by ljfong@sdf.lonestar.org

  • attachment Odessa.map added.

The mapfile used.

01/22/07 19:23:01 changed by ljfong@sdf.lonestar.org

  • attachment symbology.sym added.

Symbol definition file

01/22/07 19:26:59 changed by ljfong@sdf.lonestar.org

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

01/22/07 19:34:27 changed by ljfong@sdf.lonestar.org

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

01/22/07 19:55:27 changed by ljfong@sdf.lonestar.org

  • attachment symbol_before_losing_transparency.JPG added.

Symbol image prior to call to clone()

01/22/07 19:56:10 changed by ljfong@sdf.lonestar.org

  • attachment symbol_after_losing_transparency.JPG added.

Symbol image after call to clone()

01/22/07 20:57:33 changed by sgillies@frii.com

  • status changed from reopened to new.
  • owner changed from sgillies@frii.com to sdlime.

01/22/07 22:59:17 changed by sdlime

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

Steve

01/23/07 03:43:05 changed by szekerest

  • cc set to szekeres.tamas@freemail.hu.

08/13/07 00:49:07 changed by hobu

  • description changed.

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

08/13/07 21:57:05 changed 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.

08/13/07 23:43:39 changed 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

08/14/07 17:13:15 changed 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.

08/14/07 17:13:59 changed by tunatuni

  • attachment interstate.gif added.

Original Highway symbol

08/14/07 17:15:15 changed by tunatuni

  • attachment maptile.gif added.

Highway symbol after map clone in map tile

08/14/07 23:24:08 changed by hobu

tunatuni,

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

08/15/07 13:49:42 changed 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.

08/15/07 13:59:15 changed by tunatuni

Also symobol in symbol file is defined as

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

09/04/07 01:39:49 changed 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

09/05/07 09:40:20 changed 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

09/05/07 10:05:49 changed 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

10/03/07 11:36:40 changed by aalbarello

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

10/03/07 12:08:00 changed 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

10/03/07 13:00:16 changed 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

11/02/07 16:46:37 changed 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

11/02/07 16:48:17 changed by aalbarello

  • attachment mapsymbol.diff added.

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

11/02/07 17:01:50 changed by sdlime

Yes, will apply shortly...

Steve

11/08/07 00:41:34 changed 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

11/08/07 05:20:32 changed by aalbarello

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

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

Thanks,

Andreas