Ticket #2640 (closed defect: fixed)

Opened 4 years ago

Last modified 23 months ago

[PATCH] Use GDAL transparency masks

Reported by: rouault Owned by: warmerdam
Priority: normal Milestone: 6.0 release
Component: GDAL Support Version: unspecified
Severity: normal Keywords: gdal transparency mask
Cc: sdlime, hobu

Description

From GDAL >= 1.5.0, the concept of transparency mask has been introduced. See  RFC 15.

This patch uses dataset transparency masks when no alpha band is available. It reads the mask band and simulates as if it was an alpha band, so the impact on existing code is minimum.

Attachments

transparency_mask.map Download (0.5 KB) - added by rouault 4 years ago.
To test with "./shp2img -m transparency_mask.map -o result.tif -l TEST -s 200 200 -e 0 0 19 19"
test_with_mask_1bit.tif Download (0.8 KB) - added by rouault 4 years ago.
Grey level image with transparency mask
test3_with_1mask_1bit.tif Download (1.6 KB) - added by rouault 4 years ago.
RGB image with transparency mask
result.tif Download (0.7 KB) - added by rouault 4 years ago.
Expected result : grey square at the centre of a red background
mapdrawgdal_transparency_mask.patch Download (2.2 KB) - added by rouault 4 years ago.
Patch to use GDAL transparency masks (updated not to be triggered with BANDS keyword)

Change History

Changed 4 years ago by rouault

To test with "./shp2img -m transparency_mask.map -o result.tif -l TEST -s 200 200 -e 0 0 19 19"

Changed 4 years ago by rouault

Grey level image with transparency mask

Changed 4 years ago by rouault

RGB image with transparency mask

Changed 4 years ago by rouault

Note : the above attached TIFF images have internal transparency masks, that are only handled on GDAL trunk >= r14647.

Changed 4 years ago by rouault

Expected result : grey square at the centre of a red background

Changed 4 years ago by sdlime

  • owner changed from sdlime to warmerdam
  • component changed from MapServer C Library to GDAL Support

Changing component to "GDAL Support"... I can apply but would like Frank's blessing.

Steve

Changed 4 years ago by sdlime

  • cc sdlime added; warmerdam removed

Changed 4 years ago by rouault

I've discovered the existence of msautotest/gdal, and of course by testing it, I discovered that my patch introduced a regression in unclassified.map, where the PROCESSING "BANDS=1,2,3" directive excludes the alpha component of the RGBA image from being taken into account. So I'm updating the patch not to try to use transparency masks when the BANDS keyword is used in PROCESSING. This way the test suite passes fine again.

Patch updated.

Changed 4 years ago by rouault

Patch to use GDAL transparency masks (updated not to be triggered with BANDS keyword)

Changed 3 years ago by rouault

  • cc hobu added

Changed 23 months ago by warmerdam

  • status changed from new to assigned
  • milestone set to 6.0 release

I have incorporated a slight variation on the patch in trunk (r10002).

Changed 23 months ago by warmerdam

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

Implemented test in test suite based on provided sample files (r10003) and incorporated the check for GDAL 1.5 or newer (r10004).

Thanks Even - sorry for the delay in incorporating.

Note: See TracTickets for help on using tickets.