Click here to Skip to main content
16,020,840 members
Home / Discussions / Android
   

Android

 
QuestionRe: I want to make an android application to add custom place and show on google map Pin
David Crow8-Nov-16 2:19
David Crow8-Nov-16 2:19 
QuestionRe: I want to make an android application to add custom place and show on google map Pin
ZurdoDev17-Nov-16 0:59
professionalZurdoDev17-Nov-16 0:59 
Questionproblem whith warp photo in android Pin
mr ar30-Oct-16 7:58
mr ar30-Oct-16 7:58 
i'm developing an app with warp function but my code does not working peoperly
i need to move pixels with fingers like liquify in PS
any help would be great.
tnx



Java
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 float[] matrixInverse;
    private int mLastWarpX = -9999; // don't match a touch coordinate
    private int mLastWarpY;

    private static void setXY(float[] array, int index, float x, float y) {
        array[(index * 2)] = x;
        array[(index * 2) + 1] = y;
    }

    public Warp(Bitmap imgBitmap, float i, float j, Canvas myCanvas) {
        mBitmap = imgBitmap;
        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++;
            }
        }

        // mMatrix.setTranslate(10, 10);
        mMatrix.invert(mInverse);

        float[] pt = {i, j};
        mInverse.mapPoints(pt);
        int x = (int) pt[0];
        int y = (int) pt[1];
        if (mLastWarpX != x || mLastWarpY != y) {
            mLastWarpX = x;
            mLastWarpY = y;
            draw(pt[0], pt[1], myCanvas);

        }

    }

    private void draw(float cx, float cy, Canvas canvas) {

        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 = dd/2;//(float) Math.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;
            }
        }

        canvas.drawColor(0xFFCCCCCC);
        canvas.concat(mMatrix);
        canvas.drawBitmapMesh(mBitmap, WIDTH, HEIGHT, mVerts, 0,
                null, 0, null);


    }

QuestionRe: problem whith warp photo in android Pin
David Crow30-Oct-16 16:14
David Crow30-Oct-16 16:14 
AnswerRe: problem whith warp photo in android Pin
mr ar30-Oct-16 21:18
mr ar30-Oct-16 21:18 
QuestionRe: problem whith warp photo in android Pin
David Crow31-Oct-16 2:34
David Crow31-Oct-16 2:34 
AnswerRe: problem whith warp photo in android Pin
mr ar31-Oct-16 2:42
mr ar31-Oct-16 2:42 
QuestionRe: problem whith warp photo in android Pin
David Crow31-Oct-16 2:58
David Crow31-Oct-16 2:58 
AnswerRe: problem whith warp photo in android Pin
DanielMarkus4-Nov-16 6:41
DanielMarkus4-Nov-16 6:41 
AnswerRe: problem whith warp photo in android Pin
DanielMarkus4-Nov-16 6:42
DanielMarkus4-Nov-16 6:42 
QuestionPlot Isobar n Google Map Api v2 Pin
lakhwinder12jan26-Oct-16 21:01
lakhwinder12jan26-Oct-16 21:01 
AnswerRe: Plot Isobar n Google Map Api v2 Pin
Richard MacCutchan26-Oct-16 21:56
mveRichard MacCutchan26-Oct-16 21:56 
GeneralRe: Plot Isobar n Google Map Api v2 Pin
David Crow27-Oct-16 4:53
David Crow27-Oct-16 4:53 
GeneralRe: Plot Isobar n Google Map Api v2 Pin
Richard MacCutchan27-Oct-16 4:58
mveRichard MacCutchan27-Oct-16 4:58 
QuestionRe: Plot Isobar n Google Map Api v2 Pin
David Crow27-Oct-16 4:57
David Crow27-Oct-16 4:57 
AnswerRe: Plot Isobar n Google Map Api v2 Pin
Richard MacCutchan27-Oct-16 4:59
mveRichard MacCutchan27-Oct-16 4:59 
GeneralRe: Plot Isobar n Google Map Api v2 Pin
David Crow27-Oct-16 5:01
David Crow27-Oct-16 5:01 
AnswerRe: Plot Isobar n Google Map Api v2 Pin
ZurdoDev27-Oct-16 6:00
professionalZurdoDev27-Oct-16 6:00 
GeneralRe: Plot Isobar n Google Map Api v2 Pin
lakhwinder12jan27-Oct-16 21:36
lakhwinder12jan27-Oct-16 21:36 
GeneralRe: Plot Isobar n Google Map Api v2 Pin
ZurdoDev28-Oct-16 0:45
professionalZurdoDev28-Oct-16 0:45 
Questioncode android multiple table with insert, delete, update Pin
Member 1279832617-Oct-16 6:47
Member 1279832617-Oct-16 6:47 
AnswerRe: code android multiple table with insert, delete, update Pin
Richard MacCutchan17-Oct-16 7:54
mveRichard MacCutchan17-Oct-16 7:54 
AnswerRe: code android multiple table with insert, delete, update Pin
David Crow17-Oct-16 10:21
David Crow17-Oct-16 10:21 
GeneralOT Pin
Eytukan2-Dec-16 0:37
Eytukan2-Dec-16 0:37 
GeneralRe: OT Pin
David Crow2-Dec-16 5:52
David Crow2-Dec-16 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.