简体   繁体   English

如何将绘画图像转换为位图

[英]how to convert a paint image to bitmap

I am able to save the source image but not able save the image with colorfilter: paint.setColorFilter(new ColorMatrixColorFilter(cm)); 我可以保存源图像,但不能使用colorfilter保存图像: paint.setColorFilter(new ColorMatrixColorFilter(cm));

If this image is converted into bitmap it can be saved easily, but I don't know how to do this. 如果将此图像转换为位图,则可以轻松保存,但是我不知道该怎么做。 Is there anyone to give solution? 有没有人可以解决?

  1. Have your original bitmap. 拥有原始位图。
  2. Create a new clean Bitmap that has the same width/height as your original bitmap. 创建一个新的原始位图,该位图的宽度/高度与原始位图相同。
  3. Create a new Canvas using this clean Bitmap. 使用此干净的位图创建一个新的Canvas。
  4. Set your paint object, etc for this new Canvas. 设置此新Canvas的绘画对象等。
  5. Draw your original bitmap into this new Canvas. 将原始位图绘制到此新的Canvas中。

Since this new Canvas is backed by a Bitmap (point 3.), any drawing you do in this Canvas will become part of the new Bitmap (point 2.). 由于此新的画布由位图(第3点)支持,因此您在此画布中所做的任何图形都将成为新的位图(第2点)的一部分。 Now just call 'compress' on this Bitmap from point 2. and the bitmap will be saved as a jpg/png. 现在,只需从点2对该位图调用“压缩”,该位图将另存为jpg / png。

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

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