android - Unable to convert bitmap image into byte[] -


I want to convert my captured image to byte [] When I capture the image using the camera It is captured and preview is also shown and images successfully save successfully on my external storage. But when I try to change my preview image it does not store anything in the byte array. The following is my method which is called the preview image button on my phone.

  public static zoom previewed image () {try {Static ByteArrayOutputStream stream = null} imgPreview.setVisibility (View.VISIBLE); Bitmapfactor Option option = new bitmapfile the option (); Options.inSampleSize = 8; Last bitmap bitmap = bitmapfile Decodefile (fileUri.getPath (), option); ImgPreview.setImageBitmap (bitmap); Stream = new byteOutStream (); Bitmap.compress (CompressFormat.JPEG, 100, Stream); Byte [] Biteire = Stream. To Batere (); } Hold (NullPointerException e) {e.printStackTrace (); }}  

Convert image to string & amp; Byte array, use less than code.


  Bytereutputstream baoos = new byteOnputstream (); Yourbitmap.compress (Bitmap Compress Format.JPEG, 100, Baos); // This will convert the image into byte [] byte [] Bitearrease = Baos Bytere (); // it convert byte [] string string encoded image = base 64. encodeToString (byteArrayImage, Base64.DEFAULT);  

Comments

Popular posts from this blog

c# - XML serialize base class without knowing derived class -

c# - UnhandledExceptionMode.ThrowException for AppDomain.UnhandledException -

udp - The relationship between MTU and size of skb in xmit function -