[squeak-dev] error inBitBlt with ColorForm

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] error inBitBlt with ColorForm

Martin Kuball
Hi!

I'm creating a ColorForm like this:

        bits := Bitmap new: image size / 4.
        bits copyFromByteArray: image.
        form := ColorForm extent: self area extent depth: 8 bits: bits.
        form colors: self colorMap.

where area is a Rectangle instance and image is a ByteArray with some
computed image data.

Now sometimes the created form is OK and sometimes I get an error in BitBlt
when trying to display it or making a PNG file from it. The error seems to
happen when the width of the form is an odd number. For more details please
see the attached debug log. You can see that the error appears right away
when the pixel at 0@0 is accessed. But how is the value of width relevant
here?

Martin





debug.log (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] error inBitBlt with ColorForm

Hans-Martin Mosner
Martin Kuball schrieb:

> Hi!
>
> I'm creating a ColorForm like this:
>
> bits := Bitmap new: image size / 4.
> bits copyFromByteArray: image.
> form := ColorForm extent: self area extent depth: 8 bits: bits.
> form colors: self colorMap.
>
> where area is a Rectangle instance and image is a ByteArray with some
> computed image data.
>  
Your "image" data probably does not include padding.
In Squeak, the bits of a form need to be properly padded to a multiple
of 32 bits.
So if your image is not a multiple of 4 pixels wide, you need to include
appropriate padding after each scanline.

Cheers,
Hans-Martin