Android and PImage array
in
Android Processing
•
4 months ago
hello,
i try to write an app. the aim is to play animation as long as the user drag its finger into the screen.
i tested different lengths of the array. it works until 18 images.
- import android.view.MotionEvent;
- PImage[] mesImages;
- int positionLecture;
- void setup()
- {
- orientation(LANDSCAPE);
- mesImages = new PImage [17];
- for (int i=0; i < mesImages.length; i++) {
- mesImages[i]=loadImage("/storage/extSdCard/processing/Neige-Laura-"+nf(i, 3)+".png");
- }
- positionLecture =0;
- }
- void draw()
- {
- image(mesImages[positionLecture], 0, 0);
- }
- void mouseDragged()
- {
- positionLecture++;
- if (positionLecture==mesImages.length) {
- positionLecture=0;
- }
- }
- void mousePressed()
- {
- }
- public boolean surfaceTouchEvent(MotionEvent event) {
- //call to keep mouseX, mouseY, etc updated
- super.surfaceTouchEvent(event);
- //forward event to class for processing
- return gesture.surfaceTouchEvent(event);
- }
when mesImages.length > 18, here's the error message i get :
FATAL EXCEPTION: Animation Threadjava.lang.OutOfMemoryErrorat android.graphics.BitmapFactory.nativeDecodeStream(Native Method)at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:650)at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:722)at processing.core.PApplet.loadImage(Unknown Source)at processing.test.laura_video_01_android.laura_video_01_android.setup(laura_video_01_android.java:55)at processing.core.PApplet.handleDraw(Unknown Source)at processing.core.PGraphicsAndroid2D.requestDraw(PGraphicsAndroid2D.java:169)at processing.core.PApplet.run(Unknown Source)at java.lang.Thread.run(Thread.java:856)
Any idea ?
1