我有一张空白图片,然后我放了一些贴纸,然后我想保存图片。但是当我保存图像时,我发现它的边缘变形了。
编辑:还有一个问题。可能是贴纸位置边缘扭曲的折衷..它是贴纸的位置。当我使用4000 * 2250黑色图像作为背景图像时,当我使用2000 * 1500作为背景图像时,它不会对位置产生任何问题,但会对图像的重新设置进行处理。这是在保存在应用内部之前的图片:
这是保存在我的SD卡后的照片:
这是我的位图保存代码:
public Bitmap saveCurrentBitmap() {
EditActivity act = (EditActivity) mContext;
Bitmap origRawImage = act.getRawBitmap();
// copy to mutable
Bitmap rawImage = origRawImage.copy(Bitmap.Config.ARGB_8888, true);
if (rawImage == null)
return null;
Canvas canvas = new Canvas(rawImage);
// get scale factor
RectF scaledImg = act.getImageView().getInnerBitmapSize();
float scale = rawImage.getWidth() / scaledImg.width();
List<DraggableBitmap> stampList = act.getImageView().getOverlayList();
if (stampList.size() > 0) {
Enumeration<DraggableBitmap> e = Collections.enumeration(stampList);
while (e.hasMoreElements()) {
DraggableBitmap dBmp = (DraggableBitmap) e.nextElement();
Matrix finalMtx = new Matrix();
// calculate margin and move back
Matrix marginMtx = dBmp.getMarginMatrix();
float[] moveArr = new float[9];
marginMtx.getValues(moveArr);
float x = -(moveArr[0]);
float y = -(moveArr[3]);
Matrix moveBackMtx = new Matrix();
moveBackMtx.postTranslate(x, y);
// current manipulate matrix (rotate, zoom, move..)
Matrix manipulateMtx = dBmp.getCurrentMatrix();
Matrix scaleMtx = new Matrix();
// scale to original size
scaleMtx.postScale(scale, scale, 0, 0);
manipulateMtx = (manipulateMtx == null) ? new Matrix() : manipulateMtx;
finalMtx.postConcat(manipulateMtx);
finalMtx.postConcat(moveBackMtx);
finalMtx.postConcat(scaleMtx);
canvas.drawBitmap(dBmp.mBitmap, finalMtx, null);
}
}
return rawImage;
}
这是调用savebitmap的代码
private void saveImage() {
Bitmap bmpToSave = mActivityHelper.saveCurrentBitmap();
this.getBaseApplication().setRawBitmap(bmpToSave);
savedImagePath = SaveToStorageUtil.save(bmpToSave, this);
ImageScannerAdapter adapter = new ImageScannerAdapter(this);
adapter.scanImage(savedImagePath);
}
答案 0 :(得分:0)
试试这个:
Paint p = new Paint();
p.setAntiAlias(true);
canvas.drawBitmap(dBmp.mBitmap, finalMtx, p);