1

在我的 android 应用程序中,我将绘图保存为图像。我能够保存文件,但它不能完美地保存 100%,即,一些内容缺少空间即将到来。该函数在下面是我通过 onclick 调用的。请帮助我如何保存完美的屏幕截图,请访问以下链接: http : //www.flickr.com/photos/77093196@N03/7066979339,http: //www.flickr.com/photos/77093196@N03/ 7066979341

数字签名活动.java

private DrawingSurface drawingSurface;

    // To save file as Image
        public void saveDrawing(View v) throws IOException {

            File mediaStorageDir = new File(
                    Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                    "MySignatures");
             Bitmap nBitmap = drawingSurface.getBitmap();
            try {
                if (!mediaStorageDir.exists()) {
                    mediaStorageDir.mkdirs();
                }
                String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
                        .format(new Date());
                File mediaFile = new File(mediaStorageDir.getPath()
                        + File.separator + "SIGN_" + timeStamp + ".png");
             FileOutputStream out = new FileOutputStream(mediaFile);

            nBitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
                out.flush();
                out.close();
                Toast.makeText(this, "Signature saved  to " + mediaFile,
                        Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), "Not saved",
                        Toast.LENGTH_SHORT).show();
            }

        }

绘图表面.java

public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {
//some code
}
4

1 回答 1

1

我通过设置 canvas.drawColor(Color.WHITE, PorterDuff.Mode.DARKEN); 解决了 在 DrawingSurface.java 类中

于 2012-04-12T11:00:26.823 回答