android.graphics.Bitmap.CompressFormat#PNG源码实例Demo

下面列出了android.graphics.Bitmap.CompressFormat#PNG 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PkRequestManager   文件: RequestSettings.java
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;
}
 
源代码2 项目: PkRequestManager   文件: RequestSettings.java
/**
 * 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;
}
 
源代码3 项目: mollyim-android   文件: BitmapUtil.java
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;
  }
}
 
源代码4 项目: CrossMobile   文件: AndroidImageBridge.java
@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);
    }
}
 
源代码5 项目: MyBlogDemo   文件: ImageUtil.java
/**
 * 判断图片类型
 *
 * @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;
    }
}
 
源代码6 项目: MyBlogDemo   文件: ImageUtil.java
/**
 * 通过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;
    }
}
 
源代码7 项目: android-tv-launcher   文件: ImageDiskLruCache.java
/**
 * 根据文件类型获得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;
}
 
源代码8 项目: imageCrop   文件: CropActivity.java
protected static CompressFormat convertExtensionToCompressFormat(String extension) {
    return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG;
}
 
源代码9 项目: TurboLauncher   文件: WallpaperCropActivity.java
protected static CompressFormat convertExtensionToCompressFormat(String extension) {
    return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG;
}
 
源代码10 项目: Silence   文件: BitmapUtil.java
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();
  }
}
 
源代码11 项目: LB-Launcher   文件: WallpaperCropActivity.java
protected static CompressFormat convertExtensionToCompressFormat(String extension) {
    return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG;
}
 
 同类方法