yes i do beleive, because the other numbers are zero in file ( i just opened it and saw )
well... i have worked a little more on my problem... and discovered very strange thing... ok here i am showing my code:
All the structures are being saved in a big array which was allocated by the calloc in the above code, and the structure has the following type:
ReadImageInfo(&imageheader, &imageinfo, image1);
RGBQUAD *pixel = (RGBQUAD *)calloc(imageinfo.bwidth * imageinfo.bheight, sizeof(RGBQUAD));
if (pixel == NULL)
printf("No memory available!\n");
for (i = imageinfo.bwidth*imageinfo.bheight; i>=imageinfo.bwidth-1; i-=imageinfo.bwidth)
for (j = i-imageinfo.bwidth; j<=i-1; j++)
fread(&(pixel+j)->blue, 1, 1, image1);
fread(&(pixel+j)->green, 1, 1, image1);
fread(&(pixel+j)->red, 1, 1, image1);
/* This piece of code saves RGB colors of each pixel(or structure in an array) in the text file
and it also saves the offset position from the pixel near the RGB data. */
for (j = 0; j <= imageinfo.bwidth * imageinfo.bheight - 1; j++)
fprintf(imsnap, "%d ", (pixel+j)->red);
fprintf(imsnap, "%d ", (pixel+j)->green);
fprintf(imsnap, "%d\t%d\n", (pixel+j)->blue, j);
well, who worked with BMP files, probably know that they are reversed, so i am reading the file and simultaneously putting the files in the appropriate position in a memory convenient for me.. just reverse it..
typedef struct rgbquad
unsigned char red;
unsigned char green;
unsigned char blue;
interesting thing is... when i try to open different images...the program does not read the correct values from the file! and does not save correct values in structure arrays!!!
but... i have tried same with 500x500 bmp image size...and i saw that it worked perfectly! and saved all the data in a statistical file as i want!! very strange!
later...i decided to load some another BMP picture with a dimension of 500x500... and it didnt work! ....i think code works very good! but...
what a problem could be? any ideas? thank you very much for an attention