Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-8708] Android: Loading a large list of contacts w/ photos is slow #3557

Merged
merged 5 commits into from
Dec 14, 2012
14 changes: 11 additions & 3 deletions android/titanium/src/java/org/appcelerator/titanium/TiBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static TiBlob blobFromFile(TiBaseFile file, String mimeType)
blob.loadBitmapInfo();
return blob;
}

/**
* Creates a blob from a bitmap.
* @param image the image used to create blob.
Expand All @@ -133,10 +133,18 @@ public static TiBlob blobFromFile(TiBaseFile file, String mimeType)
*/
public static TiBlob blobFromImage(Bitmap image)
{

ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte data[] = new byte[0];
if (image.compress(CompressFormat.PNG, 100, bos)) {
data = bos.toByteArray();
if (image.hasAlpha()) {
if (image.compress(CompressFormat.PNG, 100, bos)) {
data = bos.toByteArray();
}
}
else {
if (image.compress(CompressFormat.JPEG, 100, bos)) {
data = bos.toByteArray();
}
}

TiBlob blob = new TiBlob(TYPE_IMAGE, data, "image/bitmap");
Expand Down