⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkpixbufdecoder.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      }          throw new IllegalArgumentException("unknown extension '" + str + "'");  }  private static GdkPixbufReaderSpi readerSpi;  private static GdkPixbufWriterSpi writerSpi;  public static synchronized GdkPixbufReaderSpi getReaderSpi()  {    if (readerSpi == null)      readerSpi = new GdkPixbufReaderSpi();    return readerSpi;  }  public static synchronized GdkPixbufWriterSpi getWriterSpi()  {    if (writerSpi == null)      writerSpi = new GdkPixbufWriterSpi();    return writerSpi;  }  public static void registerSpis(IIORegistry reg)   {    reg.registerServiceProvider(getReaderSpi(), ImageReaderSpi.class);    reg.registerServiceProvider(getWriterSpi(), ImageWriterSpi.class);  }  public static class GdkPixbufWriterSpi extends ImageWriterSpi  {    public GdkPixbufWriterSpi()     {            super("GdkPixbuf", "2.x",            GdkPixbufDecoder.getFormatNames(true),             GdkPixbufDecoder.getFormatExtensions(true),             GdkPixbufDecoder.getFormatMimeTypes(true),            "gnu.java.awt.peer.gtk.GdkPixbufDecoder$GdkPixbufWriter",            new Class[] { ImageOutputStream.class },            new String[] { "gnu.java.awt.peer.gtk.GdkPixbufDecoder$GdkPixbufReaderSpi" },            false, null, null, null, null,            false, null, null, null, null);    }    public boolean canEncodeImage(ImageTypeSpecifier ts)    {      return true;    }    public ImageWriter createWriterInstance(Object ext)    {      return new GdkPixbufWriter(this, ext);    }    public String getDescription(java.util.Locale loc)    {      return "GdkPixbuf Writer SPI";    }  }  public static class GdkPixbufReaderSpi extends ImageReaderSpi  {    public GdkPixbufReaderSpi()     {       super("GdkPixbuf", "2.x",            GdkPixbufDecoder.getFormatNames(false),             GdkPixbufDecoder.getFormatExtensions(false),             GdkPixbufDecoder.getFormatMimeTypes(false),            "gnu.java.awt.peer.gtk.GdkPixbufDecoder$GdkPixbufReader",            new Class[] { ImageInputStream.class },            new String[] { "gnu.java.awt.peer.gtk.GdkPixbufDecoder$GdkPixbufWriterSpi" },            false, null, null, null, null,            false, null, null, null, null);    }    public boolean canDecodeInput(Object obj)     {       return true;     }    public ImageReader createReaderInstance(Object ext)    {      return new GdkPixbufReader(this, ext);    }    public String getDescription(Locale loc)    {      return "GdkPixbuf Reader SPI";    }  }  private static class GdkPixbufWriter    extends ImageWriter  {    String ext;    public GdkPixbufWriter(GdkPixbufWriterSpi ownerSpi, Object ext)    {      super(ownerSpi);      this.ext = findFormatName(ext, true);    }    public IIOMetadata convertImageMetadata (IIOMetadata inData,                                             ImageTypeSpecifier imageType,                                             ImageWriteParam param)    {      return null;    }    public IIOMetadata convertStreamMetadata (IIOMetadata inData,                                              ImageWriteParam param)    {      return null;    }    public IIOMetadata getDefaultImageMetadata (ImageTypeSpecifier imageType,                                                 ImageWriteParam param)    {      return null;    }    public IIOMetadata getDefaultStreamMetadata (ImageWriteParam param)    {      return null;    }  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 = GdkGraphics2D.findSimpleIntegerArray (image.getColorModel(), ras);            if (pixels == null)        {          BufferedImage img = new BufferedImage(width, height,                                                 (model != null && model.hasAlpha() ?                                                  BufferedImage.TYPE_INT_ARGB                                                 : 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 = GdkGraphics2D.findSimpleIntegerArray (img.getColorModel(),                                                          img.getRaster());          model = img.getColorModel();        }      processImageStarted(1);      streamImage(pixels, this.ext, width, height, model.hasAlpha(),                   (DataOutput) this.getOutput());      processImageComplete();    }      }  private static class GdkPixbufReader     extends ImageReader    implements ImageConsumer  {    // ImageConsumer parts    GdkPixbufDecoder dec;    BufferedImage bufferedImage;    ColorModel defaultModel;    int width;    int height;    String ext;        public GdkPixbufReader(GdkPixbufReaderSpi ownerSpi, Object ext)    {      super(ownerSpi);      this.ext = findFormatName(ext, false);    }    public GdkPixbufReader(GdkPixbufReaderSpi ownerSpi, Object ext, GdkPixbufDecoder d)    {      this(ownerSpi, ext);      dec = d;    }    public void setDimensions(int w, int h)    {      processImageStarted(1);      width = w;      height = h;    }        public void setProperties(Hashtable props) {}    public void setColorModel(ColorModel model)     {      defaultModel = model;    }    public void setHints(int flags) {}    public void setPixels(int x, int y, int w, int h,                           ColorModel model, byte[] pixels,                           int offset, int scansize)    {    }          public void setPixels(int x, int y, int w, int h,                           ColorModel model, int[] pixels,                           int offset, int scansize)    {      if (model == null)        model = defaultModel;            if (bufferedImage == null)        {          bufferedImage = new BufferedImage (width, height, (model != null && model.hasAlpha() ?                                                              BufferedImage.TYPE_INT_ARGB                                                             : BufferedImage.TYPE_INT_RGB));        }      int pixels2[];      if (model != null)        {          pixels2 = new int[pixels.length];          for (int yy = 0; yy < h; yy++)            for (int xx = 0; xx < w; xx++)              {                int i = yy * scansize + xx;                pixels2[i] = model.getRGB (pixels[i]);              }        }      else        pixels2 = pixels;      bufferedImage.setRGB (x, y, w, h, pixels2, offset, scansize);      processImageProgress(y / (height == 0 ? 1 : height));    }    public void imageComplete(int status)     {      processImageComplete();    }    public BufferedImage getBufferedImage()    {      if (bufferedImage == null && dec != null)        dec.startProduction (this);      return bufferedImage;    }    // ImageReader parts    public int getNumImages(boolean allowSearch)      throws IOException    {      return 1;    }    public IIOMetadata getImageMetadata(int i)     {      return null;    }    public IIOMetadata getStreamMetadata()      throws IOException    {      return null;    }    public Iterator getImageTypes(int imageIndex)      throws IOException    {      BufferedImage img = getBufferedImage();      Vector vec = new Vector();      vec.add(new ImageTypeSpecifier(img));      return vec.iterator();    }        public int getHeight(int imageIndex)      throws IOException    {      return getBufferedImage().getHeight();    }    public int getWidth(int imageIndex)      throws IOException    {      return getBufferedImage().getWidth();    }    public void setInput(Object input,                         boolean seekForwardOnly,                         boolean ignoreMetadata)    {      super.setInput(input, seekForwardOnly, ignoreMetadata);      dec = new GdkPixbufDecoder((InputStream) getInput());    }    public BufferedImage read(int imageIndex, ImageReadParam param)      throws IOException    {      return getBufferedImage ();    }  }  // remaining helper class and static method is a convenience for the Gtk  // peers, for loading a BufferedImage in off a disk file without going  // through the whole imageio system.   public static BufferedImage createBufferedImage (String filename)  {    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(),                                              "png", // reader auto-detects, doesn't matter                                             new GdkPixbufDecoder (filename));    return r.getBufferedImage ();  }  public static BufferedImage createBufferedImage (URL u)  {    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(),                                              "png", // reader auto-detects, doesn't matter                                             new GdkPixbufDecoder (u));    return r.getBufferedImage ();  }  public static BufferedImage createBufferedImage (byte[] imagedata, int imageoffset,                                                   int imagelength)  {    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(),                                              "png", // reader auto-detects, doesn't matter                                             new GdkPixbufDecoder (imagedata,                                                                   imageoffset,                                                                   imagelength));    return r.getBufferedImage ();  }    public static BufferedImage createBufferedImage (ImageProducer producer)  {    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), "png" /* ignored */, null);    producer.startProduction(r);    return r.getBufferedImage ();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -