Save BMP images through C

N

Niks

i wanted to know if there is any way to save and open BMP images
through C.I wanteed to interact with some images through C.

Thanks for reading...
Niks
 
W

Walter Roberson

i wanted to know if there is any way to save and open BMP images
through C.I wanteed to interact with some images through C.

Standard C does not know anything about image formats.

You can get pre-written code, some of which might be fairly portable,
to parse and create BMP images. Here's one pointer to an article about
the internal format:

http://www.daubnet.com/formats/BMP.html


Note: if you are intending to -display- BMP images, then you are
inherently going to need to use facilities which are not part of C
(which does not know about graphics.) At that point, you might find
that all of the operating systems you are interested in having
your program run on, already provide BMP support, or that pre-written
BMP libraries are available for those OS's. Therefore unless you
are deliberately constructing a non-graphical graphics-file manipulation
program with wide portability as an important goal, then you might find
it more productive to use existing libraries rather than write your own.
 
M

Malcolm

Walter Roberson said:
Therefore unless you
are deliberately constructing a non-graphical graphics-file manipulation
program with wide portability as an important goal, then you might find
it more productive to use existing libraries rather than write your own.
You imply that this is quite an unusual thing to want to do.
If fact it is not - it is very common to want some sort of graphical output
from a program that is inherently portable.
For instance the other day I was having a go at the travelling salesman
problem, so the obvious way to get a visual fix on the algorithm is to
output a graph of the cities and route travelled.
 
J

John Tsiombikas (Nuclear / Mindlapse)

i wanted to know if there is any way to save and open BMP images
through C.I wanteed to interact with some images through C.

You most certainly can manipulate any file you want with C. The language
provides facilities for opening, reading and wrtiting files. Try reading
about fopen, fread, fwrite and similar functions of the standard C
library, or fgets, fputs, fprintf, etc for text-based I/O.

Of course C works with simple byte streams, not knowing anything, nor
imposing any specific structure on files, so you will have to either
implement the parsing of the bmp format yourself (by using the file i/o
functions provided by C), or find some code that does this job for you,
and use it.

In an off-topic comment, if you just want to interface with other image
manipulation/loading programs and you don't necessarily need the "bmp"
format but any one will do, try reading about "ppm" or "portable pixmap"
which is an extremely simple format to read and write.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top