Search This Blog

Sunday, March 20, 2016

CHUYEN HINH THANH BYTE

public byte[] ImageView_To_Byte(ImageView imgvHinhSP){
 
        //Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.chomuc);
        BitmapDrawable drawable = (BitmapDrawable) imgvHinhSP.getDrawable();
        Bitmap bmp = drawable.getBitmap();
 
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
        byte[] byteArray = stream.toByteArray();
        return byteArray;
}

No comments:

Post a Comment