我試圖從Android處理草圖保存圖像,但出現錯誤。如何將我的草圖保存到用戶手機圖庫中的圖像文件?從Android處理草圖保存圖像
public void draw(){
beginShape();
for (int i=0; i<d.length; i++){
d[i].maison();
int stroke1 = (int) random(255);
int stroke2 = (int) random(255);
int stroke3 = (int) random(255);
stroke(stroke1, stroke2, stroke3);
noFill();
vertex(d[i].x , d[i].y);
}
endShape(CLOSE);
UUID idOne = UUID.randomUUID();
save(idOne + ".tga");
}
錯誤:
09-15 23:47:25.939 23317-23389/tutorials.androidstudio.fragmentsv3 E/AndroidRuntime: FATAL EXCEPTION: Animation Thread Process: tutorials.androidstudio.fragmentsv3, PID: 23317 java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.app.Activity.getFileStreamPath(java.lang.String)' on a null object reference at processing.core.PApplet.sketchPath(Unknown Source) at processing.core.PApplet.savePath(Unknown Source) at processing.core.PApplet.save(Unknown Source) at tutorials.androidstudio.fragmentsv3.Sketch$override.draw(Sketch.java:74) at tutorials.androidstudio.fragmentsv3.Sketch$override.access$dispatch(Sketch.java) at tutorials.androidstudio.fragmentsv3.Sketch.draw(Sketch.java:0) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:818)