本文整理汇总了Java中com.bumptech.glide.load.DecodeFormat.PREFER_RGB_565属性的典型用法代码示例。如果您正苦于以下问题:Java DecodeFormat.PREFER_RGB_565属性的具体用法?Java DecodeFormat.PREFER_RGB_565怎么用?Java DecodeFormat.PREFER_RGB_565使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.bumptech.glide.load.DecodeFormat
的用法示例。
在下文中一共展示了DecodeFormat.PREFER_RGB_565属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
private GifDrawableResource decode(
ByteBuffer byteBuffer, int width, int height, GifHeaderParser parser, Options options) {
long startTime = LogTime.getLogTime();
final GifHeader header = parser.parseHeader();
if (header.getNumFrames() <= 0 || header.getStatus() != GifDecoder.STATUS_OK) {
// If we couldn't decode the GIF, we will end up with a frame count of 0.
return null;
}
Bitmap.Config config = options.get(GifOptions.DECODE_FORMAT) == DecodeFormat.PREFER_RGB_565
? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;
int sampleSize = getSampleSize(header, width, height);
GifDecoder gifDecoder = gifDecoderFactory.build(provider, header, byteBuffer, sampleSize);
gifDecoder.setDefaultBitmapConfig(config);
gifDecoder.advance();
Bitmap firstFrame = gifDecoder.getNextFrame();
if (firstFrame == null) {
return null;
}
Transformation<Bitmap> unitTransformation = UnitTransformation.get();
GifDrawable gifDrawable =
new GifDrawable(context, gifDecoder, unitTransformation, width, height, firstFrame);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Decoded GIF from stream in " + LogTime.getElapsedMillis(startTime));
}
return new GifDrawableResource(gifDrawable);
}
示例2: applyOptions
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
SharedPreferencesManager manager = new SharedPreferencesManager(context);
final String cacheSize = manager.getString(DISK_CACHE_KEY, DISK_CACHE_160MB);
String decodeFormat = manager.getString(DECODE_FORMAT_KEY, DECODE_FORMAT_ARGB_8888);
final String cacheName = manager.getString(DISK_CACHE_NAME_KEY, DEFAULT_CACHE_NAME);
DecodeFormat format = null;
switch (decodeFormat) {
case DECODE_FORMAT_RGB_565:
format = DecodeFormat.PREFER_RGB_565;
break;
default:
case DECODE_FORMAT_ARGB_8888:
format = DecodeFormat.PREFER_ARGB_8888;
break;
}
builder.setDecodeFormat(format);
builder.setDiskCache(new DiskCache.Factory() {
@Override
public DiskCache build() {
int sizeInMB = 160;
switch (cacheSize) {
case DISK_CACHE_40MB:
sizeInMB = 40;
break;
case DISK_CACHE_80MB:
sizeInMB = 80;
break;
case DISK_CACHE_160MB:
sizeInMB = 160;
break;
case DISK_CACHE_320MB:
sizeInMB = 320;
break;
default:
case DISK_CACHE_640MB:
sizeInMB = 640;
break;
}
File path = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
path = context.getExternalCacheDirs()[(context.getExternalCacheDirs().length - 1)];
} else {
path = context.getExternalCacheDir();
}
File cacheLocation = new File(path, cacheName);
cacheLocation.mkdirs();
return DiskLruCacheWrapper.get(cacheLocation, sizeInMB * 1024 * 1024);
}
});
}
示例3: FileDescriptorBitmapDecoder
public FileDescriptorBitmapDecoder(BitmapPool bitmapPool) {
this(new VideoBitmapDecoder(), bitmapPool, DecodeFormat.PREFER_RGB_565);
}
示例4: StreamBitmapDecoder
public StreamBitmapDecoder(BitmapPool bitmapPool) {
this(Downsampler.AT_LEAST, bitmapPool, DecodeFormat.PREFER_RGB_565);
}