android - 在android中更改图像形状

标签 android image android-canvas android-image

我成功地在 Canvas 上的图像中实现了双指缩放和拖放功能。

现在我想要的是重新调整大小,如下图链接基于 iPhone App enter image description here

How to change shape of an image using iPhone SDK?

那么我怎样才能在 Android 中实现这种功能呢?

最佳答案

基本上你需要使图像无效并从头开始在 Canvas 上重新绘制::

img=(ImageView)findViewById(R.id.yourimageidfromxml);

img.onTouchEvent(MotionEvent me)
{
   int X=me.getX(); 
   int Y=me.getY();
   img.invalidate();
   img.repaint(X,Y);

}

void paint(int X,int Y)
{
  img.setWidth(X);
  img.setHeight(Y);
}

缩放图像将从一开始就使用 Canvas 上的重绘进行变换

关于android - 在android中更改图像形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12278692/

相关文章:

java - Android:使用 postInvalidate() 还是直接调用 onDraw?

android - 在 Android 上,如何制作形状奇特的剪裁区域?

java - 根据随机值获取数组元素

html - 为 iOS 设置网站背景图片

android - 将 Canvas 上的图像保存到 SurfaceView 中的文件

php - iTunes 艺术作品数据为 html 图像

image - 如何解压缩 PVRTC 压缩图像格式以在 PC 上查看它

java - Android Studio 上的待办事项列表-无法解决方法

android - 从服务更新 Activity 的数据

java - 非法参数异常 : No view found for id for fragment