lunes, 27 de febrero de 2017

Modificacion de archivos forma interactiva

// Leee y modifica un archivo jpg // Interfaz interactiva // sketch_bytes_3_imagen_lista2 // Ing. francisco Villavicencio public PImage img; public PImage imgsalida; public byte b[]; void setup() { size (1800,1000); selectInput("Select a file to process:", "fileSelected"); } void draw() { } void fileSelected(File selection) { if (selection == null) { println("Window was closed or the user hit cancel."); } else { b = loadBytes(selection.getAbsolutePath()); println("Archivo inicial " + selection.getAbsolutePath() + " " + b.length); bytes (); } } void bytes () { // Open a file and read its binary data // byte b[] = loadBytes("uno.jpg"); // Print each value, from 0 to 255 for (int i = 0; i < 20; i++) { int index = int(random(b.length)); b[index] = byte (80); } salida (); } void salida (){ // Writes the bytes to a file String a = "dos2.jpg"; saveBytes(a, b); println ("Archivo final " + a + " " + b.length); } import processing.video.*; public PImage imgsalida; public byte b[]; // Leee y modifica un archivo video // sketch_bytes_6_video_1 // Interfaz interactiva // Ing. francisco Villavicencio void setup() { size(720, 402); selectInput("Select a file to process:", "fileSelected"); } void draw() { } void fileSelected(File selection) { if (selection == null) { println("Window was closed or the user hit cancel."); } else { b = loadBytes(selection.getAbsolutePath()); println("Archivo inicial " + selection.getAbsolutePath() + " " + b.length); bytes (); } } void bytes () { // Open a file and read its binary data for (int i = 0; i < 200; i++) { int index = int(random(b.length)); b[index] = byte (100); } salida (); } void salida () { // Writes the bytes to a file String a = "2.MOV"; saveBytes(a, b); println ("Archivo final " + a + " " + b.length); }

No hay comentarios: