image reading

V

vimal3271

I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ? pls
inform me.
 
V

vippstar

I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ?

You can open files with fopen. You can read their data with various
functions, for example, fgetc, fread.
The headers that should be included depend on the functions you are
going to use.
Any decent C book will help you with all these.
I recommend K&R2.
pls inform me.

pls? Don't you mean please? Type the whole word, please.
 
R

Richard Tobin

I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ? pls
inform me.

You probably don't want to write this yourself. There are free
libraries available for the common formats like JPEG and TIFF, and
they should be fairly portable. Obviously displaying an image is
system-dependent, but just reading in the data is much less so.

Start by Googling for libjpeg, libtiff, libpng...

-- Richard
 
V

vippstar

(e-mail address removed) said:



Perhaps you could remind me which section of K&R2 deals with image formats?

OP mentioned image files, image files are just files.
 
A

adam majewski

(e-mail address removed) pisze:
I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ? pls
inform me.
For me the simplest image file is PPM. If you can create file you can
also read it.

==================
#include <stdio.h>
int main() {
const int dimx = 800;
const int dimy = 800;
int i, j;
FILE * fp = fopen("first.ppm", "wb"); /* b - tryb binarny */
fprintf(fp, "P6\n%d %d\n255\n", dimx, dimy);
for(j=0; j<dimy; ++j){
for(i=0; i<dimx; ++i){
static unsigned char color[3];
color[0]=i % 255; /* red */
color[1]=j % 255; /* green */
color[2]=(i*j) % 255; /* blue */
fwrite(color,1,3,fp);
}
}
fclose(fp);
return 0;
}

====================================


Look also :

http://fraktal.republika.pl/g_file.html


HTH

Adam
 
J

jellybean stonerfish

I want to know how to read image files in C.. what are the headers that
i should include? is there any tutorials regarding this ? pls inform me.

Well, it depends on which formats you need to open. Do you just want to
read the image files, or be able to display them.

You could try "Developer's Image Library" and write code to use it.

http://directory.fsf.org/project/DevIL/

Or for more open source image libraries, you could look here.

http://directory.fsf.org/category/ilibs/



stonerfish
 
A

Antoninus Twink

(e-mail address removed) said:
On one level, yes, that's true - but if he just meant arbitrary files, he'd
have said so. He specifically mentioned image files, and it doesn't
require a genius to deduce that he wishes to do some kind of image
processing (even if it's only display), which means he's going to need to
be able to decode image formats. He realises this. I realise this. And I
suspect you realise this too. To pretend otherwise is disingenuous.

Not so much fun when it's someone else playing the
deliberate-misunderstanding game, is it?
 
V

vippstar

(e-mail address removed) said:





On one level, yes, that's true - but if he just meant arbitrary files, he'd
have said so. He specifically mentioned image files, and it doesn't
require a genius to deduce that he wishes to do some kind of image
processing (even if it's only display), which means he's going to need to
be able to decode image formats. He realises this. I realise this. And I
suspect you realise this too. To pretend otherwise is disingenuous.

I mentioned what's possible within standard C.
If someone asks for arrays, I'll reply for C arrays; I don't care if
he was obviously asking for something else, ie arrays in computer
science et cetera.
That's for three reasons

1) One who gets replies quite different than what he expected, would
stop and think if he's asking in the right newsgroup. (especially
since someone would suggest that...)
2) One who searches comp.lang.c for arrays won't find replies to CS
arrays; he'll find replies for C arrays.
3) Replying for CS arrays would be off-topic; Telling him to ask in a
CS newsgroup would be misleading to those who search for arrays in
this newsgroup.
 
V

vippstar

On Oct 6, 8:09 pm, (e-mail address removed) wrote:
ie arrays in computer science et cetera.
^^ ^^ ^^^^^^

Whoops, that might piss those who know latin well... :)
 
B

Bartc

I mentioned what's possible within standard C.
If someone asks for arrays, I'll reply for C arrays; I don't care if
he was obviously asking for something else, ie arrays in computer
science et cetera.

So what's the difference between a computer science array and a C one?
 
K

Kenny McCormack

Richard Heathfield said:
Yes, you use
fopen and getc and so on to get the data into memory, but there's a lot
more to it than that. Whilst, strictly speaking, such questions are not as
topical as they perhaps might be, it doesn't do anyone any favours for you
to pretend you don't know what he almost certainly is really after.

Irony meters all over CLC have just gone Poof!
 
R

Richard Bos

Bartc said:
So what's the difference between a computer science array and a C one?

A C array is a specific kind of computer science array. A general array
is a number of elements in some kind of order. A C array is a number of
elements of the same type, in ascending, last-index-changes-first order.

Richard
 
R

Richard Bos

Malcolm McLean said:
Basic Algorithms includes chapters on BMP, GIF and JPEG formats. Code is
free to download.

And free to use? You have no license on your website that I can find, so
anyone thinking about using that code in a commercial context _has_ to
decide against it. If that's not your attention, you should make that
clear - not here, but in the code itself.

Richard
 
V

vippstar

So what's the difference between a computer science array and a C one?

You can point to one element past the last of an array in C. CS arrays
don't care about that.
It was an example anyway.
 
V

vippstar

(e-mail address removed) said:

Within standard C, it's possible to read all kinds of image formats in
useful ways that let you do productive image processing. Yes, you use
fopen and getc and so on to get the data into memory, but there's a lot
more to it than that. Whilst, strictly speaking, such questions are not as
topical as they perhaps might be, it doesn't do anyone any favours for you
to pretend you don't know what he almost certainly is really after.

You snipped the part where I explain why I chose to behave as if I
didn't know what OP is talking about.
 
K

Kenny McCormack

You snipped the part where I explain why I chose to behave as if I
didn't know what OP is talking about.

This is just so funny, on so many levels.
 
V

vippstar

(e-mail address removed) said:



Whatever. Such behaviour is self-marginalising.

I tried to search for "self-marginalising", but the results I get from
dictionaries are definitions of the word marginalise, which don't
help. What do you mean?

Also, would you mind explaining these posts by you? Were you self-
marginalising as well, or is there something in those cases that made
you post what you posted?

Message-ID: <[email protected]>
Message-ID: <[email protected]>

They appear similar to mine.
 
J

jameskuyper

I tried to search for "self-marginalising", but the results I get from
dictionaries are definitions of the word marginalise, which don't
help. What do you mean?

To marginalize something means to move it to the margins; in this
context, that implies that it has been rendered unimportant. The
concept behind this meaning is that center of something is more
important than it's margins. Saying that you are "self marginalizing"
means that you are rendering yourself unimportant.
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top