Android Open Source - Sketcher-Tab Surface Diff






From Project

Back to project page Sketcher-Tab.

License

The source code is released under:

Apache License

If you think the Android project Sketcher-Tab listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.sketchertab;
//from www  .  j av  a  2 s. co m
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.util.Log;

import java.nio.IntBuffer;

/**
 * Two surfaces difference
 */

public final class SurfaceDiff {
    private static final String TAG = "SurfaceDiff";
    private static final boolean DEBUG_DIFF = false;

    private boolean[] bitmask;
    private Rect bounds;
    private int[] pixels;

    private SurfaceDiff(boolean[] bitmask, Rect bounds, int[] pixels) {
        this.bitmask = bitmask;
        this.bounds = bounds;
        this.pixels = pixels;
    }

    private static native boolean findBounds(int[] original, Bitmap updatedSurf, DiffResult result);

    private static native boolean applyAndSwap(Bitmap dest, int boundTop, int boundBottom, int boundLeft, int boundRight, boolean[] bitmask, int[] pixels);

    public static SurfaceDiff Create(IntBuffer original, Bitmap updatedSurf) {
        long startDiff;
        if (DEBUG_DIFF) {
            Log.i(TAG, String.format("Surface size: %dx%d", updatedSurf.getWidth(), updatedSurf.getHeight()));
            startDiff = System.currentTimeMillis();
        }

        DiffResult diffResult = new DiffResult();
        if (!findBounds(original.array(), updatedSurf, diffResult))
            return null;

        if (DEBUG_DIFF)
            Log.i(TAG, String.format("SurfaceDiff time: %d", System.currentTimeMillis() - startDiff));

        Rect diffBounds = new Rect(diffResult.boundLeft, diffResult.boundTop, diffResult.boundRight, diffResult.boundBottom);

        return new SurfaceDiff(diffResult.bitmask, diffBounds, diffResult.pixels);
    }

    public void applyAndSwap(Bitmap destination) {
        applyAndSwap(destination, bounds.top, bounds.bottom, bounds.left, bounds.right, bitmask, pixels);
    }

    static {
        System.loadLibrary("surfaceDiff");
    }

    public static class DiffResult {
        public int boundLeft;
        public int boundRight;
        public int boundTop;
        public int boundBottom;
        public boolean[] bitmask;
        public int[] pixels;
    }

}




Java Source Code List

org.sketchertab.AboutDialog.java
org.sketchertab.BrushProperties.java
org.sketchertab.DocumentHistory.java
org.sketchertab.DrawController.java
org.sketchertab.FileHelper.java
org.sketchertab.HistoryItem.java
org.sketchertab.Sketcher.java
org.sketchertab.Style.java
org.sketchertab.SurfaceDiff.java
org.sketchertab.Surface.java
org.sketchertab.colorpicker.HuePicker.java
org.sketchertab.colorpicker.PickerDialog.java
org.sketchertab.colorpicker.Picker.java
org.sketchertab.colorpicker.PreviewView.java
org.sketchertab.colorpicker.SatValPicker.java
org.sketchertab.colorpicker.Utils.java
org.sketchertab.style.CirclesStyle.java
org.sketchertab.style.FurStyle.java
org.sketchertab.style.RibbonStyle.java
org.sketchertab.style.ShadedStyle.java
org.sketchertab.style.SimpleStyle.java
org.sketchertab.style.SketchyStyle.java
org.sketchertab.style.StyleBrush.java
org.sketchertab.style.StylesFactory.java
org.sketchertab.style.WebStyle.java