image deformation in an android projrct -
in android app, need deform image 1 point other point. should seems that
the origin point , b new position of a
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
Post a Comment