开发者

how to convert a paint image to bitmap

开发者 https://www.devze.com 2022-12-14 17:35 出处:网络
I am able to save the source image but not able save the image with colorfilter: paint.setColorFilter(new ColorMatrixColorFilter(cm));

I am able to save the source image but not able save the image with colorfilter: paint.setColorFilter(new ColorMatrixColorFilter(cm));

If this image is c开发者_开发技巧onverted 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.
  4. Set your paint object, etc for this new Canvas.
  5. Draw your original bitmap into this new 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.). Now just call 'compress' on this Bitmap from point 2. and the bitmap will be saved as a jpg/png.

0

精彩评论

暂无评论...
验证码 换一张
取 消