绿色阴影,当采取屏幕射击了看法时

时间:2016-10-06 07:27:25

标签: android image screenshot

我需要拍摄视图的屏幕截图(线性布局)和内部线性布局有一个图像,当我拍摄该视图的屏幕截图并存储到SD卡中时,屏幕截图存储成功,但它会滑动图像背景颜色(白色阴影看起来像浅绿色。)

我写了下面的代码来拍摄屏幕截图。

Bitmap mScreenShot = null;
mScreenShot = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
mScreenShot.setDensity(view.getResources().getDisplayMetrics().densityDpi);
Canvas mCanvas = new Canvas(mScreenShot);
mCanvas.drawColor(0, PorterDuff.Mode.SRC_IN);
view.draw(mCanvas);
ImageHelper.saveImageAsPNG(mScreenShot,filePath);

将图像另存为PNG的方法

public static boolean saveImageAsPNG(Bitmap p_bitmap, String p_destinationPath) throws Throwable
    {
        if (p_bitmap != null || p_destinationPath != null)
        {
            FileOutputStream m_out = new FileOutputStream(p_destinationPath);
            return p_bitmap.compress(Bitmap.CompressFormat.PNG, 100, m_out);
        }
        return false;
    }

enter image description here

请查看附加的屏幕截图。 请帮帮我

1 个答案:

答案 0 :(得分:0)

您是否尝试过仅使用画布而不是设置任何参数,请参阅下面的

  /**
 * Captures the view and returns bitmap
 *
 * @param v
 * @return bitmap of view captured
 */
public static Bitmap captureView(View v) {
    Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.draw(c);
    return b;
}