Strange pixels[] bug
in
Programming Questions
•
11 months ago
Hello, when I run this code using the default renderer (is that still JAVA2D?) in Processing 2.0b6 it runs as expected: the pixels from the source image are copied correctly to the PGraphics instance. Using P2D or P3D, though, the resulting image is flipped vertically and horizontally. Going through the pixels backwards means it's flipped horizontally only. Am I doing something wrong here or is this a bug?
- PImage src;
- PGraphics pg;
- void setup() {
- size(1280, 400, P2D);
- pg= createGraphics(1280, 800, P2D);
- src= loadImage("xx.png");
- pg.loadPixels();
- for(int i=0; i<src.pixels.length; i++){
- pg.pixels[i]= src.pixels[src.pixels.length-i];
- }
- pg.updatePixels();
- }
- void draw() {
- image(src, 0, 0, 640, 400);
- image(pg, 640, 0, 640, 400);
- }
1