phonegap从html创建一个位图

时间:2013-02-26 08:03:32

标签: android cordova bitmap android-webview

如何从设备屏幕中的html创建位图?

我尝试了这个,但它给了我一个黑色图像输出

Webview mAppView = this.webView;
float appScale = mAppView.getScale();

int scaledViewHeight = (int)(webViewHeight * appScale);
int scaledViewWidth = (int)(webViewWidth * appScale);

bmp = Bitmap.createBitmap(scaledViewWidth, scaledViewHeight, Bitmap.Config.RGB_565);

try {
    os = new FileOutputStream(Environment.getExternalStorageDirectory()+"/DCIM/Camera/" + "canvas.png");
    bmp.compress(CompressFormat.PNG, 90, os);

    } catch(IOException e) {
        Log.v("save image", "fail"); 
    }

0 个答案:

没有答案