Search in sources :

Example 16 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class BaseRequestOptions method clone.

/**
   * Returns a copy of this request builder with all of the options put so far on this builder.
   *
   * <p> This method returns a "deep" copy in that all non-immutable arguments are copied such that
   * changes to one builder will not affect the other builder. However, in addition to immutable
   * arguments, the current model is not copied copied so changes to the model will affect both
   * builders. </p>
   *
   * <p> Even if this object was locked, the cloned object returned from this method will not be
   * locked. </p>
   */
@SuppressWarnings("unchecked")
@Override
public final CHILD clone() {
    try {
        BaseRequestOptions<CHILD> result = (BaseRequestOptions<CHILD>) super.clone();
        result.options = new Options();
        result.options.putAll(options);
        result.transformations = new HashMap<>();
        result.transformations.putAll(transformations);
        result.isLocked = false;
        result.isAutoCloneEnabled = false;
        return (CHILD) result;
    } catch (CloneNotSupportedException e) {
        throw new RuntimeException(e);
    }
}
Also used : Options(com.bumptech.glide.load.Options)

Example 17 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class DownsamplerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    options = new Options();
    DisplayMetrics displayMetrics = RuntimeEnvironment.application.getResources().getDisplayMetrics();
    when(byteArrayPool.get(anyInt(), Matchers.eq(byte[].class))).thenReturn(new byte[ArrayPool.STANDARD_BUFFER_SIZE_BYTES]);
    List<ImageHeaderParser> parsers = new ArrayList<ImageHeaderParser>();
    parsers.add(new DefaultImageHeaderParser());
    downsampler = new Downsampler(parsers, displayMetrics, bitmapPool, byteArrayPool);
    initialSdkVersion = Build.VERSION.SDK_INT;
}
Also used : Options(com.bumptech.glide.load.Options) ArrayList(java.util.ArrayList) DisplayMetrics(android.util.DisplayMetrics) ImageHeaderParser(com.bumptech.glide.load.ImageHeaderParser) Before(org.junit.Before)

Example 18 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class VideoBitmapDecoderTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    when(factory.build()).thenReturn(retriever);
    decoder = new VideoBitmapDecoder(bitmapPool, factory);
    options = new Options();
}
Also used : Options(com.bumptech.glide.load.Options) Before(org.junit.Before)

Example 19 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class EngineKeyTest method testDiffersIfOptionsDiffer.

@Test
public void testDiffersIfOptionsDiffer() throws NoSuchAlgorithmException {
    EngineKey first = harness.build();
    harness.options = new Options();
    harness.options.set(Option.memory("fakeKey"), "someValue");
    EngineKey second = harness.build();
    KeyAssertions.assertDifferent(first, second, false);
}
Also used : Options(com.bumptech.glide.load.Options) Test(org.junit.Test)

Example 20 with Options

use of com.bumptech.glide.load.Options in project Rocket by mozilla-tw.

the class RegionFileDecoder method decode.

@Override
public Resource<Bitmap> decode(InputStream source, int width, int height, Options options) throws IOException {
    int imageWidth = defaultWidth;
    if (source.markSupported()) {
        BitmapFactory.Options optionSize = new BitmapFactory.Options();
        optionSize.inJustDecodeBounds = true;
        source.mark(source.available());
        BitmapFactory.decodeStream(source, new Rect(), optionSize);
        source.reset();
        imageWidth = optionSize.outWidth;
    }
    BitmapRegionDecoder decoder = createDecoder(source, width, height);
    BitmapFactory.Options opts = new BitmapFactory.Options();
    // Algorithm from Glide's Downsampler.getRoundedSampleSize
    int sampleSize = (int) Math.ceil((double) imageWidth / (double) width);
    sampleSize = sampleSize == 0 ? 0 : Integer.highestOneBit(sampleSize);
    sampleSize = Math.max(1, sampleSize);
    opts.inSampleSize = sampleSize;
    // Although functionally equivalent to 0 for BitmapFactory, 1 is a safer default for our code than 0.
    Bitmap bitmap = decoder.decodeRegion(new Rect(0, 0, imageWidth, imageWidth), opts);
    return BitmapResource.obtain(bitmap, bitmapPool);
}
Also used : Options(com.bumptech.glide.load.Options) Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) BitmapRegionDecoder(android.graphics.BitmapRegionDecoder) BitmapFactory(android.graphics.BitmapFactory)

Aggregations

Options (com.bumptech.glide.load.Options)33 Before (org.junit.Before)14 Test (org.junit.Test)10 Bitmap (android.graphics.Bitmap)4 Uri (android.net.Uri)3 NonNull (android.support.annotation.NonNull)3 ImageHeaderParser (com.bumptech.glide.load.ImageHeaderParser)3 ObjectKey (com.bumptech.glide.signature.ObjectKey)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 CheckResult (android.support.annotation.CheckResult)2 CacheKeyUpdater (com.bumptech.glide.load.Option.CacheKeyUpdater)2 LruArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool)2 DefaultImageHeaderParser (com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser)2 ByteBuffer (java.nio.ByteBuffer)2 MessageDigest (java.security.MessageDigest)2 Application (android.app.Application)1 AssetManager (android.content.res.AssetManager)1 BitmapFactory (android.graphics.BitmapFactory)1