赞
踩
android实现重绘图片的工具类:
- package com.demo.loading;
-
- import android.graphics.Bitmap;
- import android.graphics.Bitmap.Config;
- import android.graphics.Canvas;
- import android.graphics.Matrix;
- import android.graphics.Paint;
- import android.graphics.Path;
- import android.graphics.PorterDuff.Mode;
- import android.graphics.PorterDuffXfermode;
- import android.graphics.Rect;
- import android.graphics.RectF;
-
- /**
- * 重绘图片
- *
- * @author Administrator
- *
- */
- public class ImageRedraw {
- private static ImageRedraw instance;
-
- public static ImageRedraw getInstance() {
- if (instance == null) {
- instance = new ImageRedraw();
- }
- return instance;
- }
-
- public ImageRedraw() {
- super();
- }
-
- /**
- * 重绘图片
- *
- * @param bitmap
- * @return newBitmap
- */
- public Bitmap redrawImg(Bitmap bitmap, String type) {
- Bitmap newBitmap = bitmap;
- if (ConstantUtils.IMAGECARDBACK.equals(type)) {
- newBitmap = redrawCardBackImg(bitmap);
- } else if (ConstantUtils.IMAGECARDFRONT.equals(type)) {
- newBitmap = redrawCardInfo(bitmap);
- }
- return newBitmap;
- }
-
- /**
- * 重绘头图片
- * @param bitmap
- * @return
- */
- public Bitmap redrawCardBackImg(Bitmap bitmap) {
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- // 946 233 原始大小
- // 315 78
- // 473 116
- // 445 110
- int newWidth = 445;
- int newHeight = 110;
- float scaleWidth = ((float) newWidth) / width;
- float scaleHe
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。