[BUG]Color>>asColorref (3.2gamma,cs:4811)

Doug Way dway at riskmetrics.com
Tue Apr 9 22:13:29 UTC 2002


Sean Charles wrote:
> 
> Whilst writing some other code to convert a Color to an HTML string
> (#rrggbb) I think I discovered a bug in the implementation of
> Color>>asColorref, here's the code:
> 
> asColorref
>     "Convert the receiver into a colorref"
>     ^ (self red * 255) asInteger + ((self green * 255) asInteger << 8) +
> ((self green * 255) asInteger << 16)
> 
> The last term references the green component again, should this be 'blue' or
> have I misunderstood the way in which the components are packed into 'rgb'?

A fix was recently submitted and harvested for this bug, and should hopefully be showing up in the update stream soon.

(Here's the fix, by the way...)

!Color methodsFor: 'conversions' stamp: 'dew 3/27/2002 01:03'!
asColorref
	"Convert the receiver into a colorref.  (A 32-bit Win32-specific value, in blue-green-red LSB order.  Use #pixelValue32 for a red-green-blue ordered value.)"
	^(self red * 255) asInteger + ((self green * 255) asInteger << 8) + ((self blue * 255) asInteger << 16)! !


- Doug Way
  dway at riskmetrics.com



More information about the Squeak-dev mailing list