Hello people,
I'm destroying jpegs but i'm running into trouble when i try to visualize each step, Basically it's
- Load in the jpeg
- Display it with image
- Load in the bytes
- Rearrange the bytes
- Save the bytes to jpeg
- And start over again
I've basically tried porting the OF-example "imagecompressionexample" to processing. In OF it's running inside "update" so you can see the jpeg gradually deterioriating (if you press "g").
In processing nothing happens, no artefacts or anything. The image just stays the same. I presume it has something to do with the file-i/o because it is running fine if it's run without looping file-i/o.
Any help on this is greatly appreciated!
FRid
Btw. inside the OF-example there is this (commented) function;
// using the OR operator |, if the bit isn't already on this will turn it on
buffer[whichByte] |= bitMask;
What does this do? Use "whichByte" OR "bitMask" as index for buffer? Then on what is this choice depending on?
I'm destroying jpegs but i'm running into trouble when i try to visualize each step, Basically it's
- Load in the jpeg
- Display it with image
- Load in the bytes
- Rearrange the bytes
- Save the bytes to jpeg
- And start over again
I've basically tried porting the OF-example "imagecompressionexample" to processing. In OF it's running inside "update" so you can see the jpeg gradually deterioriating (if you press "g").
In processing nothing happens, no artefacts or anything. The image just stays the same. I presume it has something to do with the file-i/o because it is running fine if it's run without looping file-i/o.
Any help on this is greatly appreciated!
FRid
Btw. inside the OF-example there is this (commented) function;
// using the OR operator |, if the bit isn't already on this will turn it on
buffer[whichByte] |= bitMask;
What does this do? Use "whichByte" OR "bitMask" as index for buffer? Then on what is this choice depending on?
- import java.io.*;
byte[] b;
PImage img;
void setup() {
size(700,700);
frameRate(1 );
}
void draw() {
img = loadImage("mod.jpg");
image(img, 0, 0);
b = loadBytes("mod.jpg");
int whichByte = int(random(b.length*0.1, b.length));
int whichBit = int(random(0,8));
byte bit = byte(1 << whichBit);
b[whichByte] = bit;
try {
OutputStream out = new FileOutputStream("mod.jpg");
println("ok?");
out.write(b);
out.flush();
out.close();
} catch (IOException e) {
println("Fuck!");
}
//saveBytes("mod.jpg", b);
}
void keyPressed() {
if (key == ' ') {
println("hoorah!");
}
}
1