Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a bitmap to a jpeg file in Android? [closed]

Tags:

I have a cropped bitmap image and I need to save it into a jpeg file.

Thanks in advance

like image 989
Carlo Matulessy Avatar asked Dec 02 '13 13:12

Carlo Matulessy


People also ask

Can object be converted into bitmap?

Converting a vector graphic or object to a bitmap lets you apply special effects to the object with CorelDRAW. The process of converting a vector graphic to a bitmap is also known as “rasterizing.” When you convert the vector graphic, you can select the color mode of the bitmap.


1 Answers

Use this:

Bitmap bmp = null; ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArray = stream.toByteArray(); 

for that you can use this:

FileInputStream fileInputStream = null;  File file = new File("yourfile");  byteArray = new byte[(int) file.length()];  try {     //convert file into array of bytes     fileInputStream = new FileInputStream(file);     fileInputStream.read(bFile);     fileInputStream.close();      //convert array of bytes into file     FileOutputStream fileOuputStream =             new FileOutputStream("C:\\testing2.txt");     fileOuputStream.write(bFile);     fileOuputStream.close();      System.out.println("Done"); } catch (Exception e) {     e.printStackTrace(); } 

and also for more info go with here

like image 175
Piyush Avatar answered Nov 02 '22 03:11

Piyush