Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
antonio difruscia
antonio difruscia's Profile
1
Posts
3
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
scale a background picture
[3 Replies]
28-Jul-2013 05:35 AM
Forum:
Contributed Library Questions
I'm trying to scale a jpg that I am using for a background. I have written code, but its not working. Can someone help with this ?
PImage GSimg, bgimg;
float tolerance = 22;
PImage GSimgout;
import controlP5.*;
ControlP5 controlP5;
float scale = 0.92;
void setup() {
GSimg = loadImage("familyGreen.jpg");
GSimg.resize(700, 494);
bgimg = loadImage("Hiking.jpg");
// bgimg.resize(1050, 494);
pushMatrix();
translate(width/2,height/2);
scale(scale);
popMatrix();
size(GSimg.width, GSimg.height);
controlP5 = new ControlP5(this);
controlP5.addSlider("scale",0,50,20,20,100,30);
}
void draw() {
for (int x = 0; x < GSimg.width; x++)
{
for (int y = 0; y < GSimg.height; y++)
{
float r = red(GSimg.get(x, y));
float g = green(GSimg.get(x, y));
float b = blue(GSimg.get(x, y));
if (g > b + tolerance && g > r + tolerance)
{
GSimg.set(x, y, bgimg.get(x, y)) ;
}//end if
}//end for
}
image(GSimg, 0, 0);
save("Familymtngreenout.jpg");
}
«Prev
Next »
Moderate user : antonio difruscia
Forum