How to load a .jpg onto a DirectDraw surface?

Started by
17 comments, last by Bad_Maniac 21 years, 5 months ago
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

Advertisement
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.
Don't we all still remember and miss the day we plotted our first pixel?
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?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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);
}
Don't we all still remember and miss the day we plotted our first pixel?
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]
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
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
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
The intel library is available: http://members.aol.com/Wannatolk/jpeg.zip.

By the way I wrote my own tutorial on loading bitmaps, JPEGs, and TGAs, at Flipcode.

~CGameProgrammer( );
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
sorry, I dont understand how can I do to load it from win32 program resources.



This topic is closed to new replies.

Advertisement