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);
}
}
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;
}
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();
}
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);
}
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);
}
Aggregations