01-28-2005, 01:16 AM
Sometimes, other BASICs can provide useful stuff. Case in point, this JPEG library that is used often in LibertyBasic:
http://www.nodtveidt.net/fb/jpegdll.zip
Wow, what an utterly crappy language LibertyBasic is. :barf: Talk about code obfuscation...Anyways, this isn't hard to use. Basically, you have a UInteger handle that will be a handle to the image when loaded, and you pass the hwnd of the window making the call (it works this way but I'm not 110% sure that that's how it's designed to work...but it works anyways). LoadImageFile will return the handle to the image. In your WM_PAINT, you want a Compatible DC (CreateCompatibleDC) and use SelectObject on the image handle you got earlier. Then, just BitBlt the image and use DeleteObject on the DC after you call EndPaint. The WM_PAINT code I tested this with looks like this:
whereas jpegimg is the handle that was returned by LoadImageFile.
I hope this is of use to someone...it sure was of use to me. Also, this can load more than JPEGs...according to some online docs, it is supposed to be able to handle jpg, bmp, gif, ico, wmf and emf formats. From my tests, it loads JPEG images exceptionally fast, so it's useful for loading many images into many objects in sequence. This looks like it has solved the image nightmares that would have plagued the GUI Compiler...and in the meantime, has actually extended its capabilities.
http://www.nodtveidt.net/fb/jpegdll.zip
Wow, what an utterly crappy language LibertyBasic is. :barf: Talk about code obfuscation...Anyways, this isn't hard to use. Basically, you have a UInteger handle that will be a handle to the image when loaded, and you pass the hwnd of the window making the call (it works this way but I'm not 110% sure that that's how it's designed to work...but it works anyways). LoadImageFile will return the handle to the image. In your WM_PAINT, you want a Compatible DC (CreateCompatibleDC) and use SelectObject on the image handle you got earlier. Then, just BitBlt the image and use DeleteObject on the DC after you call EndPaint. The WM_PAINT code I tested this with looks like this:
Code:
hdc = BeginPaint(imghwnd,pnt)
hsrcdc = CreateCompatibleDC(hDC)
SelectObject(hsrcdc, jpegimg)
BitBlt(hDC, 0, 0, 320, 240, hsrcdc, 0, 0, SRCCOPY)
EndPaint hWnd, pnt
DeleteObject(hsrcdc)
UpdateWindow hWnd
I hope this is of use to someone...it sure was of use to me. Also, this can load more than JPEGs...according to some online docs, it is supposed to be able to handle jpg, bmp, gif, ico, wmf and emf formats. From my tests, it loads JPEG images exceptionally fast, so it's useful for loading many images into many objects in sequence. This looks like it has solved the image nightmares that would have plagued the GUI Compiler...and in the meantime, has actually extended its capabilities.
I'd knock on wood, but my desk is particle board.