[squeak-dev] PNG export problem

Juan Vuletich juan at jvuletich.org
Fri Apr 29 01:31:53 UTC 2011


Nicolas Cellier wrote:
> This code seems to work:
>     PNGReadWriter
>         putForm: ((TextStyle defaultFont characterFormAt: $T) magnifyBy: 16)
>         onFileNamed: 'T1.png'.
>
> This one produces a fully transparent image (at least in mac finder
> and firefox renderers):
>     PNGReadWriter
>         putForm: ((TextStyle defaultFont characterFormAt: $T)
> magnifyBy: 16) asMorph imageForm
>         onFileNamed: 'T2.png'.
>
> Though a FileList is able to display a preview of the image for both files,
> importing with:
>     Form openImageInWindow: (FileDirectory default / 'T2.png') fullName.
> just leave a transparent image in upper corner...
>
> While
>     Form openImageInWindow: (FileDirectory default / 'T1.png') fullName.
> works as expected...
>
> Any clue ?
>
> Nicolas
>   

Hi Nicolas,

It is a bug in BitBlt. For instance:

    | f f2 blt sourceDepth |
    sourceDepth := 16.
    f := Form extent: 16 at 16 depth: sourceDepth.
    f fillWhite.
    f2 := Form extent: 16 at 16 depth: 32.
    f2 fillColor: Color blue.
    blt := BitBlt new.
    blt setDestForm: f2 sourceForm: f fillColor: nil combinationRule: 
Form paint destOrigin: 0 at 0 sourceOrigin: 0 at 0 extent: 16 at 16 clipRect: f 
boundingBox.
    blt copyBits.
    f2 colorAt: 0 at 0

prints 'Color transparent' if sourceDepth = 16, but 'Color white' if 
sourceDepth = 32.

The problem seems to be in BitBltSimulation>>#rgbMapPixel:flags:, if I 
replace the last line with

    val :=val bitOr: ((255) bitShift: (24)).
    ^val

and call #copyBitsSimulated (with VMMaker loaded) It seems to work ok. 
This is just a hack for testing, as it doesn't take into account actual 
source and destination depths...

Cheers,
Juan Vuletich



More information about the Squeak-dev mailing list