A collection of stuff I have which might help.
Get your head around this lot!
Get your head around this lot!
; ARGB ; Read and Write Pixel use 32-bit ARGB values. ; When read, the Most Significant Byte (the left-most) will always ; be 255 ($FF) if reading from an Image, but can be ; anything if reading from a texture. ; It's normally considered good practice to also write the Alpha Byte to an ImageBuffer. ; In 2D: ; ###### ARGB = $FF000000 Or R Shl 16 Or G Shl 8 or B ; In 3D: ; ###### ARGB = Alpha Shl 24 Or R Shl 16 Or G Shl 8 or B
; for converting colour to RGB values, for WritePixelFast / ReadPixelFast Function GetRGB(r,g,b) Return b Or (g Shl 8) Or (r Shl 16) End Function Function GetR(RGB) Return RGB Shr 16 And %11111111 End Function Function GetG(RGB) Return RGB Shr 8 And %11111111 End Function Function GetB(RGB) Return RGB And %11111111 End Function
; PRJ's Colour Mixing ;from a read... pix=ReadPixelFast( x,y ) r=(pix Shr 16) And $ff g=(pix Shr 8) And $ff b=pix And $ff ;to a write (assumes r,g,b are 0..255) pix=(r Shl 16) Or (g Shl 8) Or b WritePixelFast x,y,pix ;Half-bright: pix=(pix Shr 1) And $7f7f7f ;Quarter-bright: pix=(pix Shr 2) And $3f3f3f ;Blend 2 pixels: pix=( (pix1 Shr 1) And $7f7f7f ) + ( (pix2 Shr 1) And $7f7f7f ) ;So, a fast half-bright loop might be: WritePixelFast x,y,(ReadPixelFast( x,y ) Shr 1) And $7f7f7f