Class ImageFactory

  • Direct Known Subclasses:
    BufferedImageFactory

    public abstract class ImageFactory
    extends java.lang.Object
    ImageFactory contains image creation mechanism on top of different platforms like PC and Android. System will choose appropriate Factory based on the supported image type.
    • Constructor Detail

      • ImageFactory

        public ImageFactory()
    • Method Detail

      • getInstance

        public static ImageFactory getInstance()
        Gets new instance of Image factory from the provided factory implementation.
        Returns:
        ImageFactory
      • setImageFactory

        public static void setImageFactory​(ImageFactory factory)
        Sets a custom instance of ImageFactory.
        Parameters:
        factory - a custom instance of ImageFactory
      • fromFile

        public abstract Image fromFile​(java.nio.file.Path path)
                                throws java.io.IOException
        Gets Image from file.
        Parameters:
        path - the path to the image
        Returns:
        Image
        Throws:
        java.io.IOException - Image not found or not readable
      • fromUrl

        public Image fromUrl​(java.net.URL url)
                      throws java.io.IOException
        Gets Image from URL.
        Parameters:
        url - the URL to load from
        Returns:
        Image
        Throws:
        java.io.IOException - URL is not valid.
      • fromUrl

        public Image fromUrl​(java.lang.String url)
                      throws java.io.IOException
        Gets Image from URL.
        Parameters:
        url - the String represent URL to load from
        Returns:
        Image
        Throws:
        java.io.IOException - URL is not valid.
      • fromInputStream

        public abstract Image fromInputStream​(java.io.InputStream is)
                                       throws java.io.IOException
        Gets Image from InputStream.
        Parameters:
        is - InputStream
        Returns:
        Image
        Throws:
        java.io.IOException - image cannot be read from input stream.
      • fromImage

        public abstract Image fromImage​(java.lang.Object image)
        Gets Image from varies Java image types.

        Image can be BufferedImage or BitMap depends on platform

        Parameters:
        image - the image object.
        Returns:
        Image
      • fromNDArray

        public abstract Image fromNDArray​(NDArray array)
        Gets Image from NDArray.
        Parameters:
        array - the NDArray with CHW format
        Returns:
        Image
      • fromPixels

        public abstract Image fromPixels​(int[] pixels,
                                         int width,
                                         int height)
        Gets Image from array.
        Parameters:
        pixels - the array of ARGB values used to initialize the pixels.
        width - the width of the image
        height - the height of the image
        Returns:
        Image