public PImage getReversePImage( PImage image ) { PImage reverse = new PImage( image.width, image.height ); for( int i=0; i < image.width; i++ ){ for(int j=0; j < image.height; j++){ reverse.set( image.width - 1 - i, j, image.get(i, j) ); } } return reverse; }
Hi,
ReplyDeleteYour snippet works well, thanks :)
This a modified version which keeps alpha.
public PImage getReversePImage( PImage image ) {
PImage reverse;
reverse = createImage(image.width, image.height,ARGB );
for( int i=0; i < image.width; i++ ){
for(int j=0; j < image.height; j++){
int xPixel, yPixel;
xPixel = image.width - 1 - i;
yPixel = j;
reverse.pixels[yPixel*image.width+xPixel]=image.pixels[j*image.width+i] ;
}
}
return reverse;
}