在android中将画布转换为位图图像 [英] converting a canvas into bitmap image in android

查看:44
本文介绍了在android中将画布转换为位图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在画布上开发一个应用程序,我正在画布上绘制位图.绘制后,我正在尝试转换为位图图像.

I am trying to develop an app on canvas,I am drawing a bitmap on the canvas. After drawing, I am trying to convert into bitmap image.

谁能给我一个建议?

推荐答案

建议取决于您要尝试做什么.

Advice depends upon what you are trying to do.

如果您担心您的控件需要很长时间来绘制,并且您想绘制到位图以便您可以对位图进行 blit 而不是通过画布重新绘制,那么您不要em> 希望对平台进行双重猜测 - 控件自动将其绘图缓存到临时位图,甚至可以使用 getDrawingCache()

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:

  1. 使用 Bitmap.createBitmap()
  2. 使用Canvas(Bitmap) 构造函数
  3. 在画布上绘制
  4. 使用位图

这篇关于在android中将画布转换为位图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