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


Java IIOImage.getRenderedImage方法代碼示例

本文整理匯總了Java中javax.imageio.IIOImage.getRenderedImage方法的典型用法代碼示例。如果您正苦於以下問題:Java IIOImage.getRenderedImage方法的具體用法?Java IIOImage.getRenderedImage怎麽用?Java IIOImage.getRenderedImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.IIOImage的用法示例。


在下文中一共展示了IIOImage.getRenderedImage方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import javax.imageio.IIOImage; //導入方法依賴的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: getScaledInstance

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * Convenience method that returns a scaled instance of the provided
 * {@code IIOImage}.
 *
 * @param iioSource the original image to be scaled
 * @param scale the desired scale
 * @return a scaled version of the original {@code IIOImage}
 */
public static IIOImage getScaledInstance(IIOImage iioSource, float scale) {
    if (!(iioSource.getRenderedImage() instanceof BufferedImage)) {
        throw new IllegalArgumentException("RenderedImage in IIOImage must be BufferedImage");
    }

    if (Math.abs(scale - 1.0) < 0.001) {
        return iioSource;
    }

    BufferedImage source = (BufferedImage) iioSource.getRenderedImage();
    BufferedImage target = getScaledInstance(source, (int) (scale * source.getWidth()), (int) (scale * source.getHeight()));
    return new IIOImage(target, null, null);
}
 
開發者ID:RaiMan,項目名稱:Sikulix2tesseract,代碼行數:22,代碼來源:ImageHelper.java

示例3: write

import javax.imageio.IIOImage; //導入方法依賴的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: write

import javax.imageio.IIOImage; //導入方法依賴的package包/類
@Override
public void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ) throws IOException {
  if ( param == null ) {
    param = getDefaultWriteParam();
  }

  WebPWriteParam writeParam = (WebPWriteParam) param;

  ImageOutputStream output = ( ImageOutputStream ) getOutput();
  RenderedImage ri = image.getRenderedImage();

  byte[] encodedData = WebP.encode(writeParam, ri);
  output.write( encodedData );
}
 
開發者ID:LeeKyoungIl,項目名稱:webp-java-sample,代碼行數:15,代碼來源:WebPWriter.java

示例5: BMPFileHeader

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
   * Creates the header from an output stream, which is not closed.
   *
   * @param out - the image output stream
   * @param im - the image
   * @throws IOException if an I/O error occured.
   */
public BMPFileHeader(ImageOutputStream out, IIOImage im) throws IOException
{
  RenderedImage img = im.getRenderedImage();
  int w = img.getWidth();
  int h = img.getHeight();

  bfOffBits = SIZE + BITMAPINFOHEADER_SIZE;
  bfSize = ((w * h) * 3) + ((4 - ((w * 3) % 4)) * h) + bfOffBits;

  write(out);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:BMPFileHeader.java

示例6: write

import javax.imageio.IIOImage; //導入方法依賴的package包/類
public void write (IIOMetadata streamMetadata, IIOImage i, ImageWriteParam param)
throws IOException
{
  RenderedImage image = i.getRenderedImage();
  Raster ras = image.getData();
  int width = ras.getWidth();
  int height = ras.getHeight();
  ColorModel model = image.getColorModel();
  int[] pixels = CairoGraphics2D.findSimpleIntegerArray (image.getColorModel(), ras);

  if (pixels == null)
    {
      BufferedImage img;
      if(model != null && model.hasAlpha())
        img = CairoSurface.getBufferedImage(width, height);
      img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      int[] pix = new int[4];
      for (int y = 0; y < height; ++y)
        for (int x = 0; x < width; ++x)
          img.setRGB(x, y, model.getRGB(ras.getPixel(x, y, pix)));
      pixels = CairoGraphics2D.findSimpleIntegerArray (img.getColorModel(),
                                                     img.getRaster());
      model = img.getColorModel();
    }

  Thread workerThread = new Thread(this, "GdkPixbufWriter");
  workerThread.start();
  processImageStarted(1);
  synchronized(pixbufLock)
    {
      streamImage(pixels, this.ext, width, height, model.hasAlpha(),
                  this);
    }
  synchronized(data)
    {
      data.add(DATADONE);
      data.notifyAll();
    }

  while (workerThread.isAlive())
    {
      try
        {
          workerThread.join();
        }
      catch (InterruptedException ioe)
        {
          // Ignored.
        }
    }

  if (exception != null)
    throw exception;

  processImageComplete();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:57,代碼來源:GdkPixbufDecoder.java

示例7: BMPInfoHeader

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * Creates the info header from an output stream, which is not closed.
 *
 * @param out - the image output stream
 * @param im - the image
 * @param param - the image write param.
 * @throws IOException if an I/O error occured.
 */
public BMPInfoHeader(ImageOutputStream out, IIOImage im, ImageWriteParam param) throws IOException
{
  RenderedImage img = im.getRenderedImage();
  ColorModel cMod = img.getColorModel();

  biSize = SIZE;
  biWidth = img.getWidth();
  biHeight = img.getHeight();
  biPlanes = 1;

  if (param != null && param.canWriteCompressed())
    {
      String compType = param.getCompressionType();
      if (compType.equals("BI_RLE8"))
        {
          biCompression = BI_RLE8;
          biBitCount = 8;
        }
      else if (compType.equals("BI_RLE4"))
        {
          biCompression = BI_RLE4;
          biBitCount = 4;
        }
      else
        {
          biCompression = BI_RGB;
          biBitCount = (short) cMod.getPixelSize();
        }
    }
  else
    {
      biBitCount = (short) cMod.getPixelSize();
      biCompression = BI_RGB;
    }

  biXPelsPerMeter = 0x0;
  biYPelsPerMeter = 0x0;
  biClrUsed = 0;
  biClrImportant = 0;
  biSizeImage = ((biWidth * biHeight) * 3)
                + ((4 - ((biWidth * 3) % 4)) * biHeight);
  out.write(intToDWord(biSize));
  out.write(intToDWord(biWidth));
  out.write(intToDWord(biHeight));
  out.write(intToWord(biPlanes));
  out.write(intToWord(biBitCount));
  out.write(intToDWord(biCompression));
  out.write(intToDWord(biSizeImage));
  out.write(intToDWord(biXPelsPerMeter));
  out.write(intToDWord(biYPelsPerMeter));
  out.write(intToDWord(biClrUsed));
  out.write(intToDWord(biClrImportant));
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:62,代碼來源:BMPInfoHeader.java

示例8: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or
 * null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  byte rgb[] = new byte[3];
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];

          rgb[0] = (byte) (value & 0xFF);
          rgb[1] = (byte) ((value >> 8) & 0xFF);
          rgb[2] = (byte) ((value >> 16) & 0xFF);
          o.write(rgb);
          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:59,代碼來源:EncodeRGB24.java

示例9: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or
 * null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  ByteBuffer buf = ByteBuffer.allocate(size);
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];
          buf.put((byte) (value & 0xFF));

          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }

      buf.flip();
      o.write(uncompress(infoHeader.biWidth, infoHeader.biHeight, buf));
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
  }
 
