Search in sources :

Example 6 with BitmapFactory

use of android.graphics.BitmapFactory in project android_frameworks_base by AOSPA.

the class CodecTest method getThumbnail.

//Test for mediaMeta Data Thumbnail
public static boolean getThumbnail(String filePath, String goldenPath) {
    Log.v(TAG, "getThumbnail - " + filePath);
    int goldenHeight = 0;
    int goldenWidth = 0;
    int outputWidth = 0;
    int outputHeight = 0;
    //This test is only for the short media file
    try {
        BitmapFactory mBitmapFactory = new BitmapFactory();
        MediaMetadataRetriever mMediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            mMediaMetadataRetriever.setDataSource(filePath);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        Bitmap outThumbnail = mMediaMetadataRetriever.getFrameAtTime(-1);
        //Verify the thumbnail
        Bitmap goldenBitmap = mBitmapFactory.decodeFile(goldenPath);
        outputWidth = outThumbnail.getWidth();
        outputHeight = outThumbnail.getHeight();
        goldenHeight = goldenBitmap.getHeight();
        goldenWidth = goldenBitmap.getWidth();
        //check the image dimension
        if ((outputWidth != goldenWidth) || (outputHeight != goldenHeight))
            return false;
        // Check half line of pixel
        int x = goldenHeight / 2;
        for (int j = 1; j < goldenWidth / 2; j++) {
            if (goldenBitmap.getPixel(x, j) != outThumbnail.getPixel(x, j)) {
                Log.v(TAG, "pixel = " + goldenBitmap.getPixel(x, j));
                return false;
            }
        }
    } catch (Exception e) {
        Log.v(TAG, e.toString());
        return false;
    }
    return true;
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) BitmapFactory(android.graphics.BitmapFactory) IOException(java.io.IOException)

Example 7 with BitmapFactory

use of android.graphics.BitmapFactory in project android_frameworks_base by ResurrectionRemix.

the class CodecTest method getThumbnail.

//Test for mediaMeta Data Thumbnail
public static boolean getThumbnail(String filePath, String goldenPath) {
    Log.v(TAG, "getThumbnail - " + filePath);
    int goldenHeight = 0;
    int goldenWidth = 0;
    int outputWidth = 0;
    int outputHeight = 0;
    //This test is only for the short media file
    try {
        BitmapFactory mBitmapFactory = new BitmapFactory();
        MediaMetadataRetriever mMediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            mMediaMetadataRetriever.setDataSource(filePath);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        Bitmap outThumbnail = mMediaMetadataRetriever.getFrameAtTime(-1);
        //Verify the thumbnail
        Bitmap goldenBitmap = mBitmapFactory.decodeFile(goldenPath);
        outputWidth = outThumbnail.getWidth();
        outputHeight = outThumbnail.getHeight();
        goldenHeight = goldenBitmap.getHeight();
        goldenWidth = goldenBitmap.getWidth();
        //check the image dimension
        if ((outputWidth != goldenWidth) || (outputHeight != goldenHeight))
            return false;
        // Check half line of pixel
        int x = goldenHeight / 2;
        for (int j = 1; j < goldenWidth / 2; j++) {
            if (goldenBitmap.getPixel(x, j) != outThumbnail.getPixel(x, j)) {
                Log.v(TAG, "pixel = " + goldenBitmap.getPixel(x, j));
                return false;
            }
        }
    } catch (Exception e) {
        Log.v(TAG, e.toString());
        return false;
    }
    return true;
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) BitmapFactory(android.graphics.BitmapFactory) IOException(java.io.IOException)

Example 8 with BitmapFactory

use of android.graphics.BitmapFactory in project android_frameworks_base by crdroidandroid.

the class CodecTest method getThumbnail.

//Test for mediaMeta Data Thumbnail
public static boolean getThumbnail(String filePath, String goldenPath) {
    Log.v(TAG, "getThumbnail - " + filePath);
    int goldenHeight = 0;
    int goldenWidth = 0;
    int outputWidth = 0;
    int outputHeight = 0;
    //This test is only for the short media file
    try {
        BitmapFactory mBitmapFactory = new BitmapFactory();
        MediaMetadataRetriever mMediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            mMediaMetadataRetriever.setDataSource(filePath);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        Bitmap outThumbnail = mMediaMetadataRetriever.getFrameAtTime(-1);
        //Verify the thumbnail
        Bitmap goldenBitmap = mBitmapFactory.decodeFile(goldenPath);
        outputWidth = outThumbnail.getWidth();
        outputHeight = outThumbnail.getHeight();
        goldenHeight = goldenBitmap.getHeight();
        goldenWidth = goldenBitmap.getWidth();
        //check the image dimension
        if ((outputWidth != goldenWidth) || (outputHeight != goldenHeight))
            return false;
        // Check half line of pixel
        int x = goldenHeight / 2;
        for (int j = 1; j < goldenWidth / 2; j++) {
            if (goldenBitmap.getPixel(x, j) != outThumbnail.getPixel(x, j)) {
                Log.v(TAG, "pixel = " + goldenBitmap.getPixel(x, j));
                return false;
            }
        }
    } catch (Exception e) {
        Log.v(TAG, e.toString());
        return false;
    }
    return true;
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) BitmapFactory(android.graphics.BitmapFactory) IOException(java.io.IOException)

Aggregations

BitmapFactory (android.graphics.BitmapFactory)8 Bitmap (android.graphics.Bitmap)7 MediaMetadataRetriever (android.media.MediaMetadataRetriever)6 IOException (java.io.IOException)6 SuppressLint (android.annotation.SuppressLint)1 Matrix (android.graphics.Matrix)1 Paint (android.graphics.Paint)1 BufferedInputStream (java.io.BufferedInputStream)1