Re: Speed problem re rgb+alpha PNG

Alfred Reibenschuh <[email protected]> Tue, 24 Jun 2008 21:01:59 +0200
Newsgroups gmane.comp.lang.perl.modules.pdfapi2
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Henning Michael Møller Just wrote:
| Hi everyone
|
| I'm having some trouble creating an image object with $img =
$pdf->image_png(...)
|
| The object is created and it works, but it takes a very long time. The
image is 2482x3510 pixels and is RGBA ($cs == 6). The time is spent in
the PDF::API2::Resource::XObject::Image::PNG::unprocess() function and
then in the new() method in the lines
|
|             foreach my $n (0..($h*$w)-1) {
|                 vec($dict->{'
stream'},$n,$bpc)=vec($clearstream,($n*4)+3,$bpc);
|                 vec($self->{'
stream'},($n*3),$bpc)=vec($clearstream,($n*4),$bpc);
|                 vec($self->{'
stream'},($n*3)+1,$bpc)=vec($clearstream,($n*4)+1,$bpc);
|                 vec($self->{'
stream'},($n*3)+2,$bpc)=vec($clearstream,($n*4)+2,$bpc);
|             }
|
| I'm supposing this is getting the alpha mask out from the image and
then actually removing the transparent parts from the image? Or?
|
| On our relatively fast servers, this is taking about 3-4 minutes. It
turned out in this particular case we didn't need transparency so we
just saved it without ($cs == 2) and it's almost instantaneous now.
|
| But we will probably need transparency later, so I'd like to know if
there's something I can do. I'd rather not publisice the image (we are
doing this for a client), but I could send it privately for someone to
examine closer.

the question is wherether you need full alpha support or
can live with simple transparency.

if you need full alpha, the api has to extract the channel no matter what.

if you can live with transparency, define a transparent colour
(via png tRNS chunk) and the api will take the image almost verbatim.


cheers,

- --
fredo

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAkhhRKcACgkQpyPEZ/g4emPzGACfQljLxQRx/JsG3/TfT5l6j8N5
pqYAnjEC7BMkcRjdOOCX7HThBn6utVBJ
=lReH
-----END PGP SIGNATURE-----