本文整理汇总了Java中android.graphics.Bitmap.CompressFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Bitmap.CompressFormat方法的具体用法?Java Bitmap.CompressFormat怎么用?Java Bitmap.CompressFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Bitmap
的用法示例。
在下文中一共展示了Bitmap.CompressFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createThumbnailFromOrig
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* 压缩发送到服务器的图片
* @param origPath 原始图片路径
* @param widthLimit 图片宽度限制
* @param heightLimit 图片高度限制
* @param format 图片格式
* @param quality 图片压缩率
* @param authorityDir 图片目录
* @param outPath 图片详细目录
* @return
*/
public static boolean createThumbnailFromOrig(String origPath,
int widthLimit, int heightLimit, Bitmap.CompressFormat format,
int quality, String authorityDir, String outPath) {
Bitmap bitmapThumbNail = extractThumbNail(origPath, widthLimit, heightLimit, false);
if(bitmapThumbNail == null) {
return false;
}
try {
saveImageFile(bitmapThumbNail, quality, format, authorityDir, outPath);
return true;
} catch (IOException e) {
LogUtil.e(TAG, "create thumbnail from orig failed: " + outPath);
}
return false;
}
示例2: BitmapCropTask
import android.graphics.Bitmap; //导入方法依赖的package包/类
public BitmapCropTask(@NonNull Context context, @Nullable Bitmap viewBitmap,
@NonNull RectF cropRect, @NonNull RectF currentImageRect,
float currentScale, float currentAngle,
int maxResultImageSizeX, int maxResultImageSizeY,
@NonNull Bitmap.CompressFormat compressFormat, int compressQuality,
@NonNull Uri outputUri, @Nullable BitmapCropCallback cropCallback) {
mContext = context;
mViewBitmap = viewBitmap;
mCropRect = cropRect;
mCurrentImageRect = currentImageRect;
mCurrentScale = currentScale;
mCurrentAngle = currentAngle;
mMaxResultImageSizeX = maxResultImageSizeX;
mMaxResultImageSizeY = maxResultImageSizeY;
mCompressFormat = compressFormat;
mCompressQuality = compressQuality;
mOutputUri = outputUri;
mCropCallback = cropCallback;
}
示例3: processOptions
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* This method extracts {@link com.yalantis.ucrop.UCrop.Options #optionsBundle} from incoming intent
* and setups Activity, {@link OverlayView} and {@link CropImageView} properly.
*/
@SuppressWarnings("deprecation")
private void processOptions(@NonNull Intent intent) {
// Bitmap compression options
String compressionFormatName = intent.getStringExtra(UCrop.Options.EXTRA_COMPRESSION_FORMAT_NAME);
Bitmap.CompressFormat compressFormat = null;
if (!TextUtils.isEmpty(compressionFormatName)) {
compressFormat = Bitmap.CompressFormat.valueOf(compressionFormatName);
}
mCompressFormat = (compressFormat == null) ? DEFAULT_COMPRESS_FORMAT : compressFormat;
mCompressQuality = intent.getIntExtra(UCrop.Options.EXTRA_COMPRESSION_QUALITY, UCropActivity.DEFAULT_COMPRESS_QUALITY);
// Gestures options
int[] allowedGestures = intent.getIntArrayExtra(UCrop.Options.EXTRA_ALLOWED_GESTURES);
if (allowedGestures != null && allowedGestures.length == TABS_COUNT) {
mAllowedGestures = allowedGestures;
}
// Crop image view options
mGestureCropImageView.setMaxBitmapSize(intent.getIntExtra(UCrop.Options.EXTRA_MAX_BITMAP_SIZE, CropImageView.DEFAULT_MAX_BITMAP_SIZE));
mGestureCropImageView.setMaxScaleMultiplier(intent.getFloatExtra(UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, CropImageView.DEFAULT_MAX_SCALE_MULTIPLIER));
mGestureCropImageView.setImageToWrapCropBoundsAnimDuration(intent.getIntExtra(UCrop.Options.EXTRA_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION));
// Overlay view options
mOverlayView.setDimmedColor(intent.getIntExtra(UCrop.Options.EXTRA_DIMMED_LAYER_COLOR, getResources().getColor(R.color.ucrop_color_default_dimmed)));
mOverlayView.setOvalDimmedLayer(intent.getBooleanExtra(UCrop.Options.EXTRA_OVAL_DIMMED_LAYER, OverlayView.DEFAULT_OVAL_DIMMED_LAYER));
mOverlayView.setShowCropFrame(intent.getBooleanExtra(UCrop.Options.EXTRA_SHOW_CROP_FRAME, OverlayView.DEFAULT_SHOW_CROP_FRAME));
mOverlayView.setCropFrameColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame)));
mOverlayView.setCropFrameStrokeWidth(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width)));
mOverlayView.setShowCropGrid(intent.getBooleanExtra(UCrop.Options.EXTRA_SHOW_CROP_GRID, OverlayView.DEFAULT_SHOW_CROP_GRID));
mOverlayView.setCropGridRowCount(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_ROW_COUNT, OverlayView.DEFAULT_CROP_GRID_ROW_COUNT));
mOverlayView.setCropGridColumnCount(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_COLUMN_COUNT, OverlayView.DEFAULT_CROP_GRID_COLUMN_COUNT));
mOverlayView.setCropGridColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_grid)));
mOverlayView.setCropGridStrokeWidth(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_grid_stoke_width)));
}
示例4: saveOutput
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* 将图片保存在本地
*/
private void saveOutput(Bitmap croppedImage, Bitmap.CompressFormat outputFormat, File saveFile) {
OutputStream outputStream = null;
try {
outputStream = getContext().getContentResolver().openOutputStream(Uri.fromFile(saveFile));
if (outputStream != null) croppedImage.compress(outputFormat, 90, outputStream);
Message.obtain(mHandler, SAVE_SUCCESS, saveFile).sendToTarget();
} catch (IOException ex) {
ex.printStackTrace();
Message.obtain(mHandler, SAVE_ERROR, saveFile).sendToTarget();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
mSaving = false;
croppedImage.recycle();
}
示例5: BitmapCroppingWorkerTask
import android.graphics.Bitmap; //导入方法依赖的package包/类
BitmapCroppingWorkerTask(
CropImageView cropImageView,
Uri uri,
float[] cropPoints,
int degreesRotated,
int orgWidth,
int orgHeight,
boolean fixAspectRatio,
int aspectRatioX,
int aspectRatioY,
int reqWidth,
int reqHeight,
boolean flipHorizontally,
boolean flipVertically,
CropImageView.RequestSizeOptions options,
Uri saveUri,
Bitmap.CompressFormat saveCompressFormat,
int saveCompressQuality) {
mCropImageViewReference = new WeakReference<>(cropImageView);
mContext = cropImageView.getContext();
mUri = uri;
mCropPoints = cropPoints;
mDegreesRotated = degreesRotated;
mFixAspectRatio = fixAspectRatio;
mAspectRatioX = aspectRatioX;
mAspectRatioY = aspectRatioY;
mOrgWidth = orgWidth;
mOrgHeight = orgHeight;
mReqWidth = reqWidth;
mReqHeight = reqHeight;
mFlipHorizontally = flipHorizontally;
mFlipVertically = flipVertically;
mReqSizeOptions = options;
mSaveUri = saveUri;
mSaveCompressFormat = saveCompressFormat;
mSaveCompressQuality = saveCompressQuality;
mBitmap = null;
}
示例6: CropParameters
import android.graphics.Bitmap; //导入方法依赖的package包/类
public CropParameters(int maxResultImageSizeX, int maxResultImageSizeY,
Bitmap.CompressFormat compressFormat, int compressQuality,
String imageInputPath, String imageOutputPath, ExifInfo exifInfo) {
mMaxResultImageSizeX = maxResultImageSizeX;
mMaxResultImageSizeY = maxResultImageSizeY;
mCompressFormat = compressFormat;
mCompressQuality = compressQuality;
mImageInputPath = imageInputPath;
mImageOutputPath = imageOutputPath;
mExifInfo = exifInfo;
}
示例7: screenshotToFileWithWallpaperIf
import android.graphics.Bitmap; //导入方法依赖的package包/类
public static boolean screenshotToFileWithWallpaperIf(Activity activity, File file,
Bitmap.CompressFormat compressFormat,
int quality) {
if (ThemeUtils.isWallpaperTheme(activity)) {
return screenshotToFileWithWallpaper(activity, file, compressFormat, quality);
} else {
return screenshotToFile(activity, file, compressFormat, quality);
}
}
示例8: bitmapToFile
import android.graphics.Bitmap; //导入方法依赖的package包/类
public static boolean bitmapToFile(Bitmap bitmap, String path, int quality, Bitmap.CompressFormat format) {
boolean result = true;
try {
OutputStream out = new FileOutputStream(new File(path));
result = bitmap.compress(format, quality, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
result = false;
}
return result;
}
示例9: getCompressType
import android.graphics.Bitmap; //导入方法依赖的package包/类
private Bitmap.CompressFormat getCompressType(PhotoOptions originalPhotoOptions) {
if (originalPhotoOptions.getType().length() > 0) {
String type = originalPhotoOptions.getType().toLowerCase();
if (type.equals("jpg") || type.equals("jpeg")) {
return Bitmap.CompressFormat.JPEG;
} else if (type.equals("png")) {
return Bitmap.CompressFormat.PNG;
} else if (type.equals("webp")) {
return Bitmap.CompressFormat.WEBP;
}
}
return Bitmap.CompressFormat.JPEG;
}
示例10: bitmap2Bytes
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* bitmap转byteArr
*
* @param bitmap bitmap对象
* @param format 格式
* @return 字节数组
*/
public static byte[] bitmap2Bytes(Bitmap bitmap, Bitmap.CompressFormat format) {
if (bitmap == null)
return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(format, 100, baos);
return baos.toByteArray();
}
示例11: setOutputCompressFormat
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* the compression format to use when writting the image.<br>
* <i>Default: JPEG</i>
*/
public ActivityBuilder setOutputCompressFormat(Bitmap.CompressFormat outputCompressFormat) {
mOptions.outputCompressFormat = outputCompressFormat;
return this;
}
示例12: encodeFormatOf
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* @see RequestOptions#encodeFormatOf(CompressFormat)
*/
@CheckResult
public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) {
return new GlideOptions().encodeFormat(arg0);
}
示例13: setOutputFormat
import android.graphics.Bitmap; //导入方法依赖的package包/类
public void setOutputFormat(Bitmap.CompressFormat outputFormat) {
this.outputFormat = outputFormat;
}
示例14: setCompressFormat
import android.graphics.Bitmap; //导入方法依赖的package包/类
public Builder setCompressFormat(Bitmap.CompressFormat compressFormat) {
imageCompressor.compressFormat = compressFormat;
return this;
}
示例15: bitmap2Bytes
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* bitmap转byteArr
*
* @param bitmap bitmap对象
* @param format 格式
* @return 字节数组
*/
public static byte[] bitmap2Bytes(final Bitmap bitmap, final Bitmap.CompressFormat format) {
if (bitmap == null) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(format, 100, baos);
return baos.toByteArray();
}