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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to