Saving overlapped masked images larger than stage
in
Programming Questions
•
3 months ago
Hi,
I'm working on a simple paint type application, but I want to use masks. You pick two images and 'paint' the mask.
- PGraphics maskPattern;
- PImage img;
- PImage img2;
- void setup() {
- img = loadImage("moonwalk.jpg");
- size(800,400);
- maskPattern = createGraphics(img.width,img.height);
- img2 = loadImage("greenmountains.jpg");
- }
- void draw() {
- background(0);
- image(img2,0,0);
- if (mousePressed == true) {
- maskPaint();
- }
- img.mask(maskPattern);
- image(img,0,0);
- }
- void maskPaint(){
- maskPattern.beginDraw();
- //pg.background(0);
- maskPattern.stroke(255);
- maskPattern.fill(255);
- maskPattern.ellipse(mouseX,mouseY,50,50);
- maskPattern.endDraw();
- }
- void keyPressed() {
- if(key == ' ')
- {
- saveFrame("mask_image.jpg");
- }
- }
I would like to be able to save these images at higher resolution than the stage dimensions allow. saveFrame "flattens" the first image, the mask, and the second image to make an image. This is the functionality I would like, but it is at the resolution of the stage. It would be nice to be able to bring in photos with higher resolution than the stage (like a cellphone res), draw your mask and save everything at a higher resolution jpg.
Is there a simple "combining" or "flattening" functionality? Or will I need to go through the pixels on a new PImage and assign img or img2 to a particular pixel depending on the mask's pixel information (0 vs. 255)? Or maybe this is a job for shaders (which I have no experience with)?
Any advice is appreciated.
1