Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage a, b, c;
- void setup() {
- size(642, 937);
- PImage temp = createImage(width, height, RGB);
- a = loadImage("a.jpg"); // reference image
- b = loadImage("b.jpg");
- if (a.width<a.height) {
- // reference image is portrait mode
- float ratio = (float) a.height/b.height;
- int w = int (b.width*ratio);
- int h = int (b.height*ratio);
- temp.copy(b, 0, 0, b.width, b.height, 0, 0, w, h);
- } else {
- // reference image is landscape mode
- float ratio = (float) a.width/b.width;
- int w = int (b.width*ratio);
- int h = int (b.height*ratio);
- temp.copy(b, 0, 0, b.width, b.height, 0, 0, w, h);
- }
- image(temp, 0, 0);
- }
- void draw() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement