Basic Programming part V - Challenge : Glitching/Datamoshing
Testing 3D Glitching on the Benchy
Using the Processing sketch given in the course :
// Open a file and read its binary data
byte b[] = loadBytes("/home/fablab/test.stl");
for (int i = 0; i < b.length; i++) {
if (b[i] == 0) {
b[i]= 127;
}
}
// Writes the bytes to a file
saveBytes("/home/fablab/test127.stl", b);
All the glitch tested
Testing 3D Glitching on a Rook
All the glitch tested, using the same sketch as for the Benchy
Glitching Program
Finding the RGB values of the BMP file
Thanks to this very useful article linked in the course : https://medium.com/sysf/bits-to-bitmaps-a-simple-walkthrough-of-bmp-image-format-765dc6857393
Modified sketch
// Open a file and read its binary data
byte b[] = loadBytes("test.bmp");
int a = 0;
for (int i = 41; i < b.length - 3; i += 3)
{
byte red = b[i];
byte green = b[i+1];
byte blue = b[i+2];
println("red " + red + " blue " + blue + " green " + green);
b[i] = red;
b[i+1] = green;
b[i+2] = blue;
//b[i] = byte(b[i]);
a = i;
}
println("done " + a);
// Writes the bytes to a file
saveBytes("test25.bmp", b);
Original sketch
// Open a file and read its binary data
byte b[] = loadBytes("/home/fablab/test.stl");
for (int i = 0; i < b.length; i++) {
if (b[i] == 0) {
b[i]= 127;
}
}
// Writes the bytes to a file
saveBytes("/home/fablab/test127.stl", b);