Java Code Examples for android.graphics.Bitmap.CompressFormat#PNG
The following examples show how to use
android.graphics.Bitmap.CompressFormat#PNG .
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: RequestSettings.java From PkRequestManager with MIT License | 6 votes |
public RequestSettings() { this.emailAddresses = null; this.emailSubject = "No Subject"; this.emailPrecontent = ""; this.saveLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/.icon_request"; this.saveLocation2 = this.saveLocation + "/files"; this.appfilterName = "appfilter.xml"; this.compressFormat = CompressFormat.PNG; this.appendInformation = true; this.createAppfilter = true; this.createZip = true; this.filterAutomatic = true; this.filterDefined = true; this.byteBuffer = 2048; this.compressQuality = 100; }
Example 2
Source File: RequestSettings.java From PkRequestManager with MIT License | 6 votes |
/** * Creates a RequestSettings Builder object for easily * assigning custom settings. */ public Builder() { this.emailAddresses = new ArrayList<String>(); this.emailSubject = "No Subject"; this.emailPrecontent = ""; this.saveLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/.icon_request"; this.saveLocation2 = this.saveLocation + "/files"; this.appfilterName = "appfilter.xml"; this.compressFormat = CompressFormat.PNG; this.appendInformation = true; this.createAppfilter = true; this.createZip = true; this.filterAutomatic = true; this.filterDefined = true; this.byteBuffer = 2048; this.compressQuality = 100; }
Example 3
Source File: BitmapUtil.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static @NonNull CompressFormat getCompressFormatForContentType(@Nullable String contentType) { if (contentType == null) return CompressFormat.JPEG; switch (contentType) { case MediaUtil.IMAGE_JPEG: return CompressFormat.JPEG; case MediaUtil.IMAGE_PNG: return CompressFormat.PNG; case MediaUtil.IMAGE_WEBP: return CompressFormat.WEBP; default: return CompressFormat.JPEG; } }
Example 4
Source File: AndroidImageBridge.java From CrossMobile with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void fillStreamAndClose(NativeBitmap nativebitmap, ImageType type, double quality, OutputStream out) throws IOException { Bitmap bitmap = ((AndroidBitmap) nativebitmap).bitmap; CompressFormat compress = type == ImageType.JPEG ? CompressFormat.JPEG : CompressFormat.PNG; try { if (!bitmap.compress(compress, (int) (quality * 100), out)) throw new IOException("Unable to compress image with type " + type.name()); } finally { closeR(out); } }
Example 5
Source File: ImageUtil.java From MyBlogDemo with Apache License 2.0 | 5 votes |
/** * 判断图片类型 * * @param b * @return */ public CompressFormat getImageType(byte[] b) { if (b[1] == (byte) 'P' && b[2] == (byte) 'N' && b[3] == (byte) 'G') { return CompressFormat.PNG; } else if (b[6] == (byte) 'J' && b[7] == (byte) 'F' && b[8] == (byte) 'I' && b[9] == (byte) 'F') { return CompressFormat.JPEG; } else { return CompressFormat.JPEG; } }
Example 6
Source File: ImageUtil.java From MyBlogDemo with Apache License 2.0 | 5 votes |
/** * 通过url或文件名来判断图片类型 * * @param url * @return */ public static CompressFormat getImageType(String url) { String name = url.substring(url.lastIndexOf(".") + 1); if (name.equalsIgnoreCase("png")) { return CompressFormat.PNG; } else if (name.equalsIgnoreCase("jpg")) { return CompressFormat.JPEG; } else { return CompressFormat.JPEG; } }
Example 7
Source File: ImageDiskLruCache.java From android-tv-launcher with MIT License | 5 votes |
/** * 根据文件类型获得CompressFormat. * * @Description: * @Date 2014-3-7 */ private CompressFormat getCompressFormat(String url) { String lowerUrl = url.toLowerCase(Locale.ENGLISH); if (lowerUrl.endsWith(".jpg")) { return CompressFormat.JPEG; } else if (lowerUrl.endsWith(".png")) { return CompressFormat.PNG; } return CompressFormat.JPEG; }
Example 8
Source File: CropActivity.java From imageCrop with MIT License | 4 votes |
protected static CompressFormat convertExtensionToCompressFormat(String extension) { return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG; }
Example 9
Source File: WallpaperCropActivity.java From TurboLauncher with Apache License 2.0 | 4 votes |
protected static CompressFormat convertExtensionToCompressFormat(String extension) { return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG; }
Example 10
Source File: BitmapUtil.java From Silence with GNU General Public License v3.0 | 4 votes |
public static <T> byte[] createScaledBytes(Context context, T model, MediaConstraints constraints) throws BitmapDecodingException { CompressFormat compressFormat = CompressFormat.PNG; int quality = 100; int attempts = 0; byte[] bytes; Bitmap scaledBitmap = Downsampler.AT_MOST.decode(getInputStreamForModel(context, model), Glide.get(context).getBitmapPool(), constraints.getImageMaxWidth(context), constraints.getImageMaxHeight(context), DecodeFormat.PREFER_RGB_565); if (scaledBitmap == null) { throw new BitmapDecodingException("Unable to decode image"); } try { do { attempts++; ByteArrayOutputStream baos = new ByteArrayOutputStream(); scaledBitmap.compress(compressFormat, quality, baos); bytes = baos.toByteArray(); Log.w(TAG, "iteration with quality " + quality + "; size " + (bytes.length / 1024) + "kb; attempts " + attempts); compressFormat = CompressFormat.JPEG; if (quality > MAX_COMPRESSION_QUALITY) { quality = MAX_COMPRESSION_QUALITY; } else { quality = quality - COMPRESSION_QUALITY_DECREASE; } } while (bytes.length > constraints.getImageMaxSize(context)); return bytes; } finally { if (scaledBitmap != null) scaledBitmap.recycle(); } }
Example 11
Source File: WallpaperCropActivity.java From LB-Launcher with Apache License 2.0 | 4 votes |
protected static CompressFormat convertExtensionToCompressFormat(String extension) { return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG; }