0 Replies Latest reply on Dec 5, 2011 5:33 PM by cbigb

    How to convert Bitmap to FREBitmapData ....??

    cbigb Level 1

      Hello, all..

       

      How to convert Bitmap to FREBitmapData ....??

      my code is below..

      ---------------------------------------------------------------------- -----------------------------------------------------------

      Bitmap bitmap // <= bitmap image

       

      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

      bitmap.compress(CompressFormat.PNG, 100, outputStream);

      byte[] byteArray = outputStream.toByteArray();

       

      int width = bitmap.getWidth();

      int height = bitmap.getHeight();

       

      FREBitmapData bitmapData = FREBitmapData.newBitmapData(width, height, true, byteArray);  <== Error :

      ---------------------------------------------------------------------- ---------------------------------------------------------------------- -----------------------------------------------------

      12-05 20:34:45.773: W/System.err(9051): java.lang.IllegalArgumentException: fillColor has wrong length

      12-05 20:34:45.773: W/System.err(9051):           at com.adobe.fre.FREBitmapData.newBitmapData(FREBitmapData.java:66)

      12-05 20:34:45.773: W/System.err(9051):           at air.com.sec.flash.extension.library.bitmap.UriLoader$2.call(UriLoader .java:284)

      12-05 20:34:45.773: W/System.err(9051):           at com.adobe.air.customHandler.callTimeoutFunction(Native Method)

      12-05 20:34:45.773: W/System.err(9051):           at com.adobe.air.customHandler.callTimeoutFunction(Native Method)

      12-05 20:34:45.773: W/System.err(9051):           at com.adobe.air.customHandler.handleMessage(customHandler.java:18)

      12-05 20:34:45.773: W/System.err(9051):           at android.os.Handler.dispatchMessage(Handler.java:99)

      12-05 20:34:45.773: W/System.err(9051):           at android.os.Looper.loop(Looper.java:130)

      12-05 20:34:45.773: W/System.err(9051):           at android.app.ActivityThread.main(ActivityThread.java:3691)

      12-05 20:34:45.773: W/System.err(9051):           at java.lang.reflect.Method.invokeNative(Native Method)

      12-05 20:34:45.773: W/System.err(9051):           at java.lang.reflect.Method.invoke(Method.java:507)

      12-05 20:34:45.773: W/System.err(9051):           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit .java:907)

      12-05 20:34:45.773: W/System.err(9051):           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)

      12-05 20:34:45.773: W/System.err(9051):           at dalvik.system.NativeStart.main(Native Method)

      ---------------------------------------------------------------------- ---------------------------------------------------------------------- -----------------------------------------------------

       

      why wrong length??

      How to convert Bitmap to FREBitmapData ??

       

      in sample of the adobe, an same error occur..

      http://help.adobe.com/en_US/air/extensions/WS11d1def534ea1be0-67da1176 132a8869db6-7ffe.html

      ---------------------------------------------------------------------- ---------------------------------------------------------------------- -----------------------------------------------------

      Byte[] fillColor = {0xf,0xf,0xf,0xf,0xf,0xf,0xf,0xf};

      FREBitmapData bitmap = FREBitmapData.newBitmapData( 320, 200, true, fillColor );

      int lineStride = bitmap.getLineStride32();

      bitmap.acquire();

      ByteBuffer pixels = bitmap.getBits();

      pixels.position( lineStride * 3 );

      //do something with the image data

      bitmap.release();

      ---------------------------------------------------------------------- ---------------------------------------------------------------------- -----------------------------------------------------