本文整理了Java中java.awt.Graphics2D.drawRenderedImage()
方法的一些代码示例,展示了Graphics2D.drawRenderedImage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.drawRenderedImage()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:drawRenderedImage
暂无
代码示例来源:origin: jphp-group/jphp
@Signature
public PImage rotate(double angle)
{
double sin = Math.abs(Math.sin(Math.toRadians(angle))),
cos = Math.abs(Math.cos(Math.toRadians(angle)));
int w = image.getWidth(null), h = image.getHeight(null);
int neww = (int) Math.floor(w*cos + h*sin),
newh = (int) Math.floor(h*cos + w*sin);
BufferedImage bimg = new BufferedImage(neww, newh, image.getType());
Graphics2D g = bimg.createGraphics();
g.translate((neww-w)/2, (newh-h)/2);
g.rotate(Math.toRadians(angle), w/2, h/2);
g.drawRenderedImage(image, null);
g.dispose();
this.image = bimg;
return this;
}
代码示例来源:origin: stackoverflow.com
private BufferedImage scale(BufferedImage source,double ratio) {
int w = (int) (source.getWidth() * ratio);
int h = (int) (source.getHeight() * ratio);
BufferedImage bi = getCompatibleImage(w, h);
Graphics2D g2d = bi.createGraphics();
double xScale = (double) w / source.getWidth();
double yScale = (double) h / source.getHeight();
AffineTransform at = AffineTransform.getScaleInstance(xScale,yScale);
g2d.drawRenderedImage(source, at);
g2d.dispose();
return bi;
}
private BufferedImage getCompatibleImage(int w, int h) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
BufferedImage image = gc.createCompatibleImage(w, h);
return image;
}
代码示例来源:origin: org.apache.poi/poi
graphics.drawRenderedImage(img, at);
graphics.setClip(clipOld);
代码示例来源:origin: igniterealtime/Openfire
g.drawRenderedImage( avatar, scale );
Log.debug( "Resized image is {}x{}.", resizedAvatar.getWidth(), resizedAvatar.getHeight() );
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
g.translate((neww-w)/2, (newh-h)/2);
g.rotate(Math.toRadians(amount), w/2, h/2);
g.drawRenderedImage(src, null);
g.dispose();
origDst = dst;
代码示例来源:origin: apache/pdfbox
@Override
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
{
groupG2D.drawRenderedImage(img, xform);
alphaG2D.drawRenderedImage(img, xform);
}
代码示例来源:origin: geotools/geotools
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
delegate.drawRenderedImage(img, xform);
}
代码示例来源:origin: stackoverflow.com
/**
* scale image
*
* @param sbi image to scale
* @param imageType type of image
* @param dWidth width of destination image
* @param dHeight height of destination image
* @param fWidth x-factor for transformation / scaling
* @param fHeight y-factor for transformation / scaling
* @return scaled image
*/
public static BufferedImage scale(BufferedImage sbi, int imageType, int dWidth, int dHeight, double fWidth, double fHeight) {
BufferedImage dbi = null;
if(sbi != null) {
dbi = new BufferedImage(dWidth, dHeight, imageType);
Graphics2D g = dbi.createGraphics();
AffineTransform at = AffineTransform.getScaleInstance(fWidth, fHeight);
g.drawRenderedImage(sbi, at);
}
return dbi;
}
代码示例来源:origin: magefree/mage
private static BufferedImage rotateImage(BufferedImage image, double angle) {
double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
int width = image.getWidth(), height = image.getHeight();
int newWidth = (int) Math.floor(width * cos + height * sin), newHeight = (int) Math.floor(height * cos + width * sin);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
BufferedImage result = gc.createCompatibleImage(newWidth, newHeight, Transparency.TRANSLUCENT);
Graphics2D g = result.createGraphics();
g.translate((newWidth - width) / 2, (newHeight - height) / 2);
g.rotate(angle, width / 2, height / 2);
g.drawRenderedImage(image, null);
g.dispose();
return result;
}
代码示例来源:origin: stackoverflow.com
/**
* Rotates an image. Actually rotates a new copy of the image.
*
* @param img The image to be rotated
* @param angle The angle in degrees
* @return The rotated image
*/
public static Image rotate(Image img, double angle)
{
double sin = Math.abs(Math.sin(Math.toRadians(angle))),
cos = Math.abs(Math.cos(Math.toRadians(angle)));
int w = img.getWidth(null), h = img.getHeight(null);
int neww = (int) Math.floor(w*cos + h*sin),
newh = (int) Math.floor(h*cos + w*sin);
BufferedImage bimg = toBufferedImage(getEmptyImage(neww, newh));
Graphics2D g = bimg.createGraphics();
g.translate((neww-w)/2, (newh-h)/2);
g.rotate(Math.toRadians(angle), w/2, h/2);
g.drawRenderedImage(toBufferedImage(img), null);
g.dispose();
return toImage(bimg);
}
代码示例来源:origin: stackoverflow.com
public static BufferedImage rotate(BufferedImage image, double angle) {
double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
int w = image.getWidth(), h = image.getHeight();
int neww = (int)Math.floor(w*cos+h*sin), newh = (int) Math.floor(h * cos + w * sin);
GraphicsConfiguration gc = getDefaultConfiguration();
BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.TRANSLUCENT);
Graphics2D g = result.createGraphics();
g.translate((neww - w) / 2, (newh - h) / 2);
g.rotate(angle, w / 2, h / 2);
g.drawRenderedImage(image, null);
g.dispose();
return result;
}
private static GraphicsConfiguration getDefaultConfiguration() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.getDefaultConfiguration();
}
代码示例来源:origin: mapsforge/mapsforge
@Override
public void drawBitmap(Bitmap bitmap, Matrix matrix) {
this.graphics2D.drawRenderedImage(AwtGraphicFactory.getBitmap(bitmap),
AwtGraphicFactory.getAffineTransform(matrix));
}
代码示例来源:origin: haraldk/TwelveMonkeys
try {
g.setComposite(AlphaComposite.Src);
g.drawRenderedImage(pOriginal, IDENTITY_TRANSFORM);
代码示例来源:origin: geotools/geotools
private BufferedImage blend(BufferedImage src, BufferedImage dst) {
BufferedImage blend = new BufferedImage(src.getWidth(), dst.getWidth(), src.getType());
Graphics2D graphics = (Graphics2D) blend.getGraphics();
graphics.drawRenderedImage(src, new AffineTransform());
graphics.setComposite(composite);
graphics.drawRenderedImage(dst, new AffineTransform());
graphics.dispose();
return blend;
}
代码示例来源:origin: geotools/geotools
private BufferedImage convertImage(BufferedImage src, int imageType) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), imageType);
Graphics2D graphics = (Graphics2D) result.getGraphics();
graphics.drawRenderedImage(src, new AffineTransform());
graphics.dispose();
return result;
}
}
代码示例来源:origin: geotools/geotools
graphics.setRenderingHint(
RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.drawRenderedImage(image, markAT);
} finally {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolation);
代码示例来源:origin: mapsforge/mapsforge
(int) Math.round(tileRect.right - (int) tileRect.left), (int) Math.round(tileRect.bottom) - (int) Math.round(tileRect.top) // subtract in after rounding to get same error as on neighbor tile
);
this.graphics2D.drawRenderedImage(bufferedImage, transform);
this.graphics2D.setClip(null);
代码示例来源:origin: mapsforge/mapsforge
@Override
public void drawBitmap(Bitmap bitmap, Matrix matrix, Filter filter) {
this.graphics2D.drawRenderedImage(applyFilter(AwtGraphicFactory.getBitmap(bitmap), filter), AwtGraphicFactory.getAffineTransform(matrix));
}
代码示例来源:origin: nodebox/nodebox
public void draw(Graphics2D g) {
setupTransform(g);
// You can only position an image using an affine transformation.
// We use the transformation to translate the image to the specified
// position, and scale it according to the given width and height.
Transform imageTrans = new Transform();
// Move to the image position. Convert x, y, which are centered coordinates,
// to "real" coordinates.
double factor = getScaleFactor();
double finalWidth = image.getWidth() * factor;
double finalHeight = image.getHeight() * factor;
imageTrans.translate(x - finalWidth / 2, y - finalHeight / 2);
// Scaling only applies to image that have their desired width and/or height set.
// However, getScaleFactor return 1 if height/width are not set, in effect negating
// the effect of the scale.
imageTrans.scale(getScaleFactor());
double a = clamp(alpha);
Composite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) a);
Composite oldComposite = g.getComposite();
g.setComposite(composite);
g.drawRenderedImage(image, imageTrans.getAffineTransform());
g.setComposite(oldComposite);
restoreTransform(g);
}
代码示例来源:origin: geotools/geotools
translate = true;
graphics.drawRenderedImage(applyImage, transform);
int numBands = composedImage.getSampleModel().getNumBands();
GridSampleDimension[] sd = new GridSampleDimension[numBands];
内容来源于网络,如有侵权,请联系作者删除!