The decode byte array call expects JPEG compressed data.  You should
be consistent about either using unpacked bytes, as in your save
operation, or packed bytes, as in your read operation.

--SJ

On Mon, Sep 27, 2010 at 6:38 AM, Jey <jp9894562...@gmail.com> wrote:
> Hi all,
>
>       Am trying to store all images in my server, then i need to show
> based on requirements, i am able to store and restore bitmap bytes but
> i cant recreate the bitmap using stored bytes , pls find my code below
> and suggest me a solution if i doing wrong
>
>
> Converting Bitmap to Bytes
>
>                                        Drawable
> d=(Drawable)Packageinfo.myApplicationInfo.loadIcon(getPackageManager());
>                                        Bitmap bitmap = ((BitmapDrawable) 
> d).getBitmap();
>                                        int siz = bitmap.getHeight() * 
> bitmap.getWidth();
>                                        java.nio.ByteBuffer buffer = 
> java.nio.ByteBuffer.allocate(siz);
>                                        bitmap.copyPixelsToBuffer(buffer);
>                                        byte[] arr = buffer.array();
>                                        String bytedata = arr.toString();
>
> Recreating bitmap from Bytes
>
>                                ImageView icon = (ImageView) 
> v.findViewById(R.id.sampleimg);
>                                Bitmap b = 
> BitmapFactory.decodeByteArray(bytedata .getBytes(), 0,
> bytedata .getBytes.length);
>                                icon.setImageBitmap(b);
>
>
> Regards
> jp
>
> --
> 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