12bpp -> tPixMap

BlitzMax Forums/BlitzMax Programming/12bpp -> tPixMap

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Something like..

'Assumes the pixmap is RGBA format
Local Source:Int Ptr=Memory 'the address of the 12bpp data
Local Dest:Byte Ptr=PixmapPtr(pixmap) 'your pixmap object
Local Width:Int=PixmapWidth(pixmap)
Local Diff:Int=PixmapPitch(pixmap)-Width
Local Pixel,Red,Green,Blue,Alpha:Int
Alpha=1
For Local Y:Int=0 to PixmapHeight(pixmap)-1
   For Local X:Int=0 to (PixmapWidth/8)-1 Step 2
      Pixel=Source[x]
      Dest[x]=(Pixel & $F0000000) Shr 28
      Dest[x+1]=(Pixel & $0F000000) Shr 24
      Dest[x+2]=(Pixel & $00F00000) Shr 20
      Dest[x+3]=Alpha
      Dest[x+4]=(Pixel & $000F0000) Shr 16
      Dest[x+5]=(Pixel & $0000F000) Shr 12
      Dest[x+6]=(Pixel & $00000F00) Shr 8
      Dest[x+7]=Alpha
 
'etc


I guess you'd need to read in 4 whole 12bpp pixels because each is 1.5 bytes, so 2 would be 3 bytes, you could maybe work with 6 bytes ie 4 source pixels at a time, but not easily. Maybe better with 8 source pixels, 12 bytes, handle them as 3 int's.