Code example for ByteArrayOutputStream

Methods: closetoByteArray

0
            srcBitmap = Bitmap.createBitmap(srcBitmap, 0, 0,
                    srcBitmap.getWidth(), srcBitmap.getHeight(), matrix, true);
        } 
         
        String type = context.getContentResolver().getType(photoUri);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        if(type.equals("image/png")) {
        	srcBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
        } else if(type.equals("image/jpg") || type.equals("image/jpeg")) {
        	srcBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        } 
        byte[] bMapArray = baos.toByteArray();
		baos.close();
        return bMapArray;
    } 
     
    public static int getOrientation(Context context, Uri photoUri) {
            /* it's on the external media. */ 
            Cursor cursor = context.getContentResolver().query(photoUri,
                    new String[]{MediaStore.Images.ImageColumns.ORIENTATION},
Experience pair programming with AI  Get Codota for Java