Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imread() will decode the image, meaning: read & discard the jpeg header, then de-compress it.

what you receive, is the raw image pixels, all header information (and file magic) is gone

i have no idea, why you want to edit binary files on disk, but it will only work with uncompressed image formats, like pgm or bmp.

imread() will decode the image, meaning: read & discard the jpeg header, then de-compress it.

what you receive, is the raw image pixels, all header information (and file magic) is gone

i to see the image headers, instead of imread(), you will have no idea, why you want to edit binary files on disk, but it will only work with uncompressed image formats, like pgm or bmp.use low-level io:

ifstream in(argv[1],ios_base::binary);
while (in.good()) {
    uchar byte;
    in >> byte;
    printf("%x ",byte);
}

imread() will decode the image, meaning: read & discard the jpeg header, then de-compress it.

what you receive, is the raw image pixels, all header information (and file magic) is gone

to see the image headers, instead of imread(), you will have to use low-level io:

ifstream in(argv[1],ios_base::binary);
while (in.good()) {
    uchar byte;
    in >> byte;
    printf("%x ",byte);
}

but honestly, i think, you should forget about editing anything on this level immedeiately, e.g. you're simply not allowed to change the jpg file magic, as some programs will just refuse to read it.

imread() will decode the image, meaning: read & discard the jpeg header, then de-compress it.

what you receive, is the raw image pixels, all header information (and file magic) is gone

to see the image headers, instead of imread(), you will have to use low-level io:

ifstream in(argv[1],ios_base::binary);
while (in.good()) {
    uchar byte;
    in >> byte;
    printf("%x ",byte);
}

but honestly, i think, you should forget about editing anything on this level immedeiately, immediately, e.g. you're simply not allowed to change the jpg file magic, as some programs will just refuse to read it.