how to convert bitmap into byte array in android

Posted by satyamurthy on Stack Overflow See other posts from Stack Overflow or by satyamurthy
Published on 2010-04-12T11:48:10Z Indexed on 2010/04/12 13:33 UTC
Read the original article Hit count: 377

Filed under:

hi all i am new in android i am implementing image retrieve in sdcard in image convert into bitmap and in bitmap convert in to byte array please forward some solution of this code

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ImageView image = (ImageView) findViewById(R.id.picview);
    EditText value=(EditText)findViewById(R.id.EditText01);
    FileInputStream in;
    BufferedInputStream buf;
    try {
        in = new FileInputStream("/sdcard/pictures/1.jpg");
        buf = new BufferedInputStream(in,1070);
        System.out.println("1.................."+buf);
        byte[] bMapArray= new byte[buf.available()];
        buf.read(bMapArray);
        Bitmap bMap = BitmapFactory.decodeByteArray(bMapArray, 0, bMapArray.length);
       for (int i = 0; i < bMapArray.length; i++) {
                System.out.print("bytearray"+bMapArray[i]);
            }
        image.setImageBitmap(bMap);
        value.setText(bMapArray.toString());
        if (in != null) {
         in.close();
        }
        if (buf != null) {
         buf.close();
        }

    } catch (Exception e) {
        Log.e("Error reading file", e.toString());
    }
}

}

solution is

04-12 16:41:16.168: INFO/System.out(728): 4......................[B@435a2908 this is the result for byte array not display total byte array this array size is 1034 please forward some solution

© Stack Overflow or respective owner

Related posts about android