I’m trying to create something like a hex editor for JPEG files in processing, and running this piece of code with any JPEG file results in a correct output, but one that excludes major parts of the file.
byte b[] = loadBytes("cat.jpg");
for (int i = 0; i < b.length; i++) {
if ((i % 10) == 0) {
println();
}
int a = b[i] & 0xff;
print(hex(a,2) + " ");
}
println();
This piece of code will output something like:
B2 92 E4 34 6D 83 09 52 0F 6E
FB 7F 97 D4 20 CF A6 5E 44 D3
...
However, when using a separate hex editor, one will find that the program has excluded the majority of the file, being that the output, when searched in the editor only appears later in the file:
Can anyone think of why this may be occurring or any potential solutions? Thanks!