開發者ID:vilie,項目名稱:javify,代碼行數:59,代碼來源:EncodeRLE8.java

示例10: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or
 * null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  byte rgb[] = new byte[2];
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];

          rgb[0] = (byte) (value & 0xFF);
          rgb[1] = (byte) (value >> 8 & 0xFF);

          o.write(rgb);
          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:59,代碼來源:EncodeRGB16.java

示例11: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or
 * null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  byte rgb[] = new byte[1];
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];

          rgb[0] = (byte) (value & 0xFF);

          o.write(rgb);
          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:58,代碼來源:EncodeRGB4.java

示例12: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or
 * null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  byte rgb[] = new byte[1];
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];

          rgb[0] = (byte) (value & 0xFF);
          o.write(rgb);
          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:57,代碼來源:EncodeRGB8.java

示例13: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or
 * null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  ByteBuffer buf = ByteBuffer.allocate(size);
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];
          buf.put((byte) (value & 0xFF));

          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }

      buf.flip();
      o.write(uncompress(infoHeader.biWidth, infoHeader.biHeight, buf));
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:59,代碼來源:EncodeRLE4.java

示例14: encode

import javax.imageio.IIOImage; //導入方法依賴的package包/類
/**
 * The image encoder.
 *
 * @param o - the image output stream
 * @param streamMetadata - metadata associated with this stream, or null
 * @param image - an IIOImage containing image data.
 * @param param - image writing parameters, or null
 * @exception IOException if a write error occurs
 */
public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
                   IIOImage image, ImageWriteParam param) throws IOException
{
  int size;
  int value;
  int j;
  int rowCount;
  int rowIndex;
  int lastRowIndex;
  int[] bitmap;
  byte rgb[] = new byte[4];
  size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
  rowCount = 1;
  rowIndex = size - infoHeader.biWidth;
  lastRowIndex = rowIndex;
  try
    {
      bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
      PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
                                         0, 0, infoHeader.biWidth,
                                         infoHeader.biHeight, bitmap, 0,
                                         infoHeader.biWidth);
      pg.grabPixels();

      for (j = 0; j < size; j++)
        {
          value = bitmap[rowIndex];

          rgb[0] = (byte) (value & 0xFF);
          rgb[1] = (byte) ((value >> 8) & 0xFF);
          rgb[2] = (byte) ((value >> 16) & 0xFF);
          rgb[3] = (byte) ((value >> 24) & 0xFF);
          o.write(rgb);
          if (rowCount == infoHeader.biWidth)
            {
              rowCount = 1;
              rowIndex = lastRowIndex - infoHeader.biWidth;
              lastRowIndex = rowIndex;
            }
          else
            rowCount++;
          rowIndex++;
        }
    }
  catch (Exception wb)
    {
      wb.printStackTrace();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:59,代碼來源:EncodeRGB32.java


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