Android Open Source - scanNedit Rotate






From Project

Back to project page scanNedit.

License

The source code is released under:

MIT License

If you think the Android project scanNedit 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

/*
 * Copyright (C) 2011 Google Inc.//www.jav a 2  s.  c  o m
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.googlecode.leptonica.android;

/**
 * @author alanv@google.com (Alan Viverette)
 */
public class Rotate {
    static {
        System.loadLibrary("lept");
    }

    // Rotation default

    /** Default rotation quality is high. */
    public static final boolean ROTATE_QUALITY = true;

    /**
     * Performs rotation using the default parameters.
     *
     * @param pixs The source pix.
     * @param degrees The number of degrees to rotate; clockwise is positive.
     * @return the rotated source image
     */
    public static Pix rotate(Pix pixs, float degrees) {
        return rotate(pixs, degrees, false);
    }

    /**
     * Performs basic image rotation about the center.
     * <p>
     * Notes:
     * <ol>
     * <li>Rotation is about the center of the image.
     * <li>For very small rotations, just return a clone.
     * <li>Rotation brings either white or black pixels in from outside the
     * image.
     * <li>Above 20 degrees, if rotation by shear is requested, we rotate by
     * sampling.
     * <li>Colormaps are removed for rotation by area map and shear.
     * <li>The dest can be expanded so that no image pixels are lost. To invoke
     * expansion, input the original width and height. For repeated rotation,
     * use of the original width and height allows the expansion to stop at the
     * maximum required size, which is a square with side = sqrt(w*w + h*h).
     * </ol>
     *
     * @param pixs The source pix.
     * @param degrees The number of degrees to rotate; clockwise is positive.
     * @param quality Whether to use high-quality rotation.
     * @return the rotated source image
     */
    public static Pix rotate(Pix pixs, float degrees, boolean quality) {
        if (pixs == null)
            throw new IllegalArgumentException("Source pix must be non-null");

        int nativePix = nativeRotate(pixs.mNativePix, degrees, quality);

        if (nativePix == 0)
            return null;

        return new Pix(nativePix);
    }

    // ***************
    // * NATIVE CODE *
    // ***************

    private static native int nativeRotate(int nativePix, float degrees, boolean quality);
}




Java Source Code List

com.googlecode.leptonica.android.AdaptiveMap.java
com.googlecode.leptonica.android.Binarize.java
com.googlecode.leptonica.android.Box.java
com.googlecode.leptonica.android.Constants.java
com.googlecode.leptonica.android.Convert.java
com.googlecode.leptonica.android.Enhance.java
com.googlecode.leptonica.android.JpegIO.java
com.googlecode.leptonica.android.Pix.java
com.googlecode.leptonica.android.Pixa.java
com.googlecode.leptonica.android.ReadFile.java
com.googlecode.leptonica.android.Rotate.java
com.googlecode.leptonica.android.Scale.java
com.googlecode.leptonica.android.Skew.java
com.googlecode.leptonica.android.WriteFile.java
com.googlecode.tesseract.android.TessBaseAPI.java
com.markupartist.android.widget.ActionBar.java
com.markupartist.android.widget.ActionBar_three.java
com.markupartist.android.widget.ActionBar_two.java
com.markupartist.android.widget.ScrollingTextView.java
com.me.android.scanNedit.CameraActivity.java
com.me.android.scanNedit.CropOptionAdapter.java
com.me.android.scanNedit.CropOption.java
com.me.android.scanNedit.FileCache.java
com.me.android.scanNedit.GalleryActivity.java
com.me.android.scanNedit.HelpActivity.java
com.me.android.scanNedit.ImageLoader.java
com.me.android.scanNedit.LazyAdapter.java
com.me.android.scanNedit.MemoryCache.java
com.me.android.scanNedit.Picture.java
com.me.android.scanNedit.SampleActivity.java
com.me.android.scanNedit.StartActivity.java
com.me.android.scanNedit.TessBaseAPITest.java
com.me.android.scanNedit.Utils.java
com.me.android.scanNedit.XMLParser.java