Re: opening jpeg file in c++
- From: David Resnick <lndresnick@xxxxxxxxx>
- Date: Fri, 31 Oct 2008 08:31:09 -0700 (PDT)
On Oct 31, 11:04 am, mohi <mohangupt...@xxxxxxxxx> wrote:
hello everyone ,
i am trying to read a jpeg image through c++ but is unable to do so ,
presently i tried it with code in c as i use something like ;
FILE * fp=fopen("./x.jpg","rb");
int c;
do{
fread(fp,&c,sizeof(c));
if( c==(int) 0xFF23){
do.....
do....
}
printf("%x",c);
}
while(c!=EOF);
but the problem is the if condition never evalutes to true as i know
that according to the jpeg standard there should be market with value
0xFFD8 and others also .....and also the printf() of integer 'c' as
hex is never displayed it just displays a blank ..
Make sure you turn on compiler warnings and #include <stdio.h>.
Look up fread, your code above has 3 arguments, fread has 4 and in a
sort of strange order:
size_t fread(void *ptr, size_t size, size_t nmemb, FILE
*stream);
0xFF23 is very likely bigger than an int on your machine, btw.
c will not be set to EOF, look at return status of fread.
You have lots of other issues too, but that should get you started.
-David
.
- References:
- opening jpeg file in c++
- From: mohi
- opening jpeg file in c++
- Prev by Date: Re: (part 1) Han from China answers your C questions
- Next by Date: Re: Judge the encode systm used by the file.
- Previous by thread: opening jpeg file in c++
- Next by thread: Re: opening jpeg file in c++
- Index(es):
Relevant Pages
|