本文整理匯總了Java中java.awt.image.RenderedImage.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java RenderedImage.getHeight方法的具體用法?Java RenderedImage.getHeight怎麽用?Java RenderedImage.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.image.RenderedImage
的用法示例。
在下文中一共展示了RenderedImage.getHeight方法的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;
}