BMP's from 'attached' resource files
Here's what I finally came up with for reading bitmaps from resource
files attached to 'bound' win32lib programs.
It's pretty fast because all the bmp's are loaded along with the main
program, and all subsequent accesses are from memory, instead of from
files, because there aren't any !!
--slightly modified loadBitmapFromFile2(), from win32lib.
--reads BMP from attached resource file to memory.
function loadBmpResource( sequence fileName, atom size)
atom bmFile, bmInfoHeader, bmBits, bmColors, hdc, hDib
integer hFile, fSize, byte
hFile = rOpen( fileName, "rb" )
fSize = size
bmFile = allocate( fSize )
for i = 0 to fSize-1 do
byte = getc( hFile )
poke( bmFile+i, byte )
end for
close(hFile)
bmInfoHeader = bmFile + SIZEOF_BITMAPFILEHEADER
bmBits = bmFile + fetch( bmFile, bfOffBits )
bmColors = bmInfoHeader + SIZEOF_BITMAPINFOHEADER
hdc = getDC( 0 )
hDib = c_func( xCreateDIBitmap, {
hdc,
address( bmInfoHeader, bmiHeader ),
CBM_INIT,
bmBits,
bmInfoHeader,
DIB_RGB_COLORS} )
releaseDC( 0 )
free( bmFile )
return hDib
end function
...any improvement suggestions are welcome, Wolf
|
Not Categorized, Please Help
|
|