本文整理匯總了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);
}