public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) { this.imageKey = imageKey; this.imageUri = imageUri; this.originalImageUri = originalImageUri; this.targetSize = targetSize; this.imageScaleType = displayOptions.getImageScaleType(); this.viewScaleType = viewScaleType; this.downloader = downloader; this.extraForDownloader = displayOptions.getExtraForDownloader(); considerExifParams = displayOptions.isConsiderExifParams(); decodingOptions = new Options(); copyOptions(displayOptions.getDecodingOptions(), decodingOptions); }
public String getStickerBitmapUri(String categoryName, String stickerName) { StickerManager manager = StickerManager.getInstance(); StickerCategory category = manager.getCategory(categoryName); if (category == null) { return null; } if (isSystemSticker(categoryName)) { if (!stickerName.contains(".png")) { stickerName += ".png"; } String path = "sticker/" + category.getName() + "/" + stickerName; return ImageDownloader.Scheme.ASSETS.wrap(path); } return null; }
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; }
public ImageDecodingInfo(String imageKey, String imageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) { this.imageKey = imageKey; this.imageUri = imageUri; this.targetSize = targetSize; this.imageScaleType = displayOptions.getImageScaleType(); this.viewScaleType = viewScaleType; this.downloader = downloader; this.extraForDownloader = displayOptions.getExtraForDownloader(); considerExifParams = displayOptions.isConsiderExifParams(); decodingOptions = new Options(); copyOptions(displayOptions.getDecodingOptions(), decodingOptions); }
@Nullable public static String getUri(@Nullable File file) { if (file == null) return null; final String uri; if (file.exists()) { uri = ImageDownloader.Scheme.FILE.wrap(file.getAbsolutePath()); } else { String name = file.getName(); if (sAssets.contains(name)) { uri = ImageDownloader.Scheme.ASSETS.wrap(name); } else if (sApkExpansionZipFile != null && sApkExpansionZipFile.contains(name)) { uri = BaseImageDownloaderImpl.obbScheme + name; } else { Log.w(TAG, "File " + file.getAbsolutePath() + " doesn't exist on ext or assets!"); uri = null; } } return uri; }
private ImageDownloader getDownloader() { ImageDownloader d; if (engine.isNetworkDenied()) { d = networkDeniedDownloader; } else if (engine.isSlowNetwork()) { d = slowNetworkDownloader; } else { d = downloader; } return d; }
private ImageDownloader getDownloader() { if (this.engine.isNetworkDenied()) { return this.networkDeniedDownloader; } if (this.engine.isSlowNetwork()) { return this.slowNetworkDownloader; } return this.downloader; }
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) { this.imageKey = imageKey; this.imageUri = imageUri; this.originalImageUri = originalImageUri; this.targetSize = targetSize; this.imageScaleType = displayOptions.getImageScaleType(); this.viewScaleType = viewScaleType; this.downloader = downloader; this.extraForDownloader = displayOptions.getExtraForDownloader(); this.considerExifParams = displayOptions.isConsiderExifParams(); copyOptions(displayOptions.getDecodingOptions(), this.decodingOptions); }
protected ExifInfo defineExifOrientation(String imageUri) { int rotation = 0; boolean flip = false; try { ExifInterface exif = new ExifInterface(ImageDownloader.Scheme.FILE.crop(imageUri)); int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exifOrientation) { case ExifInterface.ORIENTATION_FLIP_HORIZONTAL: flip = true; case ExifInterface.ORIENTATION_NORMAL: rotation = 0; break; case ExifInterface.ORIENTATION_TRANSVERSE: flip = true; case ExifInterface.ORIENTATION_ROTATE_90: rotation = 90; break; case ExifInterface.ORIENTATION_FLIP_VERTICAL: flip = true; case ExifInterface.ORIENTATION_ROTATE_180: rotation = 180; break; case ExifInterface.ORIENTATION_TRANSPOSE: flip = true; case ExifInterface.ORIENTATION_ROTATE_270: rotation = 270; break; } } catch (IOException e) { L.w("Can't read EXIF tags from file [%s]", imageUri); } return new ExifInfo(rotation, flip); }
public static byte[] getImageByteByPath(String imagePath, ImageSize imageSize) { try { DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(false).cacheOnDisk(false) .considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY).build(); Bitmap upbitmap = ImageLoader.getInstance().loadImageSync(ImageDownloader.Scheme.FILE.wrap(imagePath), imageSize, options); if (upbitmap == null) { return null; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); upbitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); int option = 100; while (baos.toByteArray().length / 1024 > 120) { baos.reset(); option -= 10; upbitmap.compress(Bitmap.CompressFormat.JPEG, option, baos); } byte[] result = baos.toByteArray(); IoUtils.closeSilently(baos); upbitmap.recycle(); return result; } catch (Throwable e) { e.printStackTrace(); } return null; }
public static void displayImage_local_string(String imgStr, ImageView image){ DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true) .showImageOnLoading(R.drawable.loading_bg_cn_2_1) .showImageOnFail(R.drawable.loading_fail_bg_cn_2_1) .showImageForEmptyUri(R.drawable.loading_none_bg_cn_2_1) .cacheOnDisk(true).considerExifParams(true) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(FADEINTIME)).bitmapConfig(Bitmap.Config.RGB_565) .build(); String imagePath = "/mnt/sdcard/image.png"; String imageUrl = ImageDownloader.Scheme.FILE.wrap(imagePath); ImageLoader.getInstance().displayImage(imgStr, image, options); }
public static void displayImage_local_string(String string,ImageView image){ DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true) .showImageOnLoading(R.drawable.loading_bg_cn_2_1) .showImageOnFail(R.drawable.loading_fail_bg_cn_2_1) .showImageForEmptyUri(R.drawable.loading_none_bg_cn_2_1) .cacheOnDisk(true).considerExifParams(true) .imageScaleType(ImageScaleType.IN_SAMPLE_INT).resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(FADEINTIME)).bitmapConfig(Bitmap.Config.RGB_565) .build(); String imagePath = "/mnt/sdcard/image.png"; String imageUrl = ImageDownloader.Scheme.FILE.wrap(imagePath); ImageLoader.getInstance().displayImage(string, image, options); }