当前位置: 首页>>代码示例>>Java>>正文


Java Bitmap.CompressFormat方法代码示例

本文整理汇总了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;
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:28,代码来源:HelpUtils.java

示例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;
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:26,代码来源:BitmapCropTask.java

示例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)));
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:43,代码来源:UCropActivity.java

示例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();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:25,代码来源:CropImageView.java

示例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;
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:40,代码来源:BitmapCroppingWorkerTask.java

示例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;
}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:12,代码来源:CropParameters.java

示例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);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:10,代码来源:ScreenshotUtils.java

示例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;
}
 
开发者ID:rosberry,项目名称:media-picker-android,代码行数:15,代码来源:FileUtils.java

示例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;
}
 
开发者ID:rosberry,项目名称:media-picker-android,代码行数:15,代码来源:MediaPhotoProcessor.java

示例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();
}
 
开发者ID:Jay-Ping,项目名称:newIPlay,代码行数:15,代码来源:ConvertUtils.java

示例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;
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:9,代码来源:CropImage.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:GlideOptions.java

示例13: setOutputFormat

import android.graphics.Bitmap; //导入方法依赖的package包/类
public void setOutputFormat(Bitmap.CompressFormat outputFormat) {
    this.outputFormat = outputFormat;
}
 
开发者ID:JarvanMo,项目名称:MarsBootProject,代码行数:4,代码来源:CropParameters.java

示例14: setCompressFormat

import android.graphics.Bitmap; //导入方法依赖的package包/类
public Builder setCompressFormat(Bitmap.CompressFormat compressFormat) {
    imageCompressor.compressFormat = compressFormat;
    return this;
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:5,代码来源:ImageCompressor.java

示例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();
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:14,代码来源:ConvertUtils.java


注:本文中的android.graphics.Bitmap.CompressFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。