How to load an image (say a JPG file into Turbo C or C++)?
If can't can it be done only in VC++? :-|

How to load an image (say a JPG file into Turbo C or C++)?
If can't can it be done only in VC++? :-|

It's a little bit complicated...Assume an image is an array of values - for every pixel in that image, it is assigned a value in that array; but this is a simple bitmap. To load a JPG image, that is a compressed file, you should first transpose it in a bitmap file; you have to know the standard JPG compression (something based on Discrete Cosine Transform) etc...
In Turbo C/C++ you can load images with up to 16 colours, since it is working on DOS; in VC++ you can print out any image, with no matter how colourful it is (up to 32 bits/pixel) (excuse my english; it's not my native language; I hope you get the point)...

One of the strengths of C (and C++ and other languages) is that you can do just about anything you want.
An image file is nothing more or less than a collection of data. If you know the algorithm you can decipher that data.
http://www.wotsit.org/ has a lot of information about file formats (not just graphic) which you can use (including quite often implementations in several languages as examples).

More platform specific, several compilers ship with their own libraries to load and display images of several formats (Borland and Microsoft for example in their C++ platforms).

A Windows GUI program can handle this best. I have attached a sample created by BCX and modified for PellesC, all free downloads from the net.

Hi, sir:
Would you give me the source code for loading image (256 colors) in C. Could you send it to my E-mail Address?
thanks for your help.
Vathanak

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.