Re: Loading A Graphic Using CxImage From User Input
- Posted by Andy Jun 22, 2009
- 1336 views
ghaberek said...
Andy said...
I looked at it, added your code into my code, and my code still runs, however it is not displaying it on the screen. How do I use the function effectivley?
First, you have to get the DIB from CxImage with my function, like this:
image = CXI_LoadImage( filename, filetype, 0 ) yourDIB = createDIBFromCxImage( image )
Then, you can either copyBlt() the image to the window during a paint event, like this:
procedure Main_onPaint( integer pSelf, integer pEvent, sequence pParams ) copyBlt( Main, 0, 0, yourDIB ) end procedure setHandler( Main, w32HPaint, routine_id("Main_onPaint") )
Or you can create a Bitmap control and set the DIB using setBitmap(), like this:
constant myBmp = create( Bitmap, "", Main, 10, 10, 100, 100, 0 ) setBitmap( myBmp, yourDIB )
Either should work, though I have only tested the onPaint method.
-Greg
Thanks, the code does work, but for some reason, when ever I try to load a "user" selected image, my program crashes on me. I am probably doing something wrong in my code.