com.tncy.top.image

ImageWrapper

class ImageWrapper extends AnyRef

Image Wrapper

The ImageWrapper represents a wrapper class for java image objects.

The image is represented as a 2-D array where each pixel at (column,row) contains the RGB colour value for that pixel. The RGB value is stored as a 32-bit Integer value, taking the form:

   (MSB) TTTT TTTT RRRR RRRR GGGG GGGG BBBB BBBB (LSB)

where MSB is the most significant bit, LSB the least significant bit, T/R/G/B are 8-bit representations of the Transparency, Red, Green, and Blue colour values respectively.

For example, an RGB value of 0x000000FF (hexadecimal base) corresponds to colour blue:

  (MSB) TTTT TTTT RRRR RRRR GGGG GGGG BBBB BBBB (LSB)
        0000 0000 0000 0000 0000 0000 1111 1111

For more information about the RGB color model see the dedicated Wikipedia page on the topic.

Example Use
   // Import the API library
   import com.tncy.top.image.ImageWrapper;

   // Source image file
   var fileName : String = "sampleImage.jpg";

   // Load wrapped image
   var wrappedImage : ImageWrapper = new ImageWrapper(fileName);
   // Get the image
   var image2D : Array[Array[Int]] = wrappedImage.getImage();

   // Print image height and width
   println("The image height is: " + wrappedImage.height + " px.");
   println("The image width is: " + wrappedImage.width + " px.");

   // Modify it
   for (row <- 0 to 40) {
     for (col <-0 to 80) {
       image2D(row)(col) = 0x000000FF; // Set these pixels to RGB blue
     }
   }

   // Destination image file - Note that the image file name must contain the file type extension for the image to be saved correctly.
   var outputFile : String = "outputImage.jpg";
   // Save the result
   wrappedImage.saveImage(outputFile);
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ImageWrapper
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ImageWrapper(fileName: String)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  12. def getImage(): Array[Array[Int]]

    Get the 2-D image.

    Get the 2-D image.

    The image is represented as a 2-D array where each pixel at (column,row) contains the RGB colour value for that pixel. The RGB value is stored as a 32-bit Integer value, taking the form:

       (MSB) TTTT TTTT RRRR RRRR GGGG GGGG BBBB BBBB (LSB)
    

    where MSB is the most significant bit, LSB the least significant bit, T/R/G/B are 8-bit representations of the Transparency, Red, Green, and Blue colour values respectively.

    For example, an RGB value of 0x000000FF (hexadecimal base) corresponds to colour blue:

      (MSB) TTTT TTTT RRRR RRRR GGGG GGGG BBBB BBBB (LSB)
            0000 0000 0000 0000 0000 0000 1111 1111
    
    returns

    A 2-D array of pixel RGB values representing the image

  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. var height: Int

    The image height.

  15. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  19. def saveImage(fileName: String): Boolean

    Save the image to file.

    Save the image to file.

    The image is represented as a 2-D array where each pixel at (column,row) contains the RGB colour value for that pixel. The RGB value is stored as a 32-bit Integer value, taking the form:

       (MSB) TTTT TTTT RRRR RRRR GGGG GGGG BBBB BBBB (LSB)
    

    where MSB is the most significant bit, LSB the least significant bit, T/R/G/B are 8-bit representations of the Transparency, Red, Green, and Blue colour values respectively.

    The image file name must contain the file type extension for the image to be saved correctly:

    var fileNameWRONG : String = "myTestImage";
    var fileName : String = "myTestImage.png";
    
    fileName

    The path where to save the image file

    returns

    True upon completion

    Exceptions thrown
    NullPointerException

    if the given filename is null

    IOException

    if the image cannot be found at the specified path

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  21. def toString(): String

    Convert the 2-D array of pixel RGB values representing the image into a pretty printable string.

    Convert the 2-D array of pixel RGB values representing the image into a pretty printable string.

    The array printout is formatted as:

     	[ [1, 2, 3],
    	  [3, 4, 5],
     	  [6, 7, 8] ]
    
    Definition Classes
    ImageWrapper → AnyRef → Any
  22. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  24. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  25. var width: Int

    The image width.

Inherited from AnyRef

Inherited from Any