Search in sources :

Example 31 with Bitmap

use of android.graphics.Bitmap in project glide by bumptech.

the class GifDrawableTest method testDoesNotDrawFrameAfterRecycle.

@Test
public void testDoesNotDrawFrameAfterRecycle() {
    Bitmap bitmap = Bitmap.createBitmap(100, 112341, Bitmap.Config.RGB_565);
    drawable.setVisible(true, true);
    drawable.start();
    when(frameLoader.getCurrentFrame()).thenReturn(bitmap);
    drawable.onFrameReady();
    drawable.recycle();
    Canvas canvas = mock(Canvas.class);
    drawable.draw(canvas);
    verify(canvas, never()).drawBitmap(eq(bitmap), isARect(), isARect(), isAPaint());
}
Also used : Bitmap(android.graphics.Bitmap) BitmapTrackingShadowCanvas(com.bumptech.glide.load.resource.gif.GifDrawableTest.BitmapTrackingShadowCanvas) ShadowCanvas(org.robolectric.shadows.ShadowCanvas) Canvas(android.graphics.Canvas) Test(org.junit.Test)

Example 32 with Bitmap

use of android.graphics.Bitmap in project glide by bumptech.

the class DownsamplerTest method testAlwaysArgb8888.

@Test
public void testAlwaysArgb8888() throws IOException {
    Bitmap rgb565 = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
    InputStream stream = compressBitmap(rgb565, Bitmap.CompressFormat.JPEG);
    options.set(Downsampler.DECODE_FORMAT, DecodeFormat.PREFER_ARGB_8888);
    Resource<Bitmap> result = downsampler.decode(stream, 100, 100, options);
    assertEquals(Bitmap.Config.ARGB_8888, result.get().getConfig());
}
Also used : AllocationSizeBitmap(com.bumptech.glide.load.resource.bitmap.DownsamplerTest.AllocationSizeBitmap) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 33 with Bitmap

use of android.graphics.Bitmap in project glide by bumptech.

the class DownsamplerTest method testPreferRgb565.

@Test
public void testPreferRgb565() throws IOException {
    Bitmap rgb565 = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
    InputStream stream = compressBitmap(rgb565, Bitmap.CompressFormat.JPEG);
    options.set(Downsampler.DECODE_FORMAT, DecodeFormat.PREFER_RGB_565);
    Resource<Bitmap> result = downsampler.decode(stream, 100, 100, options);
    assertEquals(Bitmap.Config.RGB_565, result.get().getConfig());
}
Also used : AllocationSizeBitmap(com.bumptech.glide.load.resource.bitmap.DownsamplerTest.AllocationSizeBitmap) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 34 with Bitmap

use of android.graphics.Bitmap in project glide by bumptech.

the class FitCenterTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    bitmapWidth = 100;
    bitmapHeight = 100;
    Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
    when(resource.get()).thenReturn(bitmap);
    pool = new BitmapPoolAdapter();
    fitCenter = new FitCenter(pool);
}
Also used : Bitmap(android.graphics.Bitmap) BitmapPoolAdapter(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter) Before(org.junit.Before)

Example 35 with Bitmap

use of android.graphics.Bitmap in project glide by bumptech.

the class TransformationUtilsTest method testRotateImageExifReturnsGivenBitmapIfRotationIsUndefined.

@Test
public void testRotateImageExifReturnsGivenBitmapIfRotationIsUndefined() {
    Bitmap toRotate = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
    // Use assertTrue because Robolectric incorrectly implements equality for Bitmaps. We want
    // not just an identical Bitmap, but our original Bitmap object back.
    Bitmap rotated = TransformationUtils.rotateImageExif(bitmapPool, toRotate, ExifInterface.ORIENTATION_UNDEFINED);
    assertTrue(toRotate == rotated);
}
Also used : ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) Test(org.junit.Test)

Aggregations

Bitmap (android.graphics.Bitmap)3736 Canvas (android.graphics.Canvas)888 Paint (android.graphics.Paint)709 BitmapDrawable (android.graphics.drawable.BitmapDrawable)460 IOException (java.io.IOException)391 Rect (android.graphics.Rect)341 File (java.io.File)260 Test (org.junit.Test)255 Matrix (android.graphics.Matrix)254 Drawable (android.graphics.drawable.Drawable)243 BitmapFactory (android.graphics.BitmapFactory)239 View (android.view.View)224 ImageView (android.widget.ImageView)209 FileOutputStream (java.io.FileOutputStream)186 Intent (android.content.Intent)185 InputStream (java.io.InputStream)169 RectF (android.graphics.RectF)150 FileNotFoundException (java.io.FileNotFoundException)150 Point (android.graphics.Point)148 Uri (android.net.Uri)125