Tourist Trap wrote:...
For the constant overflow, that's more a issue for fbc than for me, even doing a CULNG to the value (a color) doesn't solve this. So it doesn't matter even if I wonder why this is a 64bits affair.
...
The overflow is reported on this line (275):
Code: Select all
/' ... '/
THIS._img => imageCreate( Wid, Hei, (rgba(8,20,20,199) * rgba(0,0,65,205)), 32 ) ''colour
/' ... '/
As you can see, the multiplication indeed produces an overflow. What's the intent of that code? Interpolate the colors, or just multiply them? Here's a little snippet comparing the two operations (note how you need to
shr the resulting component when multiplying):
Code: Select all
type as ulong _
RGBColor
/'
Interpolates two RGB colors
'/
function _
lerpRGB( _
byval s as RGBColor, _
byval e as RGBColor, _
byval x as ubyte ) _
as RGBColor
dim as ubyte _
sr => ( s shr 16 and 255 ), _
sg => ( s shr 8 and 255 ), _
sb => ( s and 255 ), _
er => ( e shr 16 and 255 ), _
eg => ( e shr 8 and 255 ), _
eb => ( e and 255 )
return( rgb( _
( x * ( er - sr ) ) shr 8 + sr, _
( x * ( eg - sg ) ) shr 8 + sg, _
( x * ( eb - sb ) ) shr 8 + sb ) )
end function
/'
Multiply two RGB colors
'/
function _
multRGB( _
byval s as RGBColor, _
byval d as RGBColor ) _
as RGBColor
dim as ubyte _
sr => ( s shr 16 and 255 ), _
sg => ( s shr 8 and 255 ), _
sb => ( s and 255 ), _
dr => ( d shr 16 and 255 ), _
dg => ( d shr 8 and 255 ), _
db => ( d and 255 )
return( rgb( _
( sr * dr ) shr 8, _
( sg * dg ) shr 8, _
( sb * db ) shr 8 ) )
end function
dim as integer _
scrW => 800, _
scrH => 600
screenRes( scrW, scrH, 32 )
for _
y as integer => 0 to scrH - 1
line _
( 0, y ) - _
( scrW - 1, y ), _
lerpRGB( _
rgb( 255, 128, 64 ), _
rgb( 192, 32, 255 ), _
( 255 / scrH ) * y )
next
sleep()
dim as RGBColor _
aColor => rgb( 128, 255, 32 )
for _
y as integer => 0 to scrH - 1
line _
( 0, y ) - _
( scrW - 1, y ), _
multRGB( _
aColor, _
point( 0, y ) )
next
'' Show the color that's being multiplied into the image
line _
( 0, 0 ) - _
( 63, 63 ), _
aColor, bf
sleep()
Or perhaps I'm just missing your intent there ;)