FileDocCategorySizeDatePackage
BitmapFactoryTest.javaAPI DocAndroid 5.1 API1803Thu Mar 12 22:22:30 GMT 2015android.graphics

BitmapFactoryTest

public class BitmapFactoryTest extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestBitmapParcelFileDescriptor()

        Bitmap bitmap1 = Bitmap.createBitmap(
                new int[] { Color.BLUE }, 1, 1, Bitmap.Config.RGB_565);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        bitmap1.compress(Bitmap.CompressFormat.PNG, 100, out);
        ParcelFileDescriptor pfd = ParcelFileDescriptor.fromData(out.toByteArray(), null);
        FileDescriptor fd = pfd.getFileDescriptor();
        assertNotNull("Got null FileDescriptor", fd);
        assertTrue("Got invalid FileDescriptor", fd.valid());
        Bitmap bitmap = BitmapFactory.decodeFileDescriptor(fd);
        assertNotNull("BitmapFactory returned null", bitmap);
        assertEquals("Bitmap width", 1, bitmap.getWidth());
        assertEquals("Bitmap height", 1, bitmap.getHeight());