我有一个要求,比如在画布上绘制一些内容并将其保存为更大的图像。到目前为止我在onDraw()方法中绘制并保存,它给出了设备提供的图像/画布大小,比如538(w)/ 852(h)左右。我需要几乎两倍大小的图像,大约1000(w)/ 1500(h)而不会丢失分辨率。任何示例代码,参考链接肯定会有所帮助。提前致谢。
答案 0 :(得分:0)
一种方法是创建所需大小的Bitmap并使用canvas绘制它:
int w = 1000, h = 1500;
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(w, h, conf);
Canvas canvas = new Canvas(bmp);
最后,你会得到你的绘画和必要尺寸。
EDIT ::
@Override
protected void onDraw(Canvas canvas) {
int w = 1000, h = 1500;
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(w, h, conf);
Canvas mycanvas = new Canvas(bmp);
super.onDraw(mycanvas);
...
}
答案 1 :(得分:0)
首先使用函数handleSubmit(e) {
e.preventDefault();
firebase.auth()
.createUserWithEmailAndPassword(this.state.emailValue, this.state.passValue)
.catch((error) => {
console.error(error)
})
this.handleAuthChange()
}
handleAuthChange() {
firebase.auth().onAuthStateChanged((user) => {
if (user) {
window.location = 'thank-you'
let email = user.email
console.log(email + " logged in")
} else {
window.location = ""
console.log("not logged in")
}
})
}
获取视图的位图,然后根据您的要求缩放位图。
getDrawingCache()
修改强>
你说你想要更高质量的图像。您无法从较低质量的图像中获得更高质量的图像。但是,您可以应用位图过滤以获得更好的质量。
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
//bitmap = bitmap.createScaledBitmap(..as your requirements..);