0

我正在尝试在透明位图上进行手指绘制。我使用的画布可以很好地绘制图像,但是当我保存图像时,图像如下所示,所有水平透明线。

保存的图像

我使用以下代码进行绘制。

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 时,它看起来很乱。

在此处输入图像描述

4

1 回答 1

0

我通过获取我在表面视图上创建的点并从这些点创建一个新的位图来解决这个问题。它必须对其位图进行表面处理才能导致这种情况。

于 2014-06-10T14:44:59.457 回答