简体   繁体   中英

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));

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.
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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