简体   繁体   English

Android如何在没有视图的画布上绘制

[英]Android how to draw on a canvas without a view

I am making an application that makes use of canvases and the images are saved on the server and seen by other users. 我正在开发一个使用画布的应用程序,图像保存在服务器上并被其他用户看到。

however the canvas-containing-view's size is dependent on the devices and therefore images made in smaller devices are blurry when seen in larger ones. 但是,包含画布的视图的大小取决于设备,因此,在较大的设备中观看时,在较小的设备中生成的图像模糊。

So my question is, Can I make a canvas that does not depend on a view? 所以我的问题是,我可以制作不依赖于视图的画布吗? this way I can make a large image at background and can save the HQ image on the server. 这样,我可以在后台制作大图像,并将HQ图像保存在服务器上。

If I cannot, please tell me a solution for such problem.... 如果无法解决,请告诉我解决此类问题的方法。

//The image-creating user can check what he draws by imageViews, so there is no need for the canvas to be visible or interactive. //创建图像的用户可以检查他通过imageViews绘制的内容,因此不需要画布是可见的或交互式的。

//I am not able to create the images on server side.... //我无法在服务器端创建图像。

You can create a Canvas that draws on a Bitmap : 您可以创建一个Canvas上绘制一个Bitmap

Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);

See Canvas and Drawables API guide . 请参见Canvas and Drawables API指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM