Little problem with an ArrayIndexOutOfBoundsException !
in
Programming Questions
•
3 months ago
Hi,
I'm currently working on a way to make a book of an image, and in that way to write every hex color code of every pixel of the image in single PDF pages. My script work great but when I arrived to a certain value in my loop i got the super nice message ArrayIndexOutOfBoundsException. But i don't understand why ...
- import processing.pdf.*;
- PImage img;
- PFont myFont;
- int q ;
- void setup() {
- size(1000, 1000, PDF, "livre.pdf");
- img = loadImage("img50.jpg");
- }
- void draw() {
- background(255);
- frameRate(30);
- myFont = createFont("Monkey", 58);
- textFont(myFont);
- fill(0);
- int pixel_long = (img.pixels).length;
- println(pixel_long);
- for (int i = 900; i<pixel_long;i=i+900) {
- String [] pixel = str(img.pixels);
- for (int k = 0;k<pixel_long;k=k+1) {
- pixel[k] = hex(int(pixel[k]), 6);
- }
- String [] pixel_singlepage = subset(pixel, i-900, i);
- println(pixel_singlepage);
- String writing_pixel;
- writing_pixel=join(sa3, " ");
- textSize(18);
- text(writing_pixel, 12, 0, width, height);
- PGraphicsPDF pdf = (PGraphicsPDF) g;
- pdf.nextPage();
- }
- println("finish");
- noLoop();
- exit();
- }
PS : My ArrayIndexOutOfBoundsException problem is on the line 33 ...
Thanks for the one who reply !
Max
1