WarpBlt from 16bpp to 32bpp
Andreas Raab
andreas.raab at gmx.de
Fri Apr 27 05:25:50 UTC 2007
Andreas Raab wrote:
> > so it trys to install a color map from 32-bit regardless the actuall
> > depth of the source. Why?
>
> For precisely the reason you notice. The color map ensures that the
> averaged pixel can be mapped from the 32bit RGBA representation into
> whatever the destination depth is. Internally, when cellSize>1 we always
> treat the input as 32bit since we know that WarpBlt will average that
> way. But why this isn't working for 16->32 is a good question...
Okay, found it. The VM will substitute a standard color conversion if no
colorMap is given and since Color>>colorMapIfNeededFrom:to: will not
create an explicit color map for 32->32 bit conversions, the VM will use
a color map from the sourceForm's depth (16) to the destForm's depth
(32). Which, for WarpBlt w/ smoothing is just plain wrong.
Fix attached - it simply works around the problem by installing an
appropriate (no-op) color map for 32->32 conversions if necessary.
Cheers,
- Andreas
-------------- next part --------------
'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 26 April 2007 at 10:24:49 pm'!
!WarpBlt methodsFor: 'setup' stamp: 'ar 4/26/2007 22:24'!
cellSize: s
"Set the number of samples used for averaging"
cellSize := s.
cellSize = 1 ifTrue: [^ self].
"Install the colorMap to used for mapping the averaged RGBA 32bit pixels to the
destination depth. Note that we need to install the 32->32 color map explicitly because
the VM will substitute a colorMap derived from sourceForm->destForm mapping which
is just plain wrong for <32 source and 32bit dest depth"
(destForm depth = 32 and:[sourceForm depth < 32])
ifTrue:[colorMap := ColorMap shifts: #(0 0 0 0) masks:#(16rFF0000 16rFF00 16rFF 16rFF000000) colors: nil]
ifFalse:[colorMap := Color colorMapIfNeededFrom: 32 to: destForm depth].
! !
More information about the Squeak-dev
mailing list
|