Android: how to warp images?

前端 未结 2 406
一向
一向 2020-12-06 00:37

I want to warp images like this:

\"Example

Added 08-04-2013: I used this code but it\'

相关标签:
2条回答
  • 2020-12-06 01:02

    This could be achieved by OpenCV so give a try to this

    0 讨论(0)
  • 2020-12-06 01:12

    There is a much easier way than coding you own. See TransitionDrawable

    An extension of LayerDrawables that is intended to cross-fade between the first and second layer. To start the transition, call startTransition(int). To display just the first layer, call resetTransition().
    It can be defined in an XML file with the <transition> element. Each Drawable in the transition is defined in a nested <item>

    You can find many examples on line, here is one:

    <?xml version="1.0" encoding="utf-8"?>
    <transition xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:drawable="@drawable/first_image" />
      <item android:drawable="@drawable/second_image" />
    </transition>
    

    and the code

    final ImageView image = (ImageView) findViewById(R.id.image);
    final ToggleButton button = (ToggleButton) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(final View v) {
        TransitionDrawable drawable = (TransitionDrawable) image.getDrawable();
        if (button.isChecked()) {
          drawable.startTransition(500);
        } else {
          drawable.reverseTransition(500);
        }
      }
    }); 
    
    0 讨论(0)
提交回复
热议问题