image deformation in an android projrct -




in android app, need deform image 1 point other point. should seems that

enter image description here

the origin point , b new position of a

the result may enter image description here

i have try use "drawbitmapmesh" function make possible, did not reach, here wrap code:

public void warp(float startx, float starty, float endx, float endy) {

        float ddpull = (endx - startx) * (endx - startx) + (endy - starty) * (endy - starty);         float dpull = (float) math.sqrt(ddpull);          (int = 0; < (counts * 2); += 2) {             float dx = orig[i] - startx;             float dy = orig[i + 1] - starty;             float dd = dx * dx + dy * dy;             float d = (float) math.sqrt(dd);              // deformation when point in circle             if (d < cirr) {                 double e =(cirr * cirr - dd) * (cirr * cirr - dd) / ((cirr * cirr - dd + dpull * dpull) * (cirr * cirr - dd + dpull * dpull));                 double pullx = e * (endx - startx);                 double pully = e * (endy - starty);                  verts[i] = (float) (orig[i] + pullx);                 verts[i + 1] = (float) (orig[i + 1] + pully);              }         }          invalidate();     } 

at last solve myself, use gpuimage android , write customized filter glsl, works good~!





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -