HI Siji.
Have you tried this aproach?

    public void convert(){

        ByteArrayInputStream imageStream = new ByteArrayInputStream(data);

        Bitmap theImage = BitmapFactory.decodeStream(imageStream);



        try {

             File file = FotoFolder.getFotoFile("fileName.png");

             FileOutputStream out = new FileOutputStream(file);

             theImage.compress(Bitmap.CompressFormat.PNG, 100, out);

             out.flush();

             out.close();

         } catch (Exception e) {

             e.printStackTrace();

         }

    }

2011/9/15 Siji T G <s...@techgentsia.com>

>
> I am trying to decode ARGB byte array into bitmap to display it as an
> image view. I tried using BitmapFactory's decodeByteArray() and
> decodeStream() but both way gives null as Bitmap.
>
> But when I create bitmap using createBitmap () and setPixels it works
> perfect. Here is the working code. data is the byte array of size
> imageWidth*imageHeight*4
>
>        int[] pixels=new int[imageWidth*imageHeight];
>
>
>    int i=0,j=0;
> while (i<imageWidth*imageHeight*4) {
>
>    pixels[j]= bytesToInt(data[i], data[i+1], data[i+2],data[i+3]);
>    i += 4;
>    j++;
> }
>    Bitmap bitmap=Bitmap.
> createBitmap( imageWidth,imageHeight,Bitmap.Config .ARGB_8888)
>
>     bmpf.setPixels(pixels, 0, imageWidth , 0, 0, imageWidth,
> imageHeight);
>
>     //---------------------- definition of bytesToInt()
>    int bytesToInt(byte b1,byte b2,byte b3,byte b4)
> {
>    return (((b1& 0xff)<<24)+((b2 & 0xff)<<16)+((b3&0xff)<<8)+
> (b4&0xff));
> }
> But I need to achieve this using decodeByteArray() or decodeStream()
> because for the later way I need to create integer array for
> setPixels() from the byte array , which is inefficient. What i am
> trying to implement is a video player , there fore it need to display
> around 15 frames/images per second.
>
> Hopes some one can help me in this. Thanks in advance
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to