How Create a new Image by merging two images

眉间皱痕 提交于 2019-12-24 19:03:11

问题


I want to Create a new image from two different Images .Output image must be result from overlaying one Image on other image by using drag ,zoom in/out, rotate actions.

I am new to Android how can i do that. which view i need to use surfaceview/imageview ????

Thanks for your time.


回答1:


It's not clear if you want to do this dynamically (in response to user actions) or whether you want to generate a fixed image based on specified drag/zoom/rotate parameters. For the former, you should go with a custom View, where you can do all your own drawing in onDraw(). For the latter, you can do this with the Bitmap class. You don't need any views. Follow these steps:

  1. Create a destination Bitmap of the size you want.
  2. create a Canvas, passing the destination Bitmap to the constructor. That will create a Canvas that will draw into the destination Bitmap.
  3. Create a Paint object for drawing.
  4. Draw your first source image using the Canvas.
  5. Draw the overlay image after applying the appropriate transformations to the Paint object.

Later, you can use the Bitmap in an ImageView or other view class that accepts images (e.g., TextView).



来源:https://stackoverflow.com/questions/5217188/how-create-a-new-image-by-merging-two-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!