本文整理汇总了Java中java.awt.image.RenderedImage.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java RenderedImage.getWidth方法的具体用法?Java RenderedImage.getWidth怎么用?Java RenderedImage.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.RenderedImage
的用法示例。
在下文中一共展示了RenderedImage.getWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import java.awt.image.RenderedImage; //导入方法依赖的package包/类
@Override
public void write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param) throws IOException {
RenderedImage img = image.getRenderedImage();
if (stream == null) {
throw new IOException("Set an output first!");
}
if (param == null) {
param = getDefaultWriteParam();
}
Rectangle sourceRegion = new Rectangle(0, 0, img.getWidth(), img.getHeight());
if (param.getSourceRegion() != null) {
sourceRegion = sourceRegion.intersection(param.getSourceRegion());
}
Raster raster = img.getData(sourceRegion);
int quality = 85;
if (param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
quality = (int) (param.getCompressionQuality() * 100);
}
try {
stream.write(lib.encode(raster, quality).array());
} catch (TurboJpegException e) {
throw new IOException(e);
}
}
示例2: print
import java.awt.image.RenderedImage; //导入方法依赖的package包/类
final public int print(Graphics objPgraphics, PageFormat objPpageFormat, int intPpageIndex) {
if (this.objGimageAL != null && intPpageIndex < this.objGimageAL.size()) {
final RenderedImage imgLrendered = (RenderedImage) this.objGimageAL.get(intPpageIndex);
if (imgLrendered != null) {
final Graphics2D objLgraphics2D = (Graphics2D) objPgraphics;
objLgraphics2D.translate(objPpageFormat.getImageableX(), objPpageFormat.getImageableY());
final double dblLxRatio = objPpageFormat.getImageableWidth() / imgLrendered.getWidth();
final double dblLyRatio = objPpageFormat.getImageableHeight() / imgLrendered.getHeight();
objLgraphics2D.scale(dblLxRatio, dblLyRatio);
final AffineTransform objLaffineTransform =
AffineTransform.getTranslateInstance( objPpageFormat.getImageableX(),
objPpageFormat.getImageableY());
objLgraphics2D.drawRenderedImage(imgLrendered, objLaffineTransform);
return Printable.PAGE_EXISTS;
}
}
return Printable.NO_SUCH_PAGE;
}
示例3: write
import java.awt.image.RenderedImage; //导入方法依赖的package包/类
@Override
public void write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param) throws IOException {
RenderedImage img = image.getRenderedImage();
if (param == null) {
param = getDefaultWriteParam();
}
Rectangle sourceRegion = new Rectangle(0, 0, img.getWidth(), img.getHeight());
if (param.getSourceRegion() != null) {
sourceRegion = sourceRegion.intersection(param.getSourceRegion());
}
Raster raster = img.getData(sourceRegion);
opj_cparameters cparams = ((OpenJp2ImageWriteParam) param).toNativeParams(lib);
lib.encode(raster, this.wrapper, cparams);
}
示例4: getImageRegion
import java.awt.image.RenderedImage; //导入方法依赖的package包/类
/**
* Returns a rectangle in image coordinates that may be required
* in order to draw the given image into the given clipping region
* through a pair of AffineTransforms. In addition, horizontal and
* vertical padding factors for antialising and interpolation may
* be used.
*/
private static Rectangle getImageRegion(RenderedImage img,
Region compClip,
AffineTransform transform,
AffineTransform xform,
int padX, int padY) {
Rectangle imageRect =
new Rectangle(img.getMinX(), img.getMinY(),
img.getWidth(), img.getHeight());
Rectangle result = null;
try {
double p[] = new double[8];
p[0] = p[2] = compClip.getLoX();
p[4] = p[6] = compClip.getHiX();
p[1] = p[5] = compClip.getLoY();
p[3] = p[7] = compClip.getHiY();
// Inverse transform the output bounding rect
transform.inverseTransform(p, 0, p, 0, 4);
xform.inverseTransform(p, 0, p, 0, 4);
// Determine a bounding box for the inverse transformed region
double x0,x1,y0,y1;
x0 = x1 = p[0];
y0 = y1 = p[1];
for (int i = 2; i < 8; ) {
double pt = p[i++];
if (pt < x0) {
x0 = pt;
} else if (pt > x1) {
x1 = pt;
}
pt = p[i++];
if (pt < y0) {
y0 = pt;
} else if (pt > y1) {
y1 = pt;
}
}
// This is padding for anti-aliasing and such. It may
// be more than is needed.
int x = (int)x0 - padX;
int w = (int)(x1 - x0 + 2*padX);
int y = (int)y0 - padY;
int h = (int)(y1 - y0 + 2*padY);
Rectangle clipRect = new Rectangle(x,y,w,h);
result = clipRect.intersection(imageRect);
} catch (NoninvertibleTransformException nte) {
// Worst case bounds are the bounds of the image.
result = imageRect;
}
return result;
}