We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Rotating a picture on 3 different ways
Page Index Toggle Pages: 1
Rotating a picture on 3 different ways (Read 610 times)
Rotating a picture on 3 different ways
Mar 1st, 2009, 1:09pm
 
Hello,

I'm kinda new to Processing, used it for some small programs, but I want to make a program now where I can upload a picture and rotate it in different ways.
- without interpolation
- Nearest Neighbor interpolation
- Bilineare interpolation

So far I got this:

PImage b;
int my;
int mx;
int[] pixels;
PImage online;

void setup() {
 
 b = loadImage("http://weblog.marcovonk.nl/wp-files/2007/06/iets_raars_in_je_mailbox.jpg");
 size(b.width*2,b.height);
 my = b.height/2;
 mx = b.width/2;
 image(b, 0, 0);
 pixels = new color[b.width*b.height];
 for(int i = 0; i < b.height; i++) {
   for(int j = 0; j < b.width; j++) {
     loadPixels();
     color cp = get(x,y);
     pixels[i*j] = cp;
   }
 }
 image(cp, b.width, 0);

}

but i'm getting the error: the field component.x is not visible.

could someone help me with this error? and if you have an idea to be able to rotate a picture pls share it, cause it will help me alot Smiley
thnx

Bubbie.
Re: Rotating a picture on 3 different ways
Reply #1 - Mar 1st, 2009, 1:41pm
 
Note: there is a clash between your pixels[] array and the one built in PApplet that you initialize with loadPixels().
get() is just a slower way to access pixels[] data...
And if you write in the same array where you read, you will have troubles... Smiley

Rotation: I would just use rotate() in Processing, but of course it has less educational value... Wink
Page Index Toggle Pages: 1