Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7498531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:30:21+00:00 2026-05-29T19:30:21+00:00

I am developing an application in which there is a module for Image warping.I

  • 0

I am developing an application in which there is a module for Image warping.I referred several sites but could not get any solution that could solve my problem.

Any tutorials/links or suggestions for face warping would be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:30:27+00:00Added an answer on May 29, 2026 at 7:30 pm

    This is from the samples shipped with Android SDK. From your question it’s not clear if you want to know the Android API or the very warping algorithm

    public class BitmapMesh extends GraphicsActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(new SampleView(this));
        }
    
        private static class SampleView extends View {
            private static final int WIDTH = 20;
            private static final int HEIGHT = 20;
            private static final int COUNT = (WIDTH + 1) * (HEIGHT + 1);
    
            private final Bitmap mBitmap;
            private final float[] mVerts = new float[COUNT*2];
            private final float[] mOrig = new float[COUNT*2];
    
            private final Matrix mMatrix = new Matrix();
            private final Matrix mInverse = new Matrix();
    
            private static void setXY(float[] array, int index, float x, float y) {
                array[index*2 + 0] = x;
                array[index*2 + 1] = y;
            }
    
            public SampleView(Context context) {
                super(context);
                setFocusable(true);
    
                mBitmap = BitmapFactory.decodeResource(getResources(),
                                                         R.drawable.beach);
    
                float w = mBitmap.getWidth();
                float h = mBitmap.getHeight();
                // construct our mesh
                int index = 0;
                for (int y = 0; y <= HEIGHT; y++) {
                    float fy = h * y / HEIGHT;
                    for (int x = 0; x <= WIDTH; x++) {
                        float fx = w * x / WIDTH;                    
                        setXY(mVerts, index, fx, fy);
                        setXY(mOrig, index, fx, fy);
                        index += 1;
                    }
                }
    
                mMatrix.setTranslate(10, 10);
                mMatrix.invert(mInverse);
            }
    
            @Override protected void onDraw(Canvas canvas) {
                canvas.drawColor(0xFFCCCCCC);
    
                canvas.concat(mMatrix);
                canvas.drawBitmapMesh(mBitmap, WIDTH, HEIGHT, mVerts, 0,
                                      null, 0, null);
            }
    
            private void warp(float cx, float cy) {
                final float K = 10000;
                float[] src = mOrig;
                float[] dst = mVerts;
                for (int i = 0; i < COUNT*2; i += 2) {
                    float x = src[i+0];
                    float y = src[i+1];
                    float dx = cx - x;
                    float dy = cy - y;
                    float dd = dx*dx + dy*dy;
                    float d = FloatMath.sqrt(dd);
                    float pull = K / (dd + 0.000001f);
    
                    pull /= (d + 0.000001f);
                 //   android.util.Log.d("skia", "index " + i + " dist=" + d + " pull=" + pull);
    
                    if (pull >= 1) {
                        dst[i+0] = cx;
                        dst[i+1] = cy;
                    } else {
                        dst[i+0] = x + dx * pull;
                        dst[i+1] = y + dy * pull;
                    }
                }
            }
    
            private int mLastWarpX = -9999; // don't match a touch coordinate
            private int mLastWarpY;
    
            @Override public boolean onTouchEvent(MotionEvent event) {
                float[] pt = { event.getX(), event.getY() };
                mInverse.mapPoints(pt);
    
                int x = (int)pt[0];
                int y = (int)pt[1];
                if (mLastWarpX != x || mLastWarpY != y) {
                    mLastWarpX = x;
                    mLastWarpY = y;
                    warp(pt[0], pt[1]);
                    invalidate();
                }
                return true;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a cross-platform C application. Is there any compiler macro which is
i am developing application which send and receive data between two computers but there
We are developing a web application which is available in 3 languages. There are
We've been developing an Android application which includes Google Adsense. However there seems to
I am developing an application in which there will be a search screen where
i am developing one application in which there is an imageview...in which i want
We are developing a simple web application in JSF in which there is a
I am currently developing a facebook canvas (iframe) based application. Is there any way
I am developing a php-based web application in which there is a text area
I am developing an application in which there are 7 buttons in every view.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.