I am very new to c++ and was wondering if i could ask a question about loading JPG files into a small program that i have
At the moment my program is using an image file as a background, but it is using a .bmp file which is approx 700k's in size and if i make a jpg equivelant its only 70k's but i dont know how to use a .jpg file instead of a .bmp as the background
Is there something i need to add to the program to get it to accept a .jpg file instead of a .bmp
>> I am very new to c++ and was wondering if i could ask a question about loading JPG files into a small program that i have
Processing jpegs is not a beginner's project. There are libraries out there, such as libjpeg (written in C), that make the task much easier, though.
DevIL is a library that can load many different kind of image-files, and quite easy to use. I suggest you check it out. And its cross platform :D
DevIL - A full featured cross-platform Image Library
Which OS ?
On Windows, there are at least 8 native Win32 methods to load JPEG and any graphics formats (COM, Shell, and others)
hi, thanks for the reply , seeing as i know about as much as you could get on a 1st class stamp iam truely a novice, you see my app is using a bmp file as a dialog background and i want to use a jpg file which would resulting in a smaller .exe file
and alex31 iam currently using winxp
i had hoped it was just a matter of adding a few lines of code to make the changes needed..i had no idea using a jpg would be such a massive differance
But a JPG will have to be re-expanded back to a BMP (or something very similar to it) for you to be able to see it.
So are you really saving anything at all?
does it? ohh right, hmmm , but that would be expended at runtime i guess so the filesize then isnt important
Originally Posted by Salem
Simple. Don't put the image into your executable as a resource. Keep the image file external to your app. If you don't want anyone to be able to alter it you need to come up with a way to keep prying eyes away yet still load it from your app.
> but that would be expended at runtime i guess so the filesize then isnt important
There are no black-and-white answers. Saving something in one place could well cost you something somewhere else.
Converting a single BMP to JPG will save you some disk space, but you'll need another library in your code (and the time taken to code it and make it work) and some extra CPU time to display it. But since processors are much quicker than disks, only having to load a small file and expand it may be quicker than waiting for a larger BMP file to load.
But if you had 100 images say, you might be looking at a different answer.
Or a machine with very little CPU or memory. Again, you might be looking at different ways of doing things.