我正在尝试在透明位图上进行手指绘制。我使用的画布可以很好地绘制图像,但是当我保存图像时,图像如下所示,所有水平透明线。
我使用以下代码进行绘制。
private void doDraw(Canvas canvas) {
mOffScreenCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
for(int index = 0; index < mAnnotations.size(); index++) {
InkAnnotation annotation = mAnnotations.get(index);
annotation.draw(mOffScreenCanvas, ActivityPageToolBar.mCurrentTool.paint());
}
if(canvas != null && mSurface != null) {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
canvas.drawBitmap(mSurface, 0, 0, mPaint);
}
}
该文件使用保存
Bitmap saveBitmap = Bitmap.createBitmap(map);
Canvas c = new Canvas(saveBitmap);
c.drawColor(0xFFFFFFFF);
c.drawBitmap(map,0,0,null);
我使用标准文件保存来保存它
try {
FileOutputStream out = handle.outputStream();
if(handle.fileName().contains(".png")) {
((Bitmap) handle.data()).compress(CompressFormat.PNG, quality, out);
} else if(handle.fileName().contains(".jpg") || handle.fileName().contains(".jpeg")) {
((Bitmap) handle.data()).compress(CompressFormat.JPEG, quality, out);
} else {
((Bitmap) handle.data()).compress(CompressFormat.WEBP, quality, out);
}
out.flush();
out.close();
} catch(Exception e) {
e.printStackTrace();
}
有什么办法可以解决这个问题?同时,我将位图嵌入到 pdf 中,并且颜色比应有的颜色深。
这是我保存之前图像在屏幕上的样子。背景无关紧要,我可以很好地绘制到屏幕上,但是当它保存为 png 时,它看起来很乱。