Re: CxImage User Input
- Posted by Lone_EverGreen_Ranger Aug 31, 2009
- 1181 views
ghaberek said...
jimcbrown said...
However, I was able to grab it from google cache, and I have saved them here:
http://malcom.unkmar.com/loading.html
http://malcom.unkmar.com/simplest.html
HTH
Excellent, thanks! Here we have it:
global function createDIBFromCXImage( atom image ) sequence info, pal integer width, height, bitsPer, colors, headerSize atom mset, memBits, memBitmapInfo, at, hdc, hDIB mset = w32new_memset() -- get the dib info info = CXI_GetDIB( image ) memBits = info[1] width = info[2] height = info[3] bitsPer = info[4] -- get the palette pal = CXI_GetPalette( image ) -- determine number of colors colors = length( pal ) -- determine the header size headerSize = SIZEOF_BITMAPINFOHEADER + (SIZEOF_RGBQUAD * colors) -- allocate memory for DIB memBitmapInfo = w32acquire_mem( mset, headerSize ) w32set_memory( memBitmapInfo, ID_BITMAPINFOHEADER, {SIZEOF_BITMAPINFOHEADER, width, height, 1, bitsPer, 0, 0, 0, 0, colors, 0} ) -- get the address of the first rgb tuple at = w32address( memBitmapInfo, bmiColors ) -- copy the pal to memory for i = 1 to colors do -- store values w32store( at, rgbRed, pal[i][1] ) w32store( at, rgbGreen, pal[i][2] ) w32store( at, rgbBlue, pal[i][3] ) w32store( at, rgbReserved, 0 ) -- move to next quad at += SIZEOF_RGBQUAD end for -- Get the screen's device context. hdc = getDC( Screen ) -- Create the DIB. hDIB = w32Func( xCreateDIBitmap, { hdc, w32address( memBitmapInfo, bmiHeader ), CBM_INIT, memBits, memBitmapInfo, DIB_RGB_COLORS} ) -- release the screen dc releaseDC( Screen ) -- Free memory w32release_mem( mset ) trackObject( {-1,kBitmapObject}, hDIB, ForProgram ) return hDIB end function
-Greg
Thanks, however my image is still now showing. Here is my code.
Hero_WalkGfx_Win = createEx(Window,"",Tab_Hero,460,50,64,64,{WS_CHILD,WS_CLIPSIBLINGS},0) global function createDIBFromCXImage( atom image ) sequence info, pal integer width, height, bitsPer, colors, headerSize atom mset, memBits, memBitmapInfo, at, hdc, hDIB mset = w32new_memset() -- get the dib info info = CXI_GetDIB( image ) memBits = info[1] width = info[2] height = info[3] bitsPer = info[4] -- get the palette pal = CXI_GetPalette( image ) -- determine number of colors colors = length( pal ) -- determine the header size headerSize = SIZEOF_BITMAPINFOHEADER + (SIZEOF_RGBQUAD * colors) -- allocate memory for DIB memBitmapInfo = w32acquire_mem( mset, headerSize ) w32set_memory( memBitmapInfo, ID_BITMAPINFOHEADER, {SIZEOF_BITMAPINFOHEADER, width, height, 1, bitsPer, 0, 0, 0, 0, colors, 0} ) -- get the address of the first rgb tuple at = w32address( memBitmapInfo, bmiColors ) -- copy the pal to memory for i = 1 to colors do -- store values w32store( at, rgbRed, pal[i][1] ) w32store( at, rgbGreen, pal[i][2] ) w32store( at, rgbBlue, pal[i][3] ) w32store( at, rgbReserved, 0 ) -- move to next quad at += SIZEOF_RGBQUAD end for -- Get the screen's device context. hdc = getDC( Screen ) -- Create the DIB. hDIB = w32Func( xCreateDIBitmap, { hdc, w32address( memBitmapInfo, bmiHeader ), CBM_INIT, memBits, memBitmapInfo, DIB_RGB_COLORS} ) -- release the screen dc releaseDC( Screen ) -- Free memory w32release_mem( mset ) trackObject( {-1,kBitmapObject}, hDIB, ForProgram ) return hDIB end function procedure Load_HeroWalk_Gfx(integer self, integer event, sequence parm) fName = getOpenFileName(Hero_WalkGfx_Win,file,GraphicType) if length(fName) = 0 then return end if HeroWalk_Gfx = CXI_LoadImage(fName,CXI_FORMAT_UNKNOWN,0) HeroWalk_Gfx = createDIBFromCXImage(HeroWalk_Gfx) end procedure setHandler(Hero_WalkGfx_Load,w32HClick,routine_id("Load_HeroWalk_Gfx")) procedure Paint_HeroWalk_Gfx(integer self, integer event, sequence parm) copyBlt(Hero_WalkGfx_Win,0,0,HeroWalk_Gfx) end procedure setHandler(Hero_WalkGfx_Win,w32HPaint,routine_id("Paint_HeroWalk_Gfx"))