當前位置: 首頁>>代碼示例>>Java>>正文


Java RenderedImage.getWidth方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:dbmdz,項目名稱:imageio-jnr,代碼行數:25,代碼來源:TurboJpegImageWriter.java

示例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;
	}
 
開發者ID:jugglemaster,項目名稱:JuggleMasterPro,代碼行數:26,代碼來源:ImagesPrinter.java

示例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);
}
 
開發者ID:dbmdz,項目名稱:imageio-jnr,代碼行數:15,代碼來源:OpenJp2ImageWriter.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:65,代碼來源:SunGraphics2D.java


注:本文中的java.awt.image.RenderedImage.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。