Original Post
🔒 Locked
Jpeg loader
Advertisement
If you have Visual Studio and the MSDN library, check out the help that comes with the function OleLoadPicture(). This is a win32 API call that loads jpeg, png, gif, tga, bmp and many other formats. It's a bit of a pain to get the buffer out of it, because it can render to a DeviceContext (which you normally use in Direct3D) but it doesn't supply a normal RGBA buffer. There is an example provided, loadpic, which shows how this function can be used. The only disadvantage is that you need Windows95 or higher and internet explorer 3 or higher. Windows95 OSR2 and higher comes with IE3.
I did a test with this code and it works ok. I've added a piece of code that will render the loaded image on a memoryDeviceContext which is then usable to grab the buffer from using GetDIBits. The code I've added is in WM_PAINT (pardon me for the horrible code, most of it is not mine, it's just testcode
)
NOTE:The buffer, pBuf, is freed just below the buffer is filled. I just checked it with the debugger. So it doesn't do anything with the received pixels.
enjoy. Oh and before you think you need a jpeg library... no, all is done using win32 api calls. no extra library needed.
LoadPic.cpp:
It has a menu and some icons. These are stored in a resource file. I can't paste that here, so you have to hack that out of the sourcecode.
Link with the normal .lib stuff.
Edited by - Otis on November 17, 2000 4:30:42 AM
I did a test with this code and it works ok. I've added a piece of code that will render the loaded image on a memoryDeviceContext which is then usable to grab the buffer from using GetDIBits. The code I've added is in WM_PAINT (pardon me for the horrible code, most of it is not mine, it's just testcode
NOTE:The buffer, pBuf, is freed just below the buffer is filled. I just checked it with the debugger. So it doesn't do anything with the received pixels.
enjoy. Oh and before you think you need a jpeg library... no, all is done using win32 api calls. no extra library needed.
LoadPic.cpp:
|
It has a menu and some icons. These are stored in a resource file. I can't paste that here, so you have to hack that out of the sourcecode.
Link with the normal .lib stuff.
Edited by - Otis on November 17, 2000 4:30:42 AM
i''ve been looking for a way to implement gifs for a long time. using the oleloadimage method looks like an efficient way to do this. i''m trying to use gifs as textures in opengl.
now, my problem is: how do i get the data out of a LPPICTURE object? i orientate myself on the opengl tutorials by nehe. he uses a structure called ''AUX_RGBImageRec''. its data is contained in ''AUX_RGBImageRec->data''. how should i do this with this LPPICTURE-stuff?
now, my problem is: how do i get the data out of a LPPICTURE object? i orientate myself on the opengl tutorials by nehe. he uses a structure called ''AUX_RGBImageRec''. its data is contained in ''AUX_RGBImageRec->data''. how should i do this with this LPPICTURE-stuff?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement