Note: This is an UNTESTED example, as i don't have the Memblock upgrade for DB classic.
Function Render_Memblock(ThisMemblock)
Width=memblock dword(ThisMemblock,0)
Height=memblock dword(ThisMemblock,4)
Depth=memblock dword(ThisMemblock,8)
Address=12
` 16BIT Image
` ============
if depth=2 or depth=16
For Ylp=1 to Height
For Xlp=1 to Width
16BitColor=memblock word(ThisMemblock,address)
` COnvert the colour
24BitColour=ConvertRgb16ToRgb24(16bitcolor)
` Draw the colour to the current bitmap
Ink 24BitColour,0
dot xlp,ylp
` Step the current read pixel address to the next
address=address+2
next xlp
next ylp
endif
` 24BIT Image
` ============
if depth=3 or depth=24
For Ylp=1 to Height
For Xlp=1 to Width
` read the Red, GREEN and BYTE parts of our 24bit colour
R=memblock byte(ThisMemblock,address)
G=memblock byte(ThisMemblock,address+1)
B=memblock byte(ThisMemblock,address+2)
` Draw the colour to the current bitmap
Ink rgb(r,g,b),0
dot xlp,ylp
` Step the current read pixel address to the next
address=address+3
next xlp
next ylp
endif
` 32BIT Images
` ============
if depth=4 or depth=32
For Ylp=1 to Height
For Xlp=1 to Width
` read the 32 bit RGB (top 8 bits are alpha channel)
ThisRGB=memblock dword(ThisMemblock,address)
` Draw the colour to the current bitmap
Ink ThisRGB,0
dot xlp,ylp
` Step the current read pixel address to the next
address=address+4
next xlp
next ylp
endif
endfunction
Function ConvertRgb16ToRgb24(16bitcol)
r=((16bitcol/2048)&31)*8
g=((16bitcol/32)&63)*4
b=(16bitcol&31)*8
24bitcol=rgb(r,g,b)
Endfunction 24bitcol
Function ConvertRgb16ToRgb24_faster(16bitcol)
24bitCol=((16bitcol&63488)*256)+((16bitcol&2016)*32)+((16bitcol&31)*8)
Endfunction 24bitcol
Damn, that must be pretty hard to do that and not to have memblocks
Well im sure someone has memblocks avalible (I lost my disk) And they will be able to test it
Well done :)