Binary Files

Hello i'm traying to extract some images from a binary file so i would like to know if somebody knows what coul i do, or any idea..
I have a file .raw supposedly my teacher says it has some pictures, i need to read my file .raw in blocks of 512 and extract that images. thaks
There are many ways to store an image in a file...
A question is, do you have a way to check what you read? Some sort of graphics library.. If you don't try attaching a bmp header to the data (it is explained in wikipedia) and open it with paint (or anything else). Even if the header was not right, or there was some other information in the file, you should be able to deduce the problem from the image you see.
Unless there is some compression in that file. That would be just cruel..
well, now i know whta i have to read and i already know what the biginig and the end of the image is in my FILE.. the biginig its ff d8( that means that in caracters its: ff = 'ÿ' and d8='Ø') and the end its ffd9( ff = 'ÿ' and d9 = 'Ù').
my big problem is that I have to read my FILE in blocks of 512 bytes and read those 512 bytes
set them to an array of 512 positions, then find in the array de biginnig and go writing in a differebt file (.jpg) till i find the end. Here some idea of what i have to do:

//ffd8 = ÿØ
//ffd9 = ÿÙ
this->f = fopen("images.raw","rb");
fseek(f,0,SEEK_END); int size; char c; int contImagenes=0;
size= ftell(f)/sizeof(char);
fseek(f,0,SEEK_SET); int var=0;

for(int i=0; i<size; i++){
for(int k=0; k<512; k++){

if( this->array[k]== 'ÿ' && this->array[k+1] == 'Ø' ){
contImagenes++; QString convert,unir;
convert.setNum(contImagenes);
unir = "Image_"+convert+".jpg";
qDebug()<<"Biginnig Found";
this->jpg = fopen(unir.toStdString().c_str(),"wb");

fseek(this->jpg,0,SEEK_SET);


fwrite(&arreglo[k],sizeof(char),1,jpg);
fwrite(&arreglo[k+1],sizeof(char),1,jpg);
}
}
this->resetearArreglo();


I apologize if my English is not good enough
Last edited on
Topic archived. No new replies allowed.