Unable to use 'get' to copy screen
in
Android Processing
•
2 months ago
Hello!
I'm making an android app but having some bad problems.
I found that using 'get' crashes the application.
Since copying a part of the screen is the essential part of the app, I need to get it done but don't know how.
Is there any solution or workaround to do this?
Here is my code.
Original code is much much longer and contains a lot of functions that does not matter in this topic, so I quick-wrote an alternative code to demonstrate the failure caused by using 'get' and to show you the basic function of the drawer app.
- int pX = 0;
- int pY = 0;
- boolean firstTouch = true;
- PImage a;
- void setup() {
- orientation(PORTRAIT);
- background(255);
- a = new PImage(300, 400, ARGB);
- }
- void draw() {
- a = get(0, 0, 300, 400);
- image(a, 300, 0);
- }
- void mouseDragged() {
- stroke(0);
- strokeWeight(10);
- line(pX, pY, mouseX, mouseY);
- pX = mouseX;
- pY = mouseY;
- }
- void mousePressed() {
- if(firstTouch) {
- pX = mouseX;
- pY = mouseY;
- firstTouch = false;
- }
- }
- void mouseReleased() {
- firstTouch = true;
- }
So the code is basically a drawer, but the function I need so bad is to copy certain part of the screen and make it to a PImage variable.
The code crashes immediately after launching, but if you delete the 'get' part, it works just fine.
Thank you for your replies in advance!
Please help me out :'(
1