diff options
author | Ray Chen <raychen@google.com> | 2009-08-27 17:59:29 -0700 |
---|---|---|
committer | Ray Chen <raychen@google.com> | 2009-09-23 11:35:46 -0700 |
commit | 9f1480b2c27d744c816c71cb3c512d37bc48c524 (patch) | |
tree | 49fd63ada65ba117a259ec1659569596787df4a8 /src/com/android/camera/Util.java | |
parent | 723f84eadb3c1a79337ef20e4d0a014341537adb (diff) | |
download | LegacyCamera-9f1480b2c27d744c816c71cb3c512d37bc48c524.zip LegacyCamera-9f1480b2c27d744c816c71cb3c512d37bc48c524.tar.gz LegacyCamera-9f1480b2c27d744c816c71cb3c512d37bc48c524.tar.bz2 |
Change Camera & Gallery code to use the new thumbnail APIs.
Diffstat (limited to 'src/com/android/camera/Util.java')
-rw-r--r-- | src/com/android/camera/Util.java | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index a417e32..34deb3d 100644 --- a/src/com/android/camera/Util.java +++ b/src/com/android/camera/Util.java @@ -27,7 +27,6 @@ import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Rect; -import android.media.MediaMetadataRetriever; import android.net.Uri; import android.os.Handler; import android.os.ParcelFileDescriptor; @@ -39,7 +38,6 @@ import android.view.animation.TranslateAnimation; import com.android.camera.gallery.IImage; -import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.FileDescriptor; import java.io.IOException; @@ -240,83 +238,6 @@ public class Util { return b2; } - /** - * Creates a centered bitmap of the desired size. - * @param source - * @param recycle whether we want to recycle the input - */ - public static Bitmap extractMiniThumb( - Bitmap source, int width, int height, boolean recycle) { - if (source == null) { - return null; - } - - float scale; - if (source.getWidth() < source.getHeight()) { - scale = width / (float) source.getWidth(); - } else { - scale = height / (float) source.getHeight(); - } - Matrix matrix = new Matrix(); - matrix.setScale(scale, scale); - Bitmap miniThumbnail = transform(matrix, source, width, height, - true, recycle); - return miniThumbnail; - } - - /** - * Creates a byte[] for a given bitmap of the desired size. Recycles the - * input bitmap. - */ - public static byte[] miniThumbData(Bitmap source) { - if (source == null) return null; - - Bitmap miniThumbnail = extractMiniThumb( - source, IImage.MINI_THUMB_TARGET_SIZE, - IImage.MINI_THUMB_TARGET_SIZE, - Util.RECYCLE_INPUT); - - ByteArrayOutputStream miniOutStream = new ByteArrayOutputStream(); - miniThumbnail.compress(Bitmap.CompressFormat.JPEG, 75, miniOutStream); - miniThumbnail.recycle(); - - try { - miniOutStream.close(); - byte [] data = miniOutStream.toByteArray(); - return data; - } catch (java.io.IOException ex) { - Log.e(TAG, "got exception ex " + ex); - } - return null; - } - - /** - * Create a video thumbnail for a video. May return null if the video is - * corrupt. - * - * @param filePath - */ - public static Bitmap createVideoThumbnail(String filePath) { - Bitmap bitmap = null; - MediaMetadataRetriever retriever = new MediaMetadataRetriever(); - try { - retriever.setMode(MediaMetadataRetriever.MODE_CAPTURE_FRAME_ONLY); - retriever.setDataSource(filePath); - bitmap = retriever.captureFrame(); - } catch (IllegalArgumentException ex) { - // Assume this is a corrupt video file - } catch (RuntimeException ex) { - // Assume this is a corrupt video file. - } finally { - try { - retriever.release(); - } catch (RuntimeException ex) { - // Ignore failures while cleaning up. - } - } - return bitmap; - } - public static <T> int indexOf(T [] array, T s) { for (int i = 0; i < array.length; i++) { if (array[i].equals(s)) { @@ -350,12 +271,6 @@ public class Util { * @param uri */ public static Bitmap makeBitmap(int minSideLength, int maxNumOfPixels, - Uri uri, ContentResolver cr) { - return makeBitmap(minSideLength, maxNumOfPixels, uri, cr, - IImage.NO_NATIVE); - } - - public static Bitmap makeBitmap(int minSideLength, int maxNumOfPixels, Uri uri, ContentResolver cr, boolean useNative) { ParcelFileDescriptor input = null; try { |