本文主要是介绍android中图片重绘的工具类的实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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 110int newWidth = 445;int newHeight = 110;float scaleWidth = ((float) newWidth) / width;float scaleHe
这篇关于android中图片重绘的工具类的实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!