## org.gnu.gdk
Class PixbufLoader

    java.lang.Object
      org.gnu.glib.Struct
          org.gnu.glib.GObject
              org.gnu.gdk.PixbufLoader

public class PixbufLoader
extends GObject

The `PixbufLoader` provides a way for applications to drive the process of loading an image, by letting them send the image data directly to the loader instead of having the loader read the data from a file. Applications can use this functionality instead of `Pixbuf.Pixbuf(String)` or `PixbufAnimation.PixbufAnimation(String)` when they need to parse image data in small chunks. For example, it should be used when reading an image from a (potentially) slow network connection, when loading an extremely large file or even reading an image from a database.

To use `PixbufLoader` to load an image, just create a new one, and call `write(byte[])`, `write(byte[],int)`, or `write(InputStream)` to send the data to it. When done, `close()` should be called to end the stream and finalize everything. The created ``Pixbuf`` can be retireved using the `getPixbuf()` method.

See Also:
  `Pixbuf`, `PixbufAnimation`

Constructor Summary
`PixbufLoader()` Construct a new `PixbufLoader` that automatically detects the type of image based on the data.
`PixbufLoader(java.lang.String imageType)` Construct a new `PixbufLoader` that parses the image data as if it were an image of `imageType`.

Method Summary
`boolean` `close()` Informs a loader that no further writes will occur, so that it can free its internal loading structures.
`Pixbuf` `getPixbuf()` Get the ``Pixbuf`` object that is currently being created.
`PixbufAnimation` `getPixbufAnimation()` Get the ``PixbufAnimation`` object that is currently being created.
`boolean` `write(byte[] buffer)` Parse the images bytes from the given `buffer`.
`boolean` `write(byte[] buffer, int len)` Parse `len` image bytes from `buffer`.
`boolean` `write(java.io.InputStream stream)` Parse the data for the image from the given `stream`.

Methods inherited from class org.gnu.glib.GObject

`addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getEventListenerClass, getEventType, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify`

Methods inherited from class org.gnu.glib.Struct
`equals, getHandle, getNullHandle, hashCode`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PixbufLoader

    public PixbufLoader()

  Construct a new `PixbufLoader` that automatically detects the type of image based on the data.

### PixbufLoader

    public PixbufLoader(java.lang.String imageType)

  Construct a new `PixbufLoader` that parses the image data as if it were an image of `imageType`.

Parameters:
  `imageType` - Name of the image format to be loaded with the image.

Method Detail

### write

    public boolean write(byte[] buffer)

  Parse the images bytes from the given `buffer`.

  Returns:
    `true` if the data was loaded successfully, `false` if an error occured.

### write

    public boolean write(byte[] buffer,
                         int len)

  Parse `len` image bytes from `buffer`.

  Returns:
    `true` if the data was loaded successfully, `false` if an error occured.

### write

    public boolean write(java.io.InputStream stream)

  Parse the data for the image from the given `stream`. The contents of the stream are read and loaded into the Pixbuf using succesive calls to the `write(byte[],int)` method. If all of the data for the image is in the given `stream`, the `close()` method should be called after this method finishes. You can call `getPixbuf()` to get the resulting `Pixbuf` object.

  This method does not make any attempt to efficiently read the data from the given stream. Calling applications should wrap their `InputStreams` in efficient implementations (such as `Buffered*` implementations) if necessary before calling this method.

  Parameters:
    `stream` - A stream containing the data to load.
  Returns:
    `true` if the data was loaded successfully, `false` if an error occured.

### getPixbuf

    public Pixbuf getPixbuf()

  Get the ``Pixbuf`` object that is currently being created.

### getPixbufAnimation

    public PixbufAnimation getPixbufAnimation()

  Get the ``PixbufAnimation`` object that is currently being created.

### close

    public boolean close()

  Informs a loader that no further writes will occur, so that it can free its internal loading structures.