use of java.awt.Graphics2D in project android_frameworks_base by ResurrectionRemix.
the class GcSnapshot method restoreLayer.
private void restoreLayer(Layer dstLayer) {
Graphics2D baseGfx = dstLayer.getImage().createGraphics();
// if the layer contains an original copy this means the flags
// didn't restrict drawing to the local layer and we need to make sure the
// layer bounds in the layer beneath didn't receive any drawing.
// so we use the originalCopy to erase the new drawings in there.
BufferedImage originalCopy = dstLayer.getOriginalCopy();
if (originalCopy != null) {
Graphics2D g = (Graphics2D) baseGfx.create();
g.setComposite(AlphaComposite.Src);
g.drawImage(originalCopy, mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, 0, 0, mLayerBounds.width(), mLayerBounds.height(), null);
g.dispose();
}
// now draw put the content of the local layer onto the layer,
// using the paint information
Graphics2D g = createCustomGraphics(baseGfx, mLocalLayerPaint, true, /*alphaOnly*/
0);
g.drawImage(mLocalLayer.getImage(), mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, null);
g.dispose();
baseGfx.dispose();
}
use of java.awt.Graphics2D in project android_frameworks_base by ResurrectionRemix.
the class ShadowPainter method createRectangularDropShadow.
/**
* Draws a rectangular drop shadow (of size {@link #SHADOW_SIZE} by {@link #SHADOW_SIZE} around
* the given source and returns a new image with both combined
*
* @param source the source image
*
* @return the source image with a drop shadow on the bottom and right
*/
@SuppressWarnings("UnusedDeclaration")
public static BufferedImage createRectangularDropShadow(BufferedImage source) {
int type = source.getType();
if (type == BufferedImage.TYPE_CUSTOM) {
type = BufferedImage.TYPE_INT_ARGB;
}
int width = source.getWidth();
int height = source.getHeight();
BufferedImage image;
image = new BufferedImage(width + SHADOW_SIZE, height + SHADOW_SIZE, type);
Graphics2D g = image.createGraphics();
g.drawImage(source, 0, 0, null);
drawRectangleShadow(image, 0, 0, width, height);
g.dispose();
return image;
}
use of java.awt.Graphics2D in project android_frameworks_base by ResurrectionRemix.
the class ShadowPainter method createSmallRectangularDropShadow.
/**
* Draws a small rectangular drop shadow (of size {@link #SMALL_SHADOW_SIZE} by {@link
* #SMALL_SHADOW_SIZE} around the given source and returns a new image with both combined
*
* @param source the source image
*
* @return the source image with a drop shadow on the bottom and right
*/
@SuppressWarnings("UnusedDeclaration")
public static BufferedImage createSmallRectangularDropShadow(BufferedImage source) {
int type = source.getType();
if (type == BufferedImage.TYPE_CUSTOM) {
type = BufferedImage.TYPE_INT_ARGB;
}
int width = source.getWidth();
int height = source.getHeight();
BufferedImage image;
image = new BufferedImage(width + SMALL_SHADOW_SIZE, height + SMALL_SHADOW_SIZE, type);
Graphics2D g = image.createGraphics();
g.drawImage(source, 0, 0, null);
drawSmallRectangleShadow(image, 0, 0, width, height);
g.dispose();
return image;
}
use of java.awt.Graphics2D in project android_frameworks_base by ResurrectionRemix.
the class ViewGroup_Delegate method getPathShadow.
private static BufferedImage getPathShadow(Outline outline, Canvas canvas, float elevation) {
Rect clipBounds = canvas.getClipBounds();
if (clipBounds.isEmpty()) {
return null;
}
BufferedImage image = new BufferedImage(clipBounds.width(), clipBounds.height(), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
graphics.draw(Path_Delegate.getDelegate(outline.mPath.mNativePath).getJavaShape());
graphics.dispose();
return ShadowPainter.createDropShadow(image, (int) elevation);
}
use of java.awt.Graphics2D in project android_frameworks_base by ResurrectionRemix.
the class Canvas_Delegate method drawBitmap.
private static void drawBitmap(long nativeCanvas, Bitmap_Delegate bitmap, long nativePaintOrZero, final int sleft, final int stop, final int sright, final int sbottom, final int dleft, final int dtop, final int dright, final int dbottom) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
if (canvasDelegate == null) {
return;
}
// get the paint, which could be null if the int is 0
Paint_Delegate paintDelegate = Paint_Delegate.getDelegate(nativePaintOrZero);
final BufferedImage image = getImageToDraw(bitmap, paintDelegate, sBoolOut);
draw(nativeCanvas, nativePaintOrZero, true, /*compositeOnly*/
sBoolOut[0], new GcSnapshot.Drawable() {
@Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
if (paint != null && paint.isFilterBitmap()) {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
}
//FIXME add support for canvas, screen and bitmap densities.
graphics.drawImage(image, dleft, dtop, dright, dbottom, sleft, stop, sright, sbottom, null);
}
});
}
Aggregations