画布转换成位图图像的android [英] converting a canvas into bitmap image in android
问题描述
我想向发展在画布上的应用程序,我在画布上用位图。经过图纸绘制,我想转换成位图图像。
I am trying to develope an app on canvas ,i am drawing on canvas with bitmap .After drawing,i am trying to convert into bitmap image .
谁能给我suggession
can anyone give me suggession
请多关照
推荐答案
咨询意见取决于你正在努力做的事情。
Advice depends upon what you are trying to do.
如果您担心您的控件需要很长的时间来画,你想画成位图,所以你可以的blit的位图,而不是通过一个帆布重新绘制,那么你的不希望双猜平台 - 控制自动缓存它们的绘制临时的位图,而这些甚至可以从使用控制<一个获取href="http://developer.android.com/reference/android/view/View.html#getDrawingCache%28%29"><$c$c>getDrawingCache()$c$c>
If you are concerned that your controls take a long time to draw, and you want to draw to a bitmap so you can blit the bitmap rather than re-drawing via a canvas, then you don't want to be double-guessing the platform - controls automatically cache their drawing to temporary bitmaps, and these can even be fetched from the control using getDrawingCache()
如果你想用一个帆布为位图绘制,通常的配方是:
If you want to draw using a canvas to a bitmap, the usual recipe is:
- 创建正确大小的使用位图<一href="http://developer.android.com/reference/android/graphics/Bitmap.html#createBitmap%28int,%20int,%20android.graphics.Bitmap.Config%29"><$c$c>Bitmap.createBitmap()$c$c>
- 创建一个帆布的实例指出,这种使用位图<一href="http://developer.android.com/reference/android/graphics/Canvas.html#Canvas%28android.graphics.Bitmap%29"><$c$c>Canvas(Bitmap)$c$c>构造
- 画到画布
- 使用位图
这篇关于画布转换成位图图像的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!