Search in sources :

Example 1 with Graphics

use of net.rim.device.api.ui.Graphics in project Samples-for-Java by blackberry.

the class BitmapFactory method addStateIndicator.

public static Bitmap addStateIndicator(Bitmap unfocused_bmp, int color) {
    int width = unfocused_bmp.getWidth();
    int height = unfocused_bmp.getHeight();
    int[] argb = new int[width * height];
    unfocused_bmp.getARGB(argb, 0, width, 0, 0, width, height);
    Bitmap new_bmp = new Bitmap(width, height);
    new_bmp.setARGB(argb, 0, width, 0, 0, width, height);
    Graphics pen = Graphics.create(new_bmp);
    pen.setGlobalAlpha(Constants.TRANSPARENCY);
    pen.setColor(color);
    pen.fillRect(0, 0, width, height);
    return new_bmp;
}
Also used : Graphics(net.rim.device.api.ui.Graphics) Bitmap(net.rim.device.api.system.Bitmap)

Example 2 with Graphics

use of net.rim.device.api.ui.Graphics in project Samples-for-Java by blackberry.

the class BitmapFactory method getBackground.

public static Bitmap getBackground(int width, int height) {
    Bitmap bg = new Bitmap(width, height);
    Graphics pen = Graphics.create(bg);
    int x1 = width / 3;
    int x2 = x1 * 2;
    int y1 = height / 3;
    int y2 = y1 * 2;
    pen.setColor(Color.BLACK);
    pen.drawLine(x1, 0, x1, height);
    pen.drawLine(x2, 0, x2, height);
    pen.drawLine(0, y1, width, y1);
    pen.drawLine(0, y2, width, y2);
    return bg;
}
Also used : Graphics(net.rim.device.api.ui.Graphics) Bitmap(net.rim.device.api.system.Bitmap)

Example 3 with Graphics

use of net.rim.device.api.ui.Graphics in project Samples-for-Java by blackberry.

the class ImageManipulator method scaleInto.

/**
	 * Scale the internal bitmap into the provided Bitmap. Alternate
	 * implementation of method from 5.0 Bitmap API.
	 * 
	 * <pre>
	 * {@link http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/Bitmap.html}
	 * </pre>
	 * 
	 * 
	 * @param srcLeft
	 *            X coordinate of the top left corner of the area to be copied
	 *            from the source bitmap.
	 * @param srcTop
	 *            Y coordinate of the top left corner of the area to be copied
	 *            from the source bitmap.
	 * @param srcWidth
	 *            Width of the area to be copied from the source bitmap.
	 * @param srcHeight
	 *            Height of the area to be copied from the source bitmap.
	 * @param dst
	 *            the {@link Bitmap} to paint on, scale comes from this.
	 * @param dstLeft
	 *            X coordinate of the top left corner of the area to be copied
	 *            to the destination bitmap.
	 * @param dstTop
	 *            Y coordinate of the top left corner of the area to be copied
	 *            to the destination bitmap.
	 * @param dstWidth
	 *            Width of the area to be copied from the source bitmap.
	 * @param dstHeight
	 *            Height of the area to be copied to the destination bitmap.
	 * @param filterType
	 *            has no real effect, but must be one of:
	 *            <ul>
	 *            <li>{@link #FILTER_LANCZOS}</li>
	 *            <li>{@link #FILTER_BOX}</li>
	 *            <li>{@link #FILTER_BILINEAR}</li>
	 *            </ul>
	 * @throws NullPointerException
	 *             Thrown if 'dst' is null.
	 * @throws IllegalArgumentException
	 *             Thrown if the destination bitmap is read-only.
	 * @throws IllegalArgumentException
	 *             Thrown if illegal filter type is specified.
	 * @since 1.1
	 */
public void scaleInto(int srcLeft, int srcTop, int srcWidth, int srcHeight, Bitmap dst, int dstLeft, int dstTop, int dstWidth, int dstHeight, int filterType) {
    // Maintain same interface as 5.0 API
    if (dst == null) {
        throw new NullPointerException("Destination bitmap can not be set to NULL");
    }
    if (!dst.isWritable()) {
        throw new IllegalArgumentException("Destination bitmap should not be read-only");
    }
    if (filterType < 0 || filterType > 2) {
        throw new IllegalArgumentException("Invalid filter type");
    }
    // make sure we're starting with no rotation.
    resetTransform();
    // set the region to be drawn on
    bitmapXPts = new int[] { dstLeft, dstLeft, dstLeft + dstWidth, dstLeft + dstWidth };
    bitmapYPts = new int[] { dstTop, dstTop + dstHeight, dstTop + dstHeight, dstTop };
    // Calculate the new scale based on the region sizes
    resultantScaleX = Fixed32.div(Fixed32.toFP(dstWidth), Fixed32.toFP(srcWidth));
    resultantScaleY = Fixed32.div(Fixed32.toFP(dstHeight), Fixed32.toFP(srcHeight));
    Graphics graphics = new Graphics(dst);
    paintTransformedBitmap(graphics, dstLeft - srcLeft, dstTop - srcTop);
}
Also used : Graphics(net.rim.device.api.ui.Graphics)

Example 4 with Graphics

use of net.rim.device.api.ui.Graphics in project Samples-for-Java by blackberry.

the class ImageManipulator method transformAndPaintBitmap.

/**
	 * Apply the transformation, paint to a new {@link Bitmap} and return it
	 * 
	 * @return The transformed {@link Bitmap} of the required size to display
	 *         the entire transformed (rotated, scaled) image, with an alpha
	 *         channel so that the space around the bitmap is transparent.
	 */
public Bitmap transformAndPaintBitmap() {
    applyTransformation();
    // create the new bitmap
    Bitmap transformedBitmap = new Bitmap(bitmap.getType(), transformedRegion.width, transformedRegion.height);
    transformedBitmap.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
    Graphics graphics = new Graphics(transformedBitmap);
    paintTransformedBitmap(graphics);
    return transformedBitmap;
}
Also used : Graphics(net.rim.device.api.ui.Graphics) Bitmap(net.rim.device.api.system.Bitmap)

Aggregations

Graphics (net.rim.device.api.ui.Graphics)4 Bitmap (net.rim.device.api.system.Bitmap)3