com.nostra13.universalimageloader.core.decode.ImageDecodingInfo Java Examples
The following examples show how to use
com.nostra13.universalimageloader.core.decode.ImageDecodingInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadAndDisplayImageTask.java From letv with Apache License 2.0 | 6 votes |
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { File targetFile = this.configuration.diskCache.get(this.uri); if (targetFile == null || !targetFile.exists()) { return false; } Bitmap bmp = this.decoder.decode(new ImageDecodingInfo(this.memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), this.uri, new ImageSize(maxWidth, maxHeight), ViewScaleType.FIT_INSIDE, getDownloader(), new Builder().cloneFrom(this.options).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build())); if (!(bmp == null || this.configuration.processorForDiskCache == null)) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, this.memoryCacheKey); bmp = this.configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, this.memoryCacheKey); } } if (bmp == null) { return false; } boolean saved = this.configuration.diskCache.save(this.uri, bmp); bmp.recycle(); return saved; }
Example #2
Source File: VideoRow.java From talk-android with MIT License | 6 votes |
Bitmap tryLoadBitmap(ImageViewAware imageAware) { Bitmap bitmap = null; try { java.io.File imageFile = diskCache.get(getMessage().get_id()); if (imageFile != null && imageFile.exists() && imageFile.length() > 0) { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageSize imageSize = ImageSizeUtils.defineTargetSizeForView(imageAware, new ImageSize(MainApp.CONTEXT.getResources().getDisplayMetrics().widthPixels, MainApp.CONTEXT.getResources().getDisplayMetrics().heightPixels)); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(getMessage().get_id(), ImageDownloader.Scheme.FILE.wrap(imageFile.getAbsolutePath()), getMessage().get_id(), imageSize, viewScaleType, new BaseImageDownloader(MainApp.CONTEXT), options); bitmap = decoder.decode(decodingInfo); MainApp.memoryCache.put(getMessage().get_id(), bitmap); } } catch (Exception ignored) { ignored.printStackTrace(); } return bitmap; }
Example #3
Source File: DiskDecoder.java From talk-android with MIT License | 6 votes |
protected BitmapFactory.Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) { ImageScaleType scaleType = decodingInfo.getImageScaleType(); int scale; if (scaleType == ImageScaleType.NONE) { scale = 1; } else if (scaleType == ImageScaleType.NONE_SAFE) { scale = ImageSizeUtils.computeMinImageSampleSize(imageSize); } else { ImageSize targetSize = decodingInfo.getTargetSize(); boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2; scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2); } if (scale > 1 && loggingEnabled) { L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey()); } BitmapFactory.Options decodingOptions = decodingInfo.getDecodingOptions(); decodingOptions.inSampleSize = scale; return decodingOptions; }
Example #4
Source File: LoadAndDisplayImageTask.java From mobile-manager-tool with MIT License | 5 votes |
/** Decodes image file into Bitmap, resize it and save it back */ private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { // Decode image file, compress and re-save it boolean saved = false; File targetFile = configuration.diskCache.get(uri); if (targetFile != null && targetFile.exists()) { ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight); DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions); Bitmap bmp = decoder.decode(decodingInfo); if (bmp != null && configuration.processorForDiskCache != null) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey); bmp = configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey); } } if (bmp != null) { saved = configuration.diskCache.save(uri, bmp); bmp.recycle(); } } return saved; }
Example #5
Source File: LoadAndDisplayImageTask.java From android-open-project-demo with Apache License 2.0 | 5 votes |
/** Decodes image file into Bitmap, resize it and save it back */ private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { // Decode image file, compress and re-save it boolean saved = false; File targetFile = configuration.diskCache.get(uri); if (targetFile != null && targetFile.exists()) { ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight); DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions); Bitmap bmp = decoder.decode(decodingInfo); if (bmp != null && configuration.processorForDiskCache != null) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey); bmp = configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey); } } if (bmp != null) { saved = configuration.diskCache.save(uri, bmp); bmp.recycle(); } } return saved; }
Example #6
Source File: ImageLoaderUtils.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public Bitmap decode(ImageDecodingInfo info) throws IOException { if (TextUtils.isEmpty(info.getImageKey())) { return null; } String cleanedUriString = cleanUriString(info.getImageKey()); if (isVideoUri(cleanedUriString)) { return makeVideoThumbnail(info.getTargetSize().getWidth(), info.getTargetSize().getHeight(), cleanedUriString); } else { return imageUriDecoder.decode(info); } }
Example #7
Source File: LoadAndDisplayImageTask.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 5 votes |
/** * Decodes image file into Bitmap, resize it and save it back * 解码图片 进行图片尺寸修改,然后保存 */ private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { // Decode image file, compress and re-save it boolean saved = false; File targetFile = configuration.diskCache.get(uri); if (targetFile != null && targetFile.exists()) { //构建图片尺寸size对象 ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight); //图片显示配置参数构建 DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions); //获取解码之后的图片 Bitmap bmp = decoder.decode(decodingInfo); if (bmp != null && configuration.processorForDiskCache != null) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey); bmp = configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey); } } if (bmp != null) { //图片重新保存本地文件系统 saved = configuration.diskCache.save(uri, bmp); bmp.recycle(); } } return saved; }
Example #8
Source File: LoadAndDisplayImageTask.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 5 votes |
/** * 根据图片资源地址进行解码图片 * @param imageUri 图片资源地址 * @return * @throws IOException */ private Bitmap decodeImage(String imageUri) throws IOException { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options); return decoder.decode(decodingInfo); }
Example #9
Source File: l.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private boolean a(int i1, int j1) { File file = C.o.get(a); if (file != null && file.exists()) { ImageSize imagesize = new ImageSize(i1, j1); DisplayImageOptions displayimageoptions = (new DisplayImageOptions.Builder()).cloneFrom(c).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo imagedecodinginfo = new ImageDecodingInfo(H, com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme.FILE.wrap(file.getAbsolutePath()), a, imagesize, ViewScaleType.FIT_INSIDE, h(), displayimageoptions); Bitmap bitmap = G.decode(imagedecodinginfo); if (bitmap != null && C.f != null) { Object aobj[] = new Object[1]; aobj[0] = H; L.d("Process image before cache on disk [%s]", aobj); bitmap = C.f.process(bitmap); if (bitmap == null) { Object aobj1[] = new Object[1]; aobj1[0] = H; L.e("Bitmap processor for disk cache returned null [%s]", aobj1); } } Bitmap bitmap1 = bitmap; if (bitmap1 != null) { boolean flag = C.o.save(a, bitmap1); bitmap1.recycle(); return flag; } } return false; }
Example #10
Source File: LoadAndDisplayImageTask.java From WliveTV with Apache License 2.0 | 5 votes |
/** Decodes image file into Bitmap, resize it and save it back */ private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { // Decode image file, compress and re-save it boolean saved = false; File targetFile = configuration.diskCache.get(uri); if (targetFile != null && targetFile.exists()) { ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight); DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions); Bitmap bmp = decoder.decode(decodingInfo); if (bmp != null && configuration.processorForDiskCache != null) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey); bmp = configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey); } } if (bmp != null) { saved = configuration.diskCache.save(uri, bmp); bmp.recycle(); } } return saved; }
Example #11
Source File: LoadAndDisplayImageTask.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
/** Decodes image file into Bitmap, resize it and save it back */ private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { // Decode image file, compress and re-save it boolean saved = false; File targetFile = configuration.diskCache.get(uri); if (targetFile != null && targetFile.exists()) { ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight); DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions); Bitmap bmp = decoder.decode(decodingInfo); if (bmp != null && configuration.processorForDiskCache != null) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey); bmp = configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey); } } if (bmp != null) { saved = configuration.diskCache.save(uri, bmp); bmp.recycle(); } } return saved; }
Example #12
Source File: DiskDecoder.java From talk-android with MIT License | 5 votes |
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo, int rotation, boolean flipHorizontal) { Matrix m = new Matrix(); // Scale to exact size if need ImageScaleType scaleType = decodingInfo.getImageScaleType(); if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) { ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation); float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo .getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED); if (Float.compare(scale, 1f) != 0) { m.setScale(scale, scale); if (loggingEnabled) { L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey()); } } } // Flip bitmap if need if (flipHorizontal) { m.postScale(-1, 1); if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey()); } // Rotate bitmap if need if (rotation != 0) { m.postRotate(rotation); if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey()); } Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap .getHeight(), m, true); if (finalBitmap != subsampledBitmap) { subsampledBitmap.recycle(); } return finalBitmap; }
Example #13
Source File: DiskDecoder.java From talk-android with MIT License | 5 votes |
protected InputStream resetStream(InputStream imageStream, ImageDecodingInfo decodingInfo) throws IOException { try { imageStream.reset(); } catch (IOException e) { IoUtils.closeSilently(imageStream); imageStream = getImageStream(decodingInfo); } return imageStream; }
Example #14
Source File: DiskDecoder.java From talk-android with MIT License | 5 votes |
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo) throws IOException { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(imageStream, null, options); ExifInfo exif; String imageUri = decodingInfo.getImageUri(); if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) { exif = defineExifOrientation(imageUri); } else { exif = new ExifInfo(); } return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif); }
Example #15
Source File: DiskDecoder.java From talk-android with MIT License | 5 votes |
/** * Decodes image from URI into {@link Bitmap}. Image is scaled close to incoming {@linkplain ImageSize target size} * during decoding (depend on incoming parameters). * * @param decodingInfo Needed data for decoding image * @return Decoded bitmap * @throws IOException if some I/O exception occurs during image reading * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol) */ @Override public Bitmap decode(ImageDecodingInfo decodingInfo) throws IOException { Bitmap decodedBitmap; ImageFileInfo imageInfo; InputStream imageStream = getImageStream(decodingInfo); if (imageStream == null) { L.e(ERROR_NO_IMAGE_STREAM, decodingInfo.getImageKey()); return null; } try { imageInfo = defineImageSizeAndRotation(imageStream, decodingInfo); imageStream = resetStream(imageStream, decodingInfo); BitmapFactory.Options decodingOptions = prepareDecodingOptions(imageInfo.imageSize, decodingInfo); decodedBitmap = BitmapFactory.decodeStream(imageStream, null, decodingOptions); } finally { IoUtils.closeSilently(imageStream); } if (decodedBitmap == null) { L.e(ERROR_CANT_DECODE_IMAGE, decodingInfo.getImageKey()); } else { decodedBitmap = considerExactScaleAndOrientatiton(decodedBitmap, decodingInfo, imageInfo.exif.rotation, imageInfo.exif.flipHorizontal); } return decodedBitmap; }
Example #16
Source File: ThumbnailDecoder.java From talk-android with MIT License | 5 votes |
@Override public Bitmap decode(ImageDecodingInfo imageDecodingInfo) throws IOException { if (isThumbnailUri(Uri.parse(imageDecodingInfo.getOriginalImageUri()))) { String originUrl = imageDecodingInfo.getOriginalImageUri(); String strId = originUrl.substring(16, originUrl.length()); long imageId = Long.parseLong(strId); Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail( contentResolver, imageId, MediaStore.Images.Thumbnails.MINI_KIND, null); // check the orientation of image int rotation = 0; Cursor mediaCursor = contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{"orientation"}, "_ID=" + imageId, null, null); if (mediaCursor != null && mediaCursor.getCount() != 0) { while (mediaCursor.moveToNext()) { rotation = mediaCursor.getInt(0); break; } } if (mediaCursor != null && !mediaCursor.isClosed()) { try { mediaCursor.close(); } catch (Exception e) { } } if (rotation != 0) { return rotateImage(bitmap, rotation); } return bitmap; } else { return baseImageDecoder.decode(imageDecodingInfo); } }
Example #17
Source File: LoadAndDisplayImageTask.java From candybar with Apache License 2.0 | 5 votes |
/** * Decodes image file into Bitmap, resize it and save it back */ private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException { // Decode image file, compress and re-save it boolean saved = false; File targetFile = configuration.diskCache.get(uri); if (targetFile != null && targetFile.exists()) { ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight); DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions); Bitmap bmp = decoder.decode(decodingInfo); if (bmp != null && configuration.processorForDiskCache != null) { L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey); bmp = configuration.processorForDiskCache.process(bmp); if (bmp == null) { L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey); } } if (bmp != null) { saved = configuration.diskCache.save(uri, bmp); bmp.recycle(); } } return saved; }
Example #18
Source File: LoadAndDisplayImageTask.java From mobile-manager-tool with MIT License | 4 votes |
private Bitmap decodeImage(String imageUri) throws IOException { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options); return decoder.decode(decodingInfo); }
Example #19
Source File: LoadAndDisplayImageTask.java From candybar with Apache License 2.0 | 4 votes |
private Bitmap decodeImage(String imageUri) throws IOException { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options); return decoder.decode(decodingInfo); }
Example #20
Source File: LoadAndDisplayImageTask.java From BigApp_WordPress_Android with Apache License 2.0 | 4 votes |
private Bitmap decodeImage(String imageUri) throws IOException { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options); return decoder.decode(decodingInfo); }
Example #21
Source File: LoadAndDisplayImageTask.java From WliveTV with Apache License 2.0 | 4 votes |
private Bitmap decodeImage(String imageUri) throws IOException { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options); return decoder.decode(decodingInfo); }
Example #22
Source File: l.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
private Bitmap a(String s1) { ViewScaleType viewscaletype = b.getScaleType(); ImageDecodingInfo imagedecodinginfo = new ImageDecodingInfo(H, s1, a, I, viewscaletype, h(), c); return G.decode(imagedecodinginfo); }
Example #23
Source File: DiskDecoder.java From talk-android with MIT License | 4 votes |
protected InputStream getImageStream(ImageDecodingInfo decodingInfo) throws IOException { return decodingInfo.getDownloader().getStream(decodingInfo.getImageUri(), decodingInfo.getExtraForDownloader()); }
Example #24
Source File: BrokenJpegImageDecoder.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 4 votes |
@Override protected InputStream getImageStream(ImageDecodingInfo decodingInfo) throws IOException { InputStream stream = decodingInfo.getDownloader() .getStream(decodingInfo.getImageUri(), decodingInfo.getExtraForDownloader()); return stream == null ? null : new JpegClosedInputStream(stream); }
Example #25
Source File: LoadAndDisplayImageTask.java From letv with Apache License 2.0 | 4 votes |
private Bitmap decodeImage(String imageUri) throws IOException { String str = imageUri; return this.decoder.decode(new ImageDecodingInfo(this.memoryCacheKey, str, this.uri, this.targetSize, this.imageAware.getScaleType(), getDownloader(), this.options)); }
Example #26
Source File: LoadAndDisplayImageTask.java From android-open-project-demo with Apache License 2.0 | 4 votes |
private Bitmap decodeImage(String imageUri) throws IOException { ViewScaleType viewScaleType = imageAware.getScaleType(); ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options); return decoder.decode(decodingInfo); }