Hi,
I made a PNGReadWriter2 and a PNGReadWriter2Plugin with libpng support for fast png reading, which is needed in Sophie and future versions of Plopp. Currently it can only read a png file and returns only 32bit forms. The repository for this is http://www.squeaksource.com/PNGReadWriter2 and I build it with vmaker 3.8b6, squeak 3.9 and the squeak 3.9-8 unix sources. to build it under linux, create a Makefile.inc with LDFLAGS += -lpng in platforms/unix/plugins/PNGReadWriter2Plugin contributions, e.g. writing images, are very welcome. - Jens Lincke - |
Jens Lincke wrote:
> I made a PNGReadWriter2 and a PNGReadWriter2Plugin with libpng support > for fast png reading, which is needed in Sophie and future versions of > Plopp. > > Currently it can only read a png file and returns only 32bit forms. > > The repository for this is http://www.squeaksource.com/PNGReadWriter2 All I find in there is PNGReadWriter2>>primPNGReadImageFromByteArray: source onForm: form self primitiveFailed PNGReadWriter2>>primPNGReadInfoFromByteArray: source onForm: form self primitiveFailed > and I build it with vmaker 3.8b6, squeak 3.9 and the squeak 3.9-8 unix > sources. I'm a little confused to see statements like here in the plugin: formPix isNil ifTrue: [formPix := 1]. this should be translated to isNil(formPix) and as far as I am aware there is no such function available anywhere. Also, it seems as if there are some serious hazards for decoding the PNG data - the code doesn't set a limit for the source of input when decoding so I presume libpng will simply fall over and break (possibly corrupting Squeak memory) if you give it partial input? Cheers, - Andreas |
Andreas Raab schrieb:
> > All I find in there is > > PNGReadWriter2>>primPNGReadImageFromByteArray: source onForm: form > > self primitiveFailed primPNGReadImageFromByteArray: source onForm: form <primitive: 'primPNGReadImageFromByteArrayonForm' module: 'PNGReadWriter2Plugin'> self primitiveFailed > > I'm a little confused to see statements like here in the plugin: > > formPix isNil ifTrue: [formPix := 1]. > this is an artifact of the translation from c to slang the line came from the JPEGPlugin: formPix = (255 << 24) | (buffer[0][i+rOff] << 16) | (buffer[0][i+gOff] << 8) | buffer[0][i+bOff]; if (formPix == 0) formPix = 1; > this should be translated to isNil(formPix) and as far as I am aware > there is no such function available anywhere. Also, it seems as if > there are some serious hazards for decoding the PNG data - the code > doesn't set a limit for the source of input when decoding so I presume > libpng will simply fall over and break (possibly corrupting Squeak > memory) if you give it partial input? > there is an error handler for png errors, which will return to squeak, but no other checks. |
Jens Lincke wrote:
>> All I find in there is >> >> PNGReadWriter2>>primPNGReadImageFromByteArray: source onForm: form >> self primitiveFailed > primPNGReadImageFromByteArray: source onForm: form > <primitive: 'primPNGReadImageFromByteArrayonForm' module: > 'PNGReadWriter2Plugin'> > self primitiveFailed How odd. Why doesn't Squeaksource show the primitive? I just downloaded the package and sure enough the code is in there but when you browse it on SS it doesn't show. >> I'm a little confused to see statements like here in the plugin: >> >> formPix isNil ifTrue: [formPix := 1]. >> > this is an artifact of the translation from c to slang > the line came from the JPEGPlugin: > formPix = (255 << 24) | (buffer[0][i+rOff] << 16) | (buffer[0][i+gOff] > << 8) | buffer[0][i+bOff]; > if (formPix == 0) formPix = 1; Oh, interesting - indeed the code generator translates isNil specificially. I didn't even know that ;-) (but I still think this should say "formPix = 0" instead of "formPix isNil" in the Slang code) >> this should be translated to isNil(formPix) and as far as I am aware >> there is no such function available anywhere. Also, it seems as if >> there are some serious hazards for decoding the PNG data - the code >> doesn't set a limit for the source of input when decoding so I presume >> libpng will simply fall over and break (possibly corrupting Squeak >> memory) if you give it partial input? >> > there is an error handler for png errors, which will return to squeak, > but no other checks. This sounds fishy ... how can libpng guarantee that it won't access data outside the source buffer if it doesn't even know how big the input is? On a related note: For PNGReadWriter I spent some time making sure that we can write 16 bit forms with no loss in precision when using PNGReadWriter. The way I did this was to use the sBIT (basically storing the number of significant bits for each channel as 5:5:5:1) - is there a way of retrieving this information from PNGReadWriter2 so that client code can (safely) do the conversion from 32 -> 16 bit? Cheers, - Andreas |
On Nov 22, 2006, at 20:21 , Andreas Raab wrote: > Jens Lincke wrote: >>> All I find in there is >>> >>> PNGReadWriter2>>primPNGReadImageFromByteArray: source onForm: form >>> self primitiveFailed >> primPNGReadImageFromByteArray: source onForm: form >> <primitive: 'primPNGReadImageFromByteArrayonForm' module: >> 'PNGReadWriter2Plugin'> >> self primitiveFailed > > How odd. Why doesn't Squeaksource show the primitive? I just > downloaded the package and sure enough the code is in there but > when you browse it on SS it doesn't show. Missing HTML escape - it actually is in the HTML source code of the page. - Bert - |
2006/11/22, Bert Freudenberg <[hidden email]>:
> > On Nov 22, 2006, at 20:21 , Andreas Raab wrote: > > > Jens Lincke wrote: > >>> All I find in there is > >>> > >>> PNGReadWriter2>>primPNGReadImageFromByteArray: source onForm: form > >>> self primitiveFailed > >> primPNGReadImageFromByteArray: source onForm: form > >> <primitive: 'primPNGReadImageFromByteArrayonForm' module: > >> 'PNGReadWriter2Plugin'> > >> self primitiveFailed > > > > How odd. Why doesn't Squeaksource show the primitive? I just > > downloaded the package and sure enough the code is in there but > > when you browse it on SS it doesn't show. > > Missing HTML escape - it actually is in the HTML source code of the > page. Fixed and waiting for deployment. Thanks for reporting. Cheers Philippe |
> Fixed and waiting for deployment. Thanks for reporting.
deployed -- Lukas Renggli http://www.lukas-renggli.ch |
Free forum by Nabble | Edit this page |