Controlling format of PNG export?

Ben Rubinstein benr_mc at cogapp.com
Wed Apr 23 11:16:00 EDT 2003


Background: an app which has to integrate with a Director projector; the MC
(actually Rev) app generating PNG files with alpha channels, the Director
app importing these and doing some further processing and display.
(Unfortunately I lost the battle to have the entire solution coded in Rev/MC
- but at least I am now having daily opportunities to say "I told you so".)
An early test image worked fine, we then continued on separate paths.

Now when we came to put the two together, the mask was no longer being
processed correctly by Director.  After some investigation, we found that
the Rev/MC app, which had previously been outputting RGB+mask PNG files, was
now outputting indexed colour + mask PNG files.  The code that output the
PNG files was unchanged; but some additional processing had been done on the
images, to turn them into sepia-toned pseudo-ancient images.

Evidently, the MC engine, asked to export a PNG from a 32-bit + mask image,
is cunningly inspecting it and deciding that there are no more than 256
distinct colours, and therefore choosing to optimise the file.  I've no
reason to think that these aren't perfectly valid PNG files (PhotoShop at
least seems to see the transparency) - it's probably Director's error that
it's ignoring the alpha channel if the basic image is not RGB.

I've frigged it for now by modifying the routine which does the sepia
toning, introducing some random variations in the low-order bits of some
pixels in the image, so that there are (invisibly to the human eye) more
than 256 distinct colours in the image.  But this isn't 100% guaranteed to
work for all source images.  Is there any way that I can force Rev/MC to
output the PNG as RGB+alpha?

TIA, 
 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866





More information about the metacard mailing list