Bitmap accessing

Karl Ramberg karl.ramberg at chello.se
Sun Jun 17 15:05:38 UTC 2001



Henrik Gedenryd wrote:
> 
> Karl Ramberg wrote:
> 
> > I run the code
> >
> > pixels _ newImage form bits.
> > oldBits _ oldForm bits.
> > largeness _ oldBits size.
> > d _ oldForm depth.
> > 1 to: largeness do:[:c| i _ oldBits at: c.
> > oldpixel _ Color colorFromPixelValue: i depth: d.
> > pixels at: c put: (oldpixel pixelValueForDepth: d)]
> >
> > It works as expected in 32 bits depth but in 16 or 8
> > bits I get vertical stripes of transparency...
> >
> > Anybody know why ?
> >
> > Karl
> 
> There is not enough information in your mail to tell why. Eg. transparency
> is related to blt mode used, but I guess it is paint in this case. And what
> "depth", screen, source, or destination Form? To get transparency at 8 bits
> the result pixel must be zero. Try something like this:
> 
> 1 to: largeness do:[:c| i _ oldBits at: c.
>      oldpixel _ Color colorFromPixelValue: i depth: d.
>      newPixel _ oldpixel pixelValueForDepth: d .
>      newPixel = 0 ifTrue: [self halt].
>      pixels at: c put: newPixel]
> 
> 
> Then look at what oldpixel and i are when the halt is triggered.
> 

It seems like it is a issue with the convertion from integer to color and
back. When I run this code on a 32 bit depth picuture 
1 to: largeness do:[:c| i _ bilde at: c.
     oldpixel _ Color colorFromPixelValue: i depth: d.
     newpixel_ oldpixel pixelValueForDepth: d.

       i = 4278716424
newPixel = 4278716424

But on a 16 bit image I get 
i = 134284321
newPixel = 1057 

Both give the same color as result if I print
Color colorFromPixelValue: 134284321 depth: 16 -> (Color r: 0.032 g:
0.032 b: 0.032)
Color colorFromPixelValue: 1057 depth: 16 -> (Color r: 0.032 g: 0.032 b: 0.032)

But I guess the fewer bits in the integer makes a difference ?

Karl





More information about the Squeak-dev mailing list