how to bitmap convert in to byte array in android

All your problems with Audio, Video and Images.

how to bitmap convert in to byte array in android

Postby narasimharao » Sat Apr 10, 2010 10:29 am

hi sir
i am new in android i am strucking some issue
i am implementing image upload in sdcard image converting bitmap in bitmap convert in bytearray i am implementing this code

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import android.R.array;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

public class Photo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File f = new File("/sdcard/DCIM/1.jpg");
FileInputStream is = null;
try {
is = new FileInputStream(f);
Bitmap bm;
bm = BitmapFactory.decodeStream(is,null,null);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
bm.compress(Bitmap.CompressFormat.JPEG,75, baos);
System.out.println("3........................"+bm);
ImageView pic=(ImageView)this.findViewById(R.id.picview);
pic.setImageBitmap(bm);
}
catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
}
}this code is i am implementing how can convert bitmap in byte array
INFO/System.out(12658): 3........................android.graphics.Bitmap@4358e3d0
in debug this will be displayed how can retrieve bitmap to byte array
narasimharao
Junior Developer
Junior Developer
 
Posts: 11
Joined: Mon Apr 05, 2010 12:40 pm
Location: hyderabad

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests