org.apache.commons.imaging.common

## Class ImageBuilder

- java.lang.Object
- - org.apache.commons.imaging.common.ImageBuilder

-     public class ImageBuilder
      extends Object

  A utility class primary intended for storing data obtained by reading image files.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ImageBuilder(int width, int height, boolean hasAlpha)` Construct an ImageBuilder instance

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BufferedImage` | `getBufferedImage()` Create a BufferedImage using the data stored in the ImageBuilder.
    `int` | `getHeight()` Get the height of the ImageBuilder pixel field
    `int` | `getRGB(int x, int y)` Get the RGB or ARGB value for the pixel at the position (x,y) within the image builder pixel field.
    `BufferedImage` | `getSubimage(int x, int y, int w, int h)` Gets a subimage from the ImageBuilder using the specified parameters.
    `int` | `getWidth()` Get the width of the ImageBuilder pixel field
    `void` | `setRGB(int x, int y, int argb)` Set the RGB or ARGB value for the pixel at position (x,y) within the image builder pixel field.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ImageBuilder

          public ImageBuilder(int width,
                              int height,
                              boolean hasAlpha)

      Construct an ImageBuilder instance
      Parameters:
        `width` - the width of the image to be built
        `height` - the height of the image to be built
        `hasAlpha` - indicates whether the image has an alpha channel (the selection of alpha channel does not change the memory requirements for the ImageBuilder or resulting BufferedImage.

  - ### Method Detail

    - #### getWidth

          public int getWidth()

      Get the width of the ImageBuilder pixel field
      Returns:
        a positive integer

    - #### getHeight

          public int getHeight()

      Get the height of the ImageBuilder pixel field
      Returns:
        a positive integer

    - #### getRGB

          public int getRGB(int x,
                            int y)

      Get the RGB or ARGB value for the pixel at the position (x,y) within the image builder pixel field. For performance reasons no bounds checking is applied.
      Parameters:
        `x` - the X coordinate of the pixel to be read
        `y` - the Y coordinate of the pixel to be read
      Returns:
        the RGB or ARGB pixel value

    - #### setRGB

          public void setRGB(int x,
                             int y,
                             int argb)

      Set the RGB or ARGB value for the pixel at position (x,y) within the image builder pixel field. For performance reasons, no bounds checking is applied.
      Parameters:
        `x` - the X coordinate of the pixel to be set
        `y` - the Y coordinate of the pixel to be set
        `argb` - the RGB or ARGB value to be stored.

    - #### getBufferedImage

          public BufferedImage getBufferedImage()

      Create a BufferedImage using the data stored in the ImageBuilder.
      Returns:
        a valid BufferedImage.

    - #### getSubimage

          public BufferedImage getSubimage(int x,
                                           int y,
                                           int w,
                                           int h)

      Gets a subimage from the ImageBuilder using the specified parameters. If the parameters specify a rectangular region that is not entirely contained within the bounds defined by the ImageBuilder, this method will throw a RasterFormatException. This runtime-exception behavior is consistent with the behavior of the getSubimage method provided by BufferedImage.
      Parameters:
        `x` - the X coordinate of the upper-left corner of the specified rectangular region
        `y` - the Y coordinate of the upper-left corner of the specified rectangular region
        `w` - the width of the specified rectangular region
        `h` - the height of the specified rectangular region
      Returns:
        a BufferedImage that constructed from the data within the specified rectangular region
      Throws:
        `RasterFormatException` - f the specified area is not contained within this ImageBuilder

Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.