diff --git a/data/JPGHex.jpg b/data/JPGHex.jpg index eb3f77d..a0d58a1 100644 Binary files a/data/JPGHex.jpg and b/data/JPGHex.jpg differ diff --git a/data/WEBPhex.webp b/data/WEBPhex.webp new file mode 100644 index 0000000..eb72005 Binary files /dev/null and b/data/WEBPhex.webp differ diff --git a/data/img.png b/data/img.png new file mode 100644 index 0000000..cd6ce42 Binary files /dev/null and b/data/img.png differ diff --git a/data/result.png b/data/result.png new file mode 100644 index 0000000..7927e0f Binary files /dev/null and b/data/result.png differ diff --git a/data/result.webp b/data/result.webp new file mode 100644 index 0000000..92d7dcd Binary files /dev/null and b/data/result.webp differ diff --git a/data/saves.sav b/data/saves.sav index 1d2f80f..761c446 100755 --- a/data/saves.sav +++ b/data/saves.sav @@ -1,2 +1,2 @@ //globals -uptime = 116980695 +uptime = 117147364 diff --git a/data/webpdecode.command b/data/webpdecode.command new file mode 100755 index 0000000..7a01adf --- /dev/null +++ b/data/webpdecode.command @@ -0,0 +1 @@ +convert "/Users/giers/Documents/Processing 3/manglr2/data/result.webp" "/Users/giers/Documents/Processing 3/manglr2/data/result.png" diff --git a/data/webpencode.command b/data/webpencode.command new file mode 100755 index 0000000..e6a0f5e --- /dev/null +++ b/data/webpencode.command @@ -0,0 +1 @@ +convert "/Users/giers/Documents/Processing 3/manglr2/data/img.png" "/Users/giers/Documents/Processing 3/manglr2/data/WEBPhex.webp" diff --git a/effects.pde b/effects.pde index 5de1386..7879c58 100644 --- a/effects.pde +++ b/effects.pde @@ -4276,17 +4276,17 @@ class COLORCRUSHER extends Shader { /* - JPGHexGlitch + JPGCorruption by Victor Giers */ -class JPGHEXGLITCH extends Shader { +class JPGCORRUPTION extends Shader { PImage img; byte[] brokenfile; - JPGHEXGLITCH() { + JPGCORRUPTION() { name = "fxJPGHexGlitch"; - params.add(new Param("byte amount to change probability", INTVAL, 2, 20, new int[]{RANDOM})); + params.add(new Param("byte amount to change probability", INTVAL, 2, 200, new int[]{RANDOM})); params.add(new Param("iterations", INTVAL, 2, 10, new int[]{RANDOM})); params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM})); directionParamIndex = 2; @@ -4353,3 +4353,91 @@ class JPGHEXGLITCH extends Shader { return result; } } + +class WEBPCORRUPTION extends Shader { + PImage img; + byte[] brokenfile; + int rw, rh; + WEBPCORRUPTION() { + name = "fxWebpCorruption"; + params.add(new Param("byte amount to change probability", INTVAL, 2, 50, new int[]{RANDOM})); + params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM})); + directionParamIndex = 1; + rw = canvas.width; + rh = canvas.height; + img = createImage(rw, rh, ARGB); + String encodecmd[] = {"convert \"" + dataPath("") + "/img.png\" \"" + dataPath("") + "/WEBPhex.webp\""}; + String decodecmd[] = {"convert \"" + dataPath("") + "/result.webp\" \"" + dataPath("") + "/result.png\""}; + if (OS == "mac") { + saveStrings(dataPath("") + "/webpencode.command", encodecmd); + saveStrings(dataPath("") + "/webpdecode.command", decodecmd); + } else if (OS == "windows") { + saveStrings(dataPath("") + "/webpencode.cmd", encodecmd); + saveStrings(dataPath("") + "/webpdecode.cmd", decodecmd); + } + } + + void apply() { + if (rw != canvas.width || rh != canvas.height) { + rw = canvas.width; + rh = canvas.height; + img.resize(rw, rh); + } + int probparam = (int)params.get(0).value; + int iterations = (int)params.get(1).value; + img = canvas.get(); + canvas.beginDraw(); + boolean finished = false; + while(!finished) { + println("yo"); + canvas.image(img, canvas.width/2, canvas.height/2); + canvas.save(dataPath("")+"/img.png"); //save as png + delay(300); + launch(dataPath("") + "/webpencode.command"); + delay(1500); + brokenfile = loadBytes(dataPath("")+"/WEBPhex.webp"); //and reload. just in case it wasnt a jpg. + byte[] savebytes2 = new byte[brokenfile.length]; + double probability = float(probparam) / float(brokenfile.length); + int glitchCount = 0; + for (int i = 0; i < brokenfile.length; i++) { + String hexStr = hex(brokenfile[i]); + if (i > 10) { // skip header + if (random(1)