本文整理汇总了Java中java.awt.image.BufferedImage.OPAQUE属性的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.OPAQUE属性的具体用法?Java BufferedImage.OPAQUE怎么用?Java BufferedImage.OPAQUE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.OPAQUE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImage
public static BufferedImage createImage(int shapesPerImage, BufferedImage categoryImg, ImageSize size,
Random rand) {
BufferedImage img = new BufferedImage(size.getWidth(), size.getHeight(), BufferedImage.OPAQUE);
Graphics2D graphics = img.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
switchColor(graphics, rand);
graphics.fillRect(0, 0, size.getWidth(), size.getHeight());
for (int i = 0; i < shapesPerImage; i++) {
switch (rand.nextInt(4)) {
case 0: makeRectangle(graphics, size, rand); break;
case 1: makeLine(graphics, size, rand); break;
case 2: makeOval(graphics, size, rand); break;
case 3: makeText(graphics, size, rand); break;
}
}
if (categoryImg != null) {
drawCategoryImage(graphics, size, categoryImg, rand);
}
graphics.dispose();
return img;
}
示例2: isTransparent
public static boolean isTransparent(BufferedImage img) {
return img.getTransparency() != BufferedImage.OPAQUE;
}
示例3: zoom
/**
* Filters a portion of the source image.
*
* @param dstR the destination tile to calculate
* @param dst_fr the bounds of the whole destination image
* @param srcI the source image
* @param filter the filter to apply
* @throws ClassCastException if <code>srcI</code> does not store its data
* in a {@link DataBufferInt}
*/
public static void zoom(
WritableRaster dstR,
Rectangle dst_fr,
BufferedImage srcI,
final Filter filter)
{
final int dst_data[] = ((DataBufferInt) dstR.getDataBuffer()).getData();
final int src_type;
if (srcI.getTransparency() == BufferedImage.OPAQUE) {
src_type = OPAQUE;
}
else if (srcI.isAlphaPremultiplied()) {
src_type = TRANS_PREMULT;
}
else {
src_type = TRANS_UNPREMULT;
}
final int dx0 = dstR.getMinX();
final int dy0 = dstR.getMinY();
final int dx1 = dx0 + dstR.getWidth() - 1;
final int dy1 = dy0 + dstR.getHeight() - 1;
final int dw = dstR.getWidth();
final int dh = dstR.getHeight();
final int dstWidth = dst_fr.width;
final int dstHeight = dst_fr.height;
final int srcWidth = srcI.getWidth();
final int srcHeight = srcI.getHeight();
// We want dstX0 * xscale = srcX0, except when that would make
// xscale = 0; similarly for yscale.
final float xscale =
srcWidth == 1 ? dstWidth : (float)(dstWidth-1) / (srcWidth-1);
final float yscale =
srcHeight == 1 ? dstHeight : (float)(dstHeight-1) / (srcHeight-1);
final float fwidth = filter.getSamplingRadius();
final int sx0 = Math.max(0, (int) Math.floor((dx0-fwidth)/xscale));
final int sy0 = Math.max(0, (int) Math.floor((dy0-fwidth)/yscale));
final int sx1 = Math.min(srcWidth-1, (int) Math.ceil((dx1+fwidth)/xscale));
final int sy1 = Math.min(srcHeight-1, (int) Math.ceil((dy1+fwidth)/yscale));
final int sw = sx1 - sx0 + 1;
final int sh = sy1 - sy0 + 1;
final int src_data[] =
((DataBufferInt) srcI.getRaster().getDataBuffer()).getData();
resample(
src_data, false,
sx0, sy0, sx1, sy1, sw, sh, src_type, srcWidth, srcHeight,
dst_data, dx0, dy0, dx1, dy1, dw, dh, dstWidth, dstHeight,
xscale, yscale, filter
);
}