RafaelOliveira / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

PNGEncoder -> byteArray not working with PNGImage: Alpha not supported #186

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Take Screenshot from a DisplayObject with BitmapData (without 
transperency) draw
2. Use the PNGEncoder (org.alivepdf.encoding.PNGEncoder) to create a 
ByteArray from the BitmapData
3. Use addImageStream or PNGImage

Then an error is thrown "Alpha channel not supported."

It seems, that the ByteArray is not correct, which is coming from the 
PNGEncoder, so the PNGImage can not handle it correctly.

What version of the product are you using? On what operating system?
Mac OS X 10.6.2, Adobe AIR 1.5
AlivePDF 1.5 Beta, Build from 16. November 2009

Please provide any additional information below.
This Bug is new to this version I mean.
I changed to Version 1.4.9 and it's working fine.

Original issue reported on code.google.com by rotor...@dashart.de on 7 Jan 2010 at 12:19

GoogleCodeExporter commented 9 years ago
Hmm interesting,

I will double check that.

Thanks for noticing the bug,

best,

Thibault

Original comment by thibault.imbert on 23 Jan 2010 at 10:19

GoogleCodeExporter commented 9 years ago
hello Thibault
well I am diving through the internet to find relevant info about this issue. 
The library in general is excellent (though I lack real life work best 
practises, 
but that is not a unique problem for alivePDF) and I lack what everybody else's 
lack 
a way to kick flash vectors, and textFields etc direct into a PDF. : )

anyway, I am using Flash CS4 and most doc are about flex, so I am inventing my 
own 
workarounds. and one of them is of course how to kick up the resolution so I 
can 
present graphics with text and details that will satisfy my clients. 

I Thought the PNGEncoder was designed to work with the addImageStream but it 
just 
returns line 3960: throw new Error ("Image format not supported for now."); 

Is this a known problem, is there perhaps a logic that I don't obey : ) 

any hint will be as welcome as a drip of water in the desert :()

cheers / lasse hall

Original comment by Hall.La...@gmail.com on 22 Apr 2010 at 8:44

GoogleCodeExporter commented 9 years ago
Hello lasse,

in version 1.4.9 the PNGEncoder of AlivePDF doesn't support alpha channels. If 
you 
use an alpha png-bytearray with the addImageStream in version 1.4.9, this error 
will 
be thrown: "Image format not supported for now."

As I know thibault would implement alpha channel support in version 1.5. When I 
compare the PNGEncoder from version 1.4.9 and 1.5, I see that thibault had 
rewritten 
the PNGEncoder. I think there is a bug.

Original comment by rotor...@dashart.de on 23 Apr 2010 at 7:39

GoogleCodeExporter commented 9 years ago
well the thing is I can live without the alpha/trans  effect for now. shuffling 
bitmapdata back and forth so the final cake to put in the oven is already 
composed : ) 

But the thing is no matter which Bitmapdata, with or without alpha, I either 
get an 
error for "not supporting alpha" OR the warning mentioned above adressing the 
format. 

I have found an alternative PNGEncoder ( 
http://agileui.blogspot.com/2010/01/high-
resolution-pdfs-from-flex.html ) that builds on top of an encoder from the Flex 
community, but it is nestled in the Flex library with dependencies from other 
classes so it's a bit tricky. 
And Thibaults lovely class do have the option for transparency, so I think it 
must 
be a codeerror/bug. and I like to stick to the same library, often make code 
and 
workflow more consistent. 

I have downloaded the latest library, using the class library, 

I am seriously considering moving over to Flex : ) seems to be the vehicle 
leading 
the evolution ...

cheers/ Lasse

Original comment by Hall.La...@gmail.com on 23 Apr 2010 at 8:13

GoogleCodeExporter commented 9 years ago
hello thibault

Now the PNGEncoding no alpha - works a charm : ) 

I don't know if that can help but I attach the classes that I have "hacked"
and with them the PNGEncoding works a charm. 

It might save you guys a few minutes. The library comes from Flex /codec, I 
have 
postfixed them Sekvens to distinguish them from the built in classes. I have 
simply 
taken the Flex solution from this site, 
http://agileui.blogspot.com/2010/01/high-
resolution-pdfs-from-flex.html and adapted it to Flash. So I am really the 
wrong guy 
to adress if this is of any help : )

Even though I am a seasoned flashdeveloper I simply lack the structured 
programming 
skills you guys have. :()

I wish I could contribute with a more ready solution. 

Please let us know if and when the problem is fixed, 

Now when the client sees the nice quality of the pdf, he expects the same 
quality of 
the prints from flash. But that I guess alivePDF can't solve. (Yeah I have 
suggested 
that we ask the user to print a PDF instead, and then send the pdf to the 
printer : )  Would be nice if there where a way to send a bytearray to the 
printer 
with a highresolution image. Adobe - please!!! )

cheers / merci / tack
Lasse Hall

Original comment by Hall.La...@gmail.com on 23 Apr 2010 at 2:24

Attachments:

GoogleCodeExporter commented 9 years ago
perfect!

thank you for sharing.

Original comment by rotor...@dashart.de on 25 Apr 2010 at 12:49

GoogleCodeExporter commented 9 years ago
Hi all,

I ran into the same problem and there indeed is a bug in the new PNGEncoder.
The problem is not with the transparency, but the new PNGEncoder in version 1.5
doesn't add the proper PNG header to the ByteArray it generates from the 
BitmapData.
In fact, it does not seem to write ANY header info to the ByteArray...
This results in PNGImage.as to not recognize the type of the ByteArray, causing 
the
"format not supported"-error.

Regards,

Z

Original comment by zege...@gmail.com on 22 Oct 2010 at 12:02

GoogleCodeExporter commented 9 years ago
Thanks for the fix Lasse !

Original comment by fxmarko...@gmail.com on 7 Feb 2013 at 5:08