Hi guys any one know whats wrong with this? :-\ It's in BlitzMax
Type RGBQUAD
Field rgbBlue:Byte
Field rgbGreen:Byte
Field rgbRed:Byte
Field rgbReserved:Byte
End Type
Global bmiColors:RGBQUAD = New RGBQUAD[255]
This is how I would use it: bmiColors[a].rgbBlue = 10
Just can't see the trees for the wood.
Thanks
far as I know....this one should work
Type RGBQUAD
Field rgbBlue:Byte
Field rgbGreen:Byte
Field rgbRed:Byte
Field rgbReserved:Byte
End Type
Global bmiColors:RGBQUAD = New RGBQUAD
But what you trying to do is doing Type with Arrays?
I am not sure if that what you want
Type RGBQUAD
Field rgbBlue:Byte[255]
Field rgbGreen:Byte[255]
Field rgbRed:Byte[255]
Field rgbReserved:Byte[255]
End Type
Global bmiColors:RGBQUAD = New RGBQUAD
I have tryed that, I just get an error "bmicolors can't be Indexed" :telloff:
yeah, that would give you
bmiColors.rgbBlue[0]
to
bmiColors.rgbBlue[255]
You want
Type RGBQUAD
Field rgbBlue:Byte
Field rgbGreen:Byte
Field rgbRed:Byte
Field rgbReserved:Byte
End Type
Global bmiColors:RGBQUAD[] = New RGBQUAD[256]
note the extra pair of square brackets after RGBQUAD. There are 256 entries in the palette, not 255.
You could also do
Global bmiColors:RGBQUAD[256]
Jim
Thanks Jim, Brill, them Blitzmax arrays do my head in. :goodpost:
Unhandled Exception:Attempt to access field or method of Null object
on this line:
For a = 1 To 127
bmiColors[a].rgbGreen = 255 - 2 * a <----- Error
bmiColors[a].rgbRed = 2 * a
Next
OK, so each of those array slots is just a 'pointer' to an RGBQUAD, you need to allocate some space for the data.
For a = 1 To 127
bmiColors[a] = New RGBQUAD
bmiColors[a].rgbGreen = 255 - 2 * a
bmiColors[a].rgbRed = 2 * a
Next
I'm not sure if it's necessary to do that if you used
Global bmiColors:RGBQUAD[] = New RGBQUAD[256]
Not sure. I've never used BlitzMax.
Jim