Revision: 1052
          http://swingme.svn.sourceforge.net/swingme/?rev=1052&view=rev
Author:   janeroski
Date:     2010-06-29 11:49:46 +0000 (Tue, 29 Jun 2010)
Log Message:
-----------
Image: Hack for OutOfMemory Exception when creating images
Modified Paths:
--------------
    AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Image.java	2010-06-28 16:38:03 UTC (rev 1051)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Image.java	2010-06-29 11:49:46 UTC (rev 1052)
@@ -67,6 +67,14 @@
         int size = Math.max(stream.available(), 8 * 1024);
         BufferedInputStream buffInput = new BufferedInputStream(stream, size);
 
+        BitmapFactory.Options opts = new BitmapFactory.Options();
+        try {
+            BitmapFactory.Options.class.getField("inPurgeable").set(opts, true);
+        } catch (Exception e) {
+            // inPurgeable not supported
+            // http://www.droidnova.com/2d-sprite-animation-in-android-addendum,505.html
+        }
+
         Bitmap bitmap;
         try {
             bitmap = BitmapFactory.decodeStream(buffInput);
@@ -115,6 +123,15 @@
     }
 
     public static Image createImage(byte[] imgData, int offset, int length) {
+
+        BitmapFactory.Options opts = new BitmapFactory.Options();
+        try {
+            BitmapFactory.Options.class.getField("inPurgeable").set(opts, true);
+        } catch (Exception e) {
+            // inPurgeable not supported
+            // http://www.droidnova.com/2d-sprite-animation-in-android-addendum,505.html
+        }
+
         Bitmap bitmap;
         try {
             bitmap = BitmapFactory.decodeByteArray(imgData, offset, length);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |