Java Rectangle getRectLE(byte[] data, int i)

Here you can find the source of getRectLE(byte[] data, int i)

Description

Gets a rectangle out of an array of bytes.

License

Mozilla Public License

Parameter

Parameter Description
data The array of bytes to copy from.
i The index of the first byte of the rectangle.

Return

The rectangle at index i.

Declaration

public static java.awt.Rectangle getRectLE(byte[] data, int i) 

Method Source Code

//package com.java2s;
/*//w  w  w . j ava 2s  . c  om
 * Copyright © 2010-2011 Rebecca G. Bettencourt / Kreative Software
 * <p>
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * <a href="http://www.mozilla.org/MPL/">http://www.mozilla.org/MPL/</a>
 * <p>
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * <p>
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU Lesser General Public License (the "LGPL License"), in which
 * case the provisions of LGPL License are applicable instead of those
 * above. If you wish to allow use of your version of this file only
 * under the terms of the LGPL License and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting the provisions above and replace them with the notice and
 * other provisions required by the LGPL License. If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the LGPL License.
 * @since KSFL 1.0
 * @author Rebecca G. Bettencourt, Kreative Software
 */

public class Main {
    /**
     * Gets a rectangle out of an array of bytes.
     * A rectangle is defined by four 16-bit little-endian integers,
     * representing the top, left, bottom, and right.
     * @param data The array of bytes to copy from.
     * @param i The index of the first byte of the rectangle.
     * @return The rectangle at index <code>i</code>.
     */
    public static java.awt.Rectangle getRectLE(byte[] data, int i) {
        return new java.awt.Rectangle(getShortLE(data, i + 2), getShortLE(
                data, i + 0), getShortLE(data, i + 6)
                - getShortLE(data, i + 2), getShortLE(data, i + 4)
                - getShortLE(data, i + 0));
    }

    /**
     * Gets a 16-bit little-endian integer out of an array of bytes.
     * @param data The array of bytes to copy from.
     * @param i The index of the first byte of the integer.
     * @return The 16-bit little-endian integer at index <code>i</code>.
     */
    public static short getShortLE(byte[] data, int i) {
        return (short) (((data[i + 0] & 0xFF) << 0) | ((data[i + 1] & 0xFF) << 8));
    }
}

Related

  1. getAbsoluteRectangle(Rectangle rect)
  2. getFrameOrientations(Rectangle parent)
  3. getMaximalRectangle(Rectangle r1, Rectangle r2)
  4. getRect(byte[] data, int i)
  5. getRectangleProperty(Map p, Object key, Rectangle defaultValue)
  6. getSubArea(Shape retangulo, int divisorx, int divisory, int offsetx, int offsety)
  7. inflateRectangle(Rectangle r, int x, int y)
  8. interpolate(Rectangle r1, Rectangle r2, float f)
  9. mergeRects(Set prev, Set current)