Search in sources :

Example 1 with DefaultImageHeaderParser

use of com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser in project glide by bumptech.

the class ExifTest method testIssue387.

@Test
public void testIssue387() throws IOException {
    InputStream is = TestResourceUtil.openResource(getClass(), "issue387_rotated_jpeg.jpg");
    assertThat(new DefaultImageHeaderParser().getOrientation(is, byteArrayPool)).isEqualTo(6);
}
Also used : DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 2 with DefaultImageHeaderParser

use of com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser in project glide by bumptech.

the class ByteBufferGifDecoderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    gifHeader = Mockito.spy(new GifHeader());
    when(parser.parseHeader()).thenReturn(gifHeader);
    when(parserPool.obtain(isA(ByteBuffer.class))).thenReturn(parser);
    when(decoderFactory.build(isA(GifDecoder.BitmapProvider.class), eq(gifHeader), isA(ByteBuffer.class), anyInt())).thenReturn(gifDecoder);
    List<ImageHeaderParser> parsers = new ArrayList<ImageHeaderParser>();
    parsers.add(new DefaultImageHeaderParser());
    options = new Options();
    decoder = new ByteBufferGifDecoder(RuntimeEnvironment.application, parsers, bitmapPool, new LruArrayPool(ARRAY_POOL_SIZE_BYTES), parserPool, decoderFactory);
}
Also used : Options(com.bumptech.glide.load.Options) LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) ArrayList(java.util.ArrayList) GifHeader(com.bumptech.glide.gifdecoder.GifHeader) ByteBuffer(java.nio.ByteBuffer) DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) ImageHeaderParser(com.bumptech.glide.load.ImageHeaderParser) Before(org.junit.Before)

Example 3 with DefaultImageHeaderParser

use of com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser in project glide by bumptech.

the class ExifOrientationStreamTest method testIncludesGivenExifOrientation.

@Test
public void testIncludesGivenExifOrientation() throws IOException {
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            InputStream toWrap = openOrientationExample(true, /*isLandscape*/
            j + 1);
            InputStream wrapped = new ExifOrientationStream(toWrap, i);
            DefaultImageHeaderParser parser = new DefaultImageHeaderParser();
            assertThat(parser.getOrientation(wrapped, byteArrayPool)).isEqualTo(i);
            toWrap = openOrientationExample(false, /*isLandscape*/
            j + 1);
            wrapped = new ExifOrientationStream(toWrap, i);
            assertThat(parser.getOrientation(wrapped, byteArrayPool)).isEqualTo(i);
        }
    }
}
Also used : DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 4 with DefaultImageHeaderParser

use of com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser in project glide by bumptech.

the class ExifTest method assertOrientation.

private void assertOrientation(String filePrefix, int expectedOrientation) {
    InputStream is = null;
    try {
        is = open(filePrefix + "_" + expectedOrientation + ".jpg");
        assertEquals(new DefaultImageHeaderParser().getOrientation(is, byteArrayPool), expectedOrientation);
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            // Do nothing.
            }
        }
    }
}
Also used : DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 5 with DefaultImageHeaderParser

use of com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser in project glide by bumptech.

the class StreamGifDecoderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    List<ImageHeaderParser> parsers = new ArrayList<ImageHeaderParser>();
    parsers.add(new DefaultImageHeaderParser());
    decoder = new StreamGifDecoder(parsers, byteBufferDecoder, new LruArrayPool());
    options = new Options();
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) Options(com.bumptech.glide.load.Options) DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) ArrayList(java.util.ArrayList) DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) ImageHeaderParser(com.bumptech.glide.load.ImageHeaderParser) Before(org.junit.Before)

Aggregations

DefaultImageHeaderParser (com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser)5 InputStream (java.io.InputStream)3 ImageHeaderParser (com.bumptech.glide.load.ImageHeaderParser)2 Options (com.bumptech.glide.load.Options)2 LruArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 Test (org.junit.Test)2 GifHeader (com.bumptech.glide.gifdecoder.GifHeader)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1