Archived

This topic is now archived and is closed to further replies.

How to load a .jpg onto a DirectDraw surface?

This topic is 5528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yes I know there is a tutorial on this site. Yes I have read it, it uses the INTEL jpg library, wich is no longer available... any hints? Help me out please because: BMP''s are big =/ It''''s nice to be important, but it''''s more important to be nice.

Share this post


Link to post
Share on other sites
Works like a charm, thanks Xaminani.
Although it''s not exzctly what I''m looking for, does anyone have a jpg loader that they actually wrote themselves, or that can be included in a program?

So that I don''t have to include a dll file in my releases all the time...

It''''s nice to be important, but it''''s more important to be nice.

Share this post


Link to post
Share on other sites
quote:

D3DXLoadSurfaceFromFile
Loads a surface from a file.
...
This function supports the following file formats: .bmp, .dds, .dib, .jpg, .png, and .tga.



Striaght from the MS docs. This is for DX8 however, so you may not be able to use it (You didn''t say which version you were using). Otherwise, check out DevIL. It can load all sorts of things, but it really only works under MSVC++.

Share this post


Link to post
Share on other sites
Take a look to http://www.voicenet.com/~richgel

this man did your own load jpg library (i think is based on ijg library, im not sure)

else, you can take a look on http://members.aol.com/olivthill/

or in jpg.org or in paintlib or in cximage, you can find it in the web easily

elgransan

Share this post


Link to post
Share on other sites
Wow, that's a lot of info, I must be able to piece together one simple Load_Jpg (filename, *surface) function from all that. it's all I need =D

if you feel like giving me charity, email me a working routine to copy and paste to the email in my profile. I'm lazy =D

[Forgot the most important part]
Thanks a lot to you guys. Your help is appreciated!

It''s nice to be important, but it''s more important to be nice.

[edited by - Bad_Maniac on October 23, 2002 4:28:32 PM]

Share this post


Link to post
Share on other sites
well, I cant help you with that, Im looking for the same think a lot because I need a library that can load a jpg from a windows resource into memory, the CxImage do that, but it size up my code +400k, and the rest of my code is about, 400k to, so, is so expensive for me.

if someone knows what I have to do, please tell me, my email elgransan@yahoo.com.ar

elgransan
from Argentina (sorry my english)

Share this post


Link to post
Share on other sites
That''s exactly what I''m after, a function to load a jpg to a surface, nothing else at all. Maybe jpg is a bad choice?

is there a "better" format, for getting compressed images, that is easier to load than jpg, but smaller than bmp?

It''''s nice to be important, but it''''s more important to be nice.

Share this post


Link to post
Share on other sites
Bad_Maniac, its depends on what do you want to do with the image, for example, with jpg you dont have alpha-channel to do a smoth blittering over other image, you dont have transparents points and you cant asign one to be transparent because the color never is exact.
BUT.... is realy very cheap in term of size, so its very usesfull for background images.

example:

BMP = 900Kb
the others formats are about 100-150 kb
JPG = 40kb

Share this post


Link to post
Share on other sites
I wasn''t aware .jpg images don''t have exact colors. they might be very bad for my projects then, seeing that I want to use them for sprites, where a color is transparent.

I might as well use rle bitmaps, it''s easy enough to write a converter program. and a loader. Thanks a lot.

I still am looking for the simplest possible jpg loader, as size does matter. I''ve been looking through various sources I found here and from Google, but they are all too big. If I have a 900 kb .bmp and a 50 kb .exe, or a 900 kb .exe and a 50 kb jpg doesnt get me anywhere... (an obvious slight exaggeration) (sp?)

It''''s nice to be important, but it''''s more important to be nice.

Share this post


Link to post
Share on other sites
jpg are serious lossy encoding - considering the file size the quality is very high, but in an absolute sense they are quite poor and have a high rate of artifacts.

png is less compression (but I don''t recall if it''s light lossy compression like DV, or actually loseless).

Can you use Dx8?

Share this post


Link to post
Share on other sites
I am using the DX8.1 SDK, so yes I can use it, altohough I don''t understand a word of the D3D code, since I''m a C, not a C++ programmer =D
(that''s why I''m asking questions, not answering them, I''m still learning)

int Radeon_Ad(void)
{
IE_CRASH ++;
return(0);
}

Share this post


Link to post
Share on other sites
You might want to take this into considuration. I was in the _exact_ same spot as you, trying to find the chepest and fastest way of using images in my game. I finally decided that .jpg would for backgroundimages, which it did. BUT! They are only "smaller" on the harddrive, when DX loads them into memory it expands them just like a bitmap. With RPG values for each pixel. And that encoding/expanding (while loading) is time costly. I found using .jpg really made the loading longer, and didn''t really approve performance. But it saved HDD space (from 150mb to 32mb).

That''s my 2 cents...

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites
I know all that, but im doing a simple game to share it by email, and focuses to people that dont care about graphics cards, and to have the last win (so im using ddraw4 for win98se standard), so to load background images into dxsurface, I have to use jpg, i cant spend 900k x 4 bmp, the final .exe I wont share it, Im very frustrated with that.

The CxImage increase my code 400kb
The Small JPG Library, I can load the image from the Resource to the decoder class. But, I dont understand how to put in the dd_surface.



elgransan

Share this post


Link to post
Share on other sites
Bad_Maniac this is my code to load from CxImage library:

fndo1 = new CxImage();
if (!fondo1->LoadResource(FindResource(m_hInst, MAKEINTRESOURCE(IDR_JPG1), "JPG"), CXIMAGE_FORMAT_JPG))
Error("No se pudo cargar una imagen", 0);

DrawBitmap(fondo1->GetDIB(), 0, 0, dwWidth, dwHeight);

It''s very simple. And you can use it to load a lot anothers formats. If you use Dx8, or GDI+ you dont need all that thinks.

hope this help

But, dont forget me someone help me with my problem please!!! (see above)

elgransan

Share this post


Link to post
Share on other sites