We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, When i try the resize() function in the android mode, it gives me the following error
FATAL EXCEPTION: Animation Thread
java.lang.NullPointerException
at android.graphics.Bitmap.checkPixelsAccess(Bitmap.java:834)
at android.graphics.Bitmap.setPixels(Bitmap.java:892)
at processing.core.PGraphicsAndroid2D.imageImpl(Unknown Source)
at processing.core.PGraphics.image(Unknown Source)
at processing.core.PGraphics.image(Unknown Source)
at processing.core.PApplet.image(Unknown Source)
at processing.test.the_timetable.The_timetable$Lecture.draw_normal_state(The_timetable.java:699)
at processing.test.the_timetable.The_timetable$Lecture.draw_lecture(The_timetable.java:670)
at processing.test.the_timetable.The_timetable$Day.draw_day(The_timetable.java:506)
at processing.test.the_timetable.The_timetable$Week.draw(The_timetable.java:1740)
at processing.test.the_timetable.The_timetable.draw(The_timetable.java:67)
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:1019)
I think that resizing the image using the method image(x, y, width, height) is horrible because it drops the frame rate down to about 10 fps on my android device, and this ruins the app.
How can i resize the image once ?
Answers
Instead of resizing it with processing ,how about you use a larger or smaller version of the image ...for instance you can resize it with microsoft office before you import to Processing but you should note though, you can't have a constant image size if you intend to run your application on different android devices because different devices have different screen sizes
Hi, you could resize all the images you want by doing something like this:
Matrix push / pops and transformations are generally really bad for the framerate as well, which goes against the poster's original intentions...
Are you sure? I thought that it was a good practice in opengl the use of matrix transformations
Perhaps in OpenGL, but that isn't Processing's default renderer in either Java or Android mode. In general, transformations kill performance when using Java2D.... at least in my experience.
I got the same problem and found a walk-around of resize() in the android mode. That's using copy() method.
I agree that using image(x,y,width,height) in draw() function induces a huge overhead. I think it's always better to have resized PImage at your setup(). Try this:
example..
img.resize(400, 400); img.loadPixels(); ////insert this!!
ciao
[code] img.resize(400, 400); img.loadPixels();////insert this [/code]
Camperos you are, simply, the fucking boss<3
use in the following order and it will work. image.loadPixels(); image.resize(targetW,targetH); image.updatePixels();