Class Bitmap

java.lang.Object
fr.olleroy.ImageModifier.components.Bitmap

public class Bitmap extends Object
Bitmap class stores pixels and basic information about the image. Bitmap looks like a BufferedImage but is smaller in memory. BufferedImage could be more efficient to open files faster -> could upgrade to it.
Version:
1.2.0
Author:
olleory alias ollprogram.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Bitmap​(int width, int height)
    Construct a bitmap with the specified size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    change​(Bitmap bmp)
    Replace completely the bitmap.
    int
    getARGB​(int x, int y)
    Get the ARGB color of a specified pixel.
    int
    Get the height of the bitmap.
    getPixel​(int x, int y)
    Get a pixel.
    int
    getRGB​(int x, int y)
    Get the RGB color of a specified pixel.
    int
    getSize​(boolean alpha)
    Get the size of the bitmap image.
    int
    Get the width of the bitmap.
    void
    setPixel​(int x, int y, int color)
    Modify the color of a pixel in the bitmap.
    void
    setPixel​(int x, int y, int r, int g, int b)
    Modify the color of a pixel in the bitmap.
    void
    setPixel​(int x, int y, int a, int r, int g, int b)
    Modify the color of a pixel in the bitmap.
    void
    setPixel​(int x, int y, Pixel pixel)
    Modify the color of a pixel in the bitmap.
    void
    setPixel​(int x, int y, Color color)
    Modify the color of a pixel in the bitmap.
    Convert the bitmap to a buffered image.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Bitmap

      public Bitmap(int width, int height)
      Construct a bitmap with the specified size.
      Parameters:
      width - Width of the bitmap image.
      height - Height of the bitmap image.
  • Method Details

    • change

      public void change(Bitmap bmp)
      Replace completely the bitmap. This method allow changing entirely the bitmap without changing the reference of the object (not creating a new object in memory).
      Parameters:
      bmp - The bitmap which will replace the older bitmap.
    • getPixel

      public Pixel getPixel(int x, int y)
      Get a pixel.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      Returns:
      The pixel at the specified location in the bitmap. Black pixel it's a 0x0 bitmap.
    • getRGB

      public int getRGB(int x, int y)
      Get the RGB color of a specified pixel.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      Returns:
      The RGB color of the pixel with his specified location in the bitmap.
    • getARGB

      public int getARGB(int x, int y)
      Get the ARGB color of a specified pixel.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      Returns:
      The ARGB color of the pixel with his specified location in the bitmap.
    • setPixel

      public void setPixel(int x, int y, Pixel pixel)
      Modify the color of a pixel in the bitmap.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      pixel - Pixel for replacement.
    • setPixel

      public void setPixel(int x, int y, int color)
      Modify the color of a pixel in the bitmap.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      color - An integer in RGB or ARGB format.
    • setPixel

      public void setPixel(int x, int y, int r, int g, int b)
      Modify the color of a pixel in the bitmap.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      r - Red color.
      g - Green color.
      b - Blue color.
    • setPixel

      public void setPixel(int x, int y, int a, int r, int g, int b)
      Modify the color of a pixel in the bitmap.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      a - Alpha.
      r - Red color.
      g - Green color.
      b - Blue color.
    • setPixel

      public void setPixel(int x, int y, Color color)
      Modify the color of a pixel in the bitmap.
      Parameters:
      x - X-axis location.
      y - Y-axis location.
      color - The color to set.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getWidth

      public int getWidth()
      Get the width of the bitmap.
      Returns:
      The width of the bitmap.
    • getHeight

      public int getHeight()
      Get the height of the bitmap.
      Returns:
      The height of the bitmap.
    • toImage

      public BufferedImage toImage()
      Convert the bitmap to a buffered image.
      Returns:
      The bufferedImage built with the bitmap.
    • getSize

      public int getSize(boolean alpha)
      Get the size of the bitmap image.
      Parameters:
      alpha - true for ARGB size, else RGB size.
      Returns:
      The size in bytes.