java.awt.image.renderable.RenderContext Java Examples

The following examples show how to use java.awt.image.renderable.RenderContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenderableImageOperation.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public RenderedImage createRendering(RenderContext renderContext) {
	Rectangle bounds = new Rectangle(0, 0, img.getWidth(),
			img.getHeight());
	Rectangle newBounds = renderContext.getTransform()
			.createTransformedShape(bounds).getBounds();

	BufferedImage bi = new BufferedImage(newBounds.width,
			newBounds.height, BufferedImage.TYPE_INT_ARGB);
	Graphics2D g = bi.createGraphics();
	g.translate(-newBounds.x, -newBounds.y);
	if (renderContext.getRenderingHints() != null)
		g.addRenderingHints(renderContext.getRenderingHints());
	g.drawRenderedImage(img, renderContext.getTransform());
	g.dispose();
	return bi;
}
 
Example #2
Source File: RenderableImageOperation.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public RenderedImage createScaledRendering(int w, int h,
		RenderingHints hints) {
	double sx = ((double) w) / ((double) img.getWidth());
	double sy = ((double) h) / ((double) img.getHeight());
	AffineTransform tx = AffineTransform.getScaleInstance(sx, sy);

	return createRendering(new RenderContext(tx));
}