1. CxImage User Input
- Posted by Lone_EverGreen_Ranger Aug 31, 2009
- 1286 views
Hello,
I tried searching the code for the old cxImage code that allowed a user to input a graphic file using the cximage, but it isn't showing up. Does anyone have the code for the use of the cximage library? I remember the code being something like this
function createDIBFromCXImage() --eu code end function
However that's all I can remember.
2. Re: CxImage User Input
- Posted by mic_ Aug 31, 2009
- 1225 views
It's a bit unclear to me what it is you want to do. If you want to display an image on a window there's a function in cximage.ew that generates a HBITMAP for you:
-- atom CXI_MakeBitmap(atom image, atom hdc) -- Return a HBITMAP for the image. Useful if you want to draw the image to a window. -- 'hdc' is the target device context (can be NULL).
3. Re: CxImage User Input
- Posted by useless Aug 31, 2009
- 1248 views
Hello,
I tried searching the code for the old cxImage code that allowed a user to input a graphic file using the cximage, but it isn't showing up. Does anyone have the code for the use of the cximage library? I remember the code being something like this
function createDIBFromCXImage() --eu code end function
However that's all I can remember.
[03:01] <katsmeow-afk> !eu search CXImage
[03:01] <[Tiggr]> There's 11 files found...
[03:01] <[Tiggr]> Looking for CXImage , I find it in these files: \winprog.5\124 - Emf13.e , \winprog.5\123 - Emf12.e , \winprog.5\122 - Emf11.e , \winprog.5\121 - Emf10.e , \winprog.5\120 - Emf9.e , \winprog.5\119 - Emf8.e , \picview\file_list.ew , \picview\cximage.ew , \picview\PicView.exw , \cximage\test.exw ,
[03:01] <[Tiggr]> \cximage\cximage.ew ,
[03:01] <katsmeow-afk> !eu more
[03:01] <[Tiggr]> there's no more!
[03:01] <katsmeow-afk> thanks, Tiggr
[03:03] <katsmeow-afk> !eu search createDIBFromCXImage
[03:03] <[Tiggr]> Sorry, i don't have that word indexed!
[03:03] <katsmeow-afk> !eu search cxi
[03:03] <[Tiggr]> There's 6 files found...
[03:03] <[Tiggr]> Looking for cxi , I find it in these files: \picview\file_list.ew , \picview\cximage.ew ,
\picview\PicView.exw , \cximage\test.exw , \cximage\cximage.ew , \2d_plots\2D_PLOTS.TXT ,
[03:05] * katsmeow-afk hugs her bot
[03:05] * [Tiggr] hugs katsmeow back B-]
useless
4. Re: CxImage User Input
- Posted by ghaberek (admin) Aug 31, 2009
- 1137 views
cxImage code that allowed a user to input a graphic file
Given that statement right there, I think this is what you are looking for:
-- atom CXI_LoadImage(object source, integer imageType, integer bufSize) -- Loads an image from 'source', which can be either a sequence specifying -- a filename, or an atom specifying a memory location. If loading from -- memory you should set 'bufSize' to the size of the memory buffer, otherwise -- you can just pass any (integer) value. 'imageType' specifies the kind of -- image you want to load (see the list below. CXI_FORMAT_*). If you pass -- CXI_FORMAT_UNKNOWN the library will try to detect the image type on its own. -- CXI_LoadImage returns a pointer to a CxImage object (for a reference, download -- the CxImage sources and look in ximage.h) on success, and 0 otherwise.
-Greg
5. Re: CxImage User Input
- Posted by Lone_EverGreen_Ranger Aug 31, 2009
- 1200 views
OK, However whenever I try to load a image, my program freezes, here's my code.
Hero_WalkGfx_Win = createEx(Window,"",Tab_Hero,460,50,64,64,{WS_CHILD,WS_CLIPSIBLINGS},0) object HeroWalk_Gfx HeroWalk_Gfx = 0 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) end procedure setHandler(Hero_WalkGfx_Load,w32HClick,routine_id("Load_HeroWalk_Gfx")) procedure Paint_HeroWalk_Gfx(integer self, integer event, sequence parm) transBlt(Hero_WalkGfx_Win,0,0,HeroWalk_Gfx) end procedure setHandler(Hero_WalkGfx_Win,w32HPaint,routine_id("Paint_HeroWalk_Gfx"))
There's more code to obviously, but this is the part that counts, I'm pretty sure. I remember they're being some kinda of code Greg wrote so that user input images would work. What I want is for the user to load a image and then have it displayed in the window. However, when I tried loading an image, my program froze.
6. Re: CxImage User Input
- Posted by ghaberek (admin) Aug 31, 2009
- 1147 views
Are you calling CXI_Init before any other CXI routine?
-Greg
7. Re: CxImage User Input
- Posted by Lone_EverGreen_Ranger Aug 31, 2009
- 1145 views
Are you calling CXI_Init before any other CXI routine?
-Greg
OK I did, and now it dosen't freeze anymore, but my image isn't showing up on the window.
8. Re: CxImage User Input
- Posted by mic_ Aug 31, 2009
- 1144 views
I don't know what kind of parameters the transBlt procedure takes, but I really doubt that it accepts a pointer to an instance of the CxImage class (which is what CXI_LoadImage returns). If transBlt accepts an HBITMAP, try calling CXI_MakeBitmap on the image you've loaded with CXI_LoadImage.
9. Re: CxImage User Input
- Posted by Lone_EverGreen_Ranger Aug 31, 2009
- 1135 views
I don't know what kind of parameters the transBlt procedure takes, but I really doubt that it accepts a pointer to an instance of the CxImage class (which is what CXI_LoadImage returns). If transBlt accepts an HBITMAP, try calling CXI_MakeBitmap on the image you've loaded with CXI_LoadImage.
That didn't work either. I remember somebody had some code written so that it would allow for this. I remember it being something like this.
function createDIBFromCXImage(atom hDib) return hDib end function
I don't rememeber all the code in the function, but I remember that is what I had that showed the image in the window. I think Greg wrote it, but I'm not sure.
10. Re: CxImage User Input
- Posted by ghaberek (admin) Aug 31, 2009
- 1126 views
That didn't work either. I remember somebody had some code written so that it would allow for this. I remember it being something like this.
function createDIBFromCXImage(atom hDib) return hDib end function
I don't rememeber all the code in the function, but I remember that is what I had that showed the image in the window. I think Greg wrote it, but I'm not sure.
I remember now. Yes, I wrote that. I can't seem to find it on my comptuer. I may not have saved it anywhere. Google reveals it's in this thread...
...but that link is broken.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
-Greg
11. Re: CxImage User Input
- Posted by jimcbrown (admin) Aug 31, 2009
- 1137 views
That didn't work either. I remember somebody had some code written so that it would allow for this. I remember it being something like this.
function createDIBFromCXImage(atom hDib) return hDib end function
I don't rememeber all the code in the function, but I remember that is what I had that showed the image in the window. I think Greg wrote it, but I'm not sure.
I remember now. Yes, I wrote that. I can't seem to find it on my comptuer. I may not have saved it anywhere. Google reveals it's in this thread...
...but that link is broken.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
-Greg
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
12. Re: CxImage User Input
- Posted by ghaberek (admin) Aug 31, 2009
- 1166 views
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
13. Re: CxImage User Input
- Posted by Lone_EverGreen_Ranger Aug 31, 2009
- 1182 views
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"))
14. Re: CxImage User Input
- Posted by ghaberek (admin) Sep 01, 2009
- 1085 views
Your child Window is not visible. You'll need to add the WS_VISIBLE flag to have it show up...
Hero_WalkGfx_Win = createEx(Window,"",Tab_Hero,460,50,64,64,{WS_VISIBLE,WS_CHILD,WS_CLIPSIBLINGS},0)
-Greg
15. Re: CxImage User Input
- Posted by Lone_EverGreen_Ranger Sep 01, 2009
- 1093 views
Your child Window is not visible. You'll need to add the WS_VISIBLE flag to have it show up...
Hero_WalkGfx_Win = createEx(Window,"",Tab_Hero,460,50,64,64,{WS_VISIBLE,WS_CHILD,WS_CLIPSIBLINGS},0)
-Greg
Actually it wasn't that it, it wasn't visible, I forgot to add repaintWindow when I drew the image to the window.