We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The method set(x,y,image) doesn't seem to be working in android mode, where image(image,x,y) works fine but is way too slow for the scale of the project I'm building. The error message I get returned states that my input PImage is null (which it isn't, as the image() method does work). Is there any known fix for this problem? (I will come with some error logs and actual code tomorrow)
Answers
try
loadPixels
and then use pixels[] ?
Hello!
Thanks for the answer, it worked! I will give more of an outline now .
Say, I have a sketch like this: `PImage image;
void setup() { image = loadImage("crate.png"); image.resize(256, 256); } void draw() { set(0, 0, image); }`
When ran in java mode, it runs fine. When ran in android mode, it gives the following error:
FATAL EXCEPTION: Animation Thread Process: processing.test.settest, PID: 6726 java.lang.NullPointerException: Attempt to get length of null array at android.graphics.Bitmap.checkPixelsAccess(Bitmap.java:1401) at android.graphics.Bitmap.setPixels(Bitmap.java:1463) at processing.core.PGraphicsAndroid2D.set(Unknown Source) at processing.core.PApplet.set(Unknown Source) at processing.test.settest.settest.draw(settest.java:26) 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)
However, if I use the same sketch but replace
set(0, 0, image);
withimage(image,0,0);
it did work.Using your example, when I want to use the set() method, this works:
`PImage image;
void setup() { image = loadImage("crate.png"); image.resize(256, 256); image.loadPixels(); //just added this line and all works fine :) } void draw() { set(0, 0, image); }`
Thanks for your help!!
why not use
image()
?also, I wouldn't call a var image, it's confusing since the command has the same name
;-)
Yea I know, the var image was just for testing purposes. The image() method is way too slow for the scale of the project I'm building (I get 60fps when using set(), and max 4fps when using image()).
I see