Hi,
I didn't find a solution via Google and forum search: I have an image loaded via LoadImage_()-API and want to pass it to a PureBasic written DLL. How can I grab the image and put it into a PureBasic image?
Copy image from LoadImage_() into PB-image
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Copy image from LoadImage_() into PB-image
Hi
Code: Select all
OpenWindow(0,0,0,400,400,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
imgH = LoadImage_(0,"g:\mmedia\pictures\girl8.bmp",#IMAGE_BITMAP,128,128,#LR_LOADFROMFILE)
PBimg = CreateImage(#PB_Any,128,128,32)
StartDrawing(ImageOutput(PBimg))
DrawImage(imgH,0,0)
StopDrawing()
DeleteObject_(imgH)
ImageGadget(0,0,0,400,400,ImageID(PBimg))
;FreeImage(PBimg)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
End
Egypt my love
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Copy image from LoadImage_() into PB-image
Hi rashad,
yes of course. I just realized that I've done this before...anyway, thanks for the answer.
How do I get the dimensions of the picture (which I don't know beforehand)? I guess I need
?
yes of course. I just realized that I've done this before...anyway, thanks for the answer.
How do I get the dimensions of the picture (which I don't know beforehand)? I guess I need
Code: Select all
Define dimensions.bitmap
GetObject_(myimage, sizeof(dimensions),dimensions)
Debug "width: "+Str(dimensions\bmwidth)
Debug "height: "+Str(dimensions\bmheight)
Re: Copy image from LoadImage_() into PB-image
With LoadImage_() you already know the image width & height
Code: Select all
HANDLE LoadImage(
HINSTANCE hinst, // handle of the instance that contains the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);
Egypt my love
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Copy image from LoadImage_() into PB-image
Nope, I get the handle passed from an application to my DLL. I know I could also pass the dimensions, but that's not an option, the function is multipurpose and an extra parameter would be useless for all other calls.