Created
December 2, 2011 12:51
-
-
Save jbeerdev/1423134 to your computer and use it in GitHub Desktop.
Store image in SDCard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static boolean StoreByteImage(Context mContext, byte[] imageData, | |
| int quality, String expName) { | |
| File sdImageMainDirectory = new File("/sdcard/myImages"); | |
| FileOutputStream fileOutputStream = null; | |
| String nameFile; | |
| try { | |
| BitmapFactory.Options options=new BitmapFactory.Options(); | |
| options.inSampleSize = 5; | |
| Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, | |
| imageData.length,options); | |
| fileOutputStream = new FileOutputStream( | |
| sdImageMainDirectory.toString() +"/" + nameFile + ".jpg"); | |
| BufferedOutputStream bos = new BufferedOutputStream( | |
| fileOutputStream); | |
| myImage.compress(CompressFormat.JPEG, quality, bos); | |
| bos.flush(); | |
| bos.close(); | |
| } catch (FileNotFoundException e) { | |
| // TODO Auto-generated catch block | |
| e.printStackTrace(); | |
| } catch (IOException e) { | |
| // TODO Auto-generated catch block | |
| e.printStackTrace(); | |
| } | |
| return true; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment