This repository has been archived by the owner on Oct 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flesh out new put and get methods. Still needs work
- Loading branch information
Chris Banes
committed
Dec 16, 2012
1 parent
a5c4475
commit 683b32d
Showing
2 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package uk.co.senab.bitmapcache; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.Bitmap.CompressFormat; | ||
|
||
public class Util { | ||
|
||
/** | ||
* Pipe an InputStream to the given OutputStream | ||
* | ||
* @param in | ||
* @param out | ||
* @throws IOException | ||
*/ | ||
// TODO Can probably be optimized | ||
public static void pipe(InputStream in, OutputStream out) throws IOException { | ||
byte[] buffer = new byte[1024]; | ||
int len = in.read(buffer); | ||
while (len != -1) { | ||
out.write(buffer, 0, len); | ||
len = in.read(buffer); | ||
} | ||
} | ||
|
||
public static void saveBitmap(Bitmap bitmap, OutputStream out) { | ||
bitmap.compress(CompressFormat.PNG, 100, out); | ||
} | ||
|
||
} |