Class Pixmap

  • All Implemented Interfaces:
    com.badlogic.gdx.utils.Disposable

    public class Pixmap
    extends java.lang.Object
    implements com.badlogic.gdx.utils.Disposable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Map<java.lang.Integer,​Pixmap> pixmaps  
    • Constructor Summary

      Constructors 
      Constructor Description
      Pixmap​(int width, int height, Pixmap.Format format)  
      Pixmap​(com.badlogic.gdx.files.FileHandle file)  
      Pixmap​(com.google.gwt.dom.client.ImageElement img)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canUseImageElement()  
      void dispose()  
      void drawCircle​(int x, int y, int radius)
      Draws a circle outline with the center at x,y and a radius using the current color and stroke width.
      void drawLine​(int x, int y, int x2, int y2)
      Draws a line between the given coordinates using the currently set color.
      void drawPixel​(int x, int y)
      Draws a pixel at the given location with the current color.
      void drawPixel​(int x, int y, int color)
      Draws a pixel at the given location with the given color.
      void drawPixmap​(Pixmap pixmap, int x, int y)
      Draws an area form another Pixmap to this Pixmap.
      void drawPixmap​(Pixmap pixmap, int x, int y, int srcx, int srcy, int srcWidth, int srcHeight)
      Draws an area form another Pixmap to this Pixmap.
      void drawPixmap​(Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, int dstx, int dsty, int dstWidth, int dstHeight)
      Draws an area form another Pixmap to this Pixmap.
      void drawRectangle​(int x, int y, int width, int height)
      Draws a rectangle outline starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using the current color.
      void fill()
      Fills the complete bitmap with the currently set color.
      void fillCircle​(int x, int y, int radius)
      Fills a circle with the center at x,y and a radius using the current color.
      void fillRectangle​(int x, int y, int width, int height)
      Fills a rectangle starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using the current color.
      void fillTriangle​(int x1, int y1, int x2, int y2, int x3, int y3)
      Fills a triangle with vertices at x1,y1 and x2,y2 and x3,y3 using the current color.
      static Pixmap.Blending getBlending()  
      com.google.gwt.dom.client.CanvasElement getCanvasElement()  
      com.google.gwt.canvas.dom.client.Context2d getContext()  
      Pixmap.Format getFormat()  
      int getGLFormat()  
      int getGLInternalFormat()  
      int getGLType()  
      int getHeight()  
      com.google.gwt.dom.client.ImageElement getImageElement()  
      int getPixel​(int x, int y)
      Returns the 32-bit RGBA8888 value of the pixel at x, y.
      java.nio.Buffer getPixels()  
      int getWidth()  
      static java.lang.String make​(int r2, int g2, int b2, float a2)  
      static void setBlending​(Pixmap.Blending blending)
      Sets the type of Pixmap.Blending to be used for all operations.
      void setColor​(float r, float g, float b, float a)
      Sets the color for the following drawing operations.
      void setColor​(int color)
      Sets the color for the following drawing operations
      void setColor​(com.badlogic.gdx.graphics.Color color)
      Sets the color for the following drawing operations.
      static void setFilter​(Pixmap.Filter filter)
      Sets the type of interpolation Pixmap.Filter to be used in conjunction with drawPixmap(Pixmap, int, int, int, int, int, int, int, int).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pixmaps

        public static java.util.Map<java.lang.Integer,​Pixmap> pixmaps
    • Constructor Detail

      • Pixmap

        public Pixmap​(com.badlogic.gdx.files.FileHandle file)
      • Pixmap

        public Pixmap​(com.google.gwt.dom.client.ImageElement img)
      • Pixmap

        public Pixmap​(int width,
                      int height,
                      Pixmap.Format format)
    • Method Detail

      • getContext

        public com.google.gwt.canvas.dom.client.Context2d getContext()
      • make

        public static java.lang.String make​(int r2,
                                            int g2,
                                            int b2,
                                            float a2)
      • getGLInternalFormat

        public int getGLInternalFormat()
      • getGLFormat

        public int getGLFormat()
      • getGLType

        public int getGLType()
      • getWidth

        public int getWidth()
      • getHeight

        public int getHeight()
      • getPixels

        public java.nio.Buffer getPixels()
      • dispose

        public void dispose()
        Specified by:
        dispose in interface com.badlogic.gdx.utils.Disposable
      • getCanvasElement

        public com.google.gwt.dom.client.CanvasElement getCanvasElement()
      • canUseImageElement

        public boolean canUseImageElement()
      • getImageElement

        public com.google.gwt.dom.client.ImageElement getImageElement()
      • setColor

        public void setColor​(int color)
        Sets the color for the following drawing operations
        Parameters:
        color - the color, encoded as RGBA8888
      • setColor

        public void setColor​(float r,
                             float g,
                             float b,
                             float a)
        Sets the color for the following drawing operations.
        Parameters:
        r - The red component.
        g - The green component.
        b - The blue component.
        a - The alpha component.
      • setColor

        public void setColor​(com.badlogic.gdx.graphics.Color color)
        Sets the color for the following drawing operations.
        Parameters:
        color - The color.
      • fill

        public void fill()
        Fills the complete bitmap with the currently set color.
      • drawLine

        public void drawLine​(int x,
                             int y,
                             int x2,
                             int y2)
        Draws a line between the given coordinates using the currently set color.
        Parameters:
        x - The x-coodinate of the first point
        y - The y-coordinate of the first point
        x2 - The x-coordinate of the first point
        y2 - The y-coordinate of the first point
      • drawRectangle

        public void drawRectangle​(int x,
                                  int y,
                                  int width,
                                  int height)
        Draws a rectangle outline starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using the current color.
        Parameters:
        x - The x coordinate
        y - The y coordinate
        width - The width in pixels
        height - The height in pixels
      • drawPixmap

        public void drawPixmap​(Pixmap pixmap,
                               int x,
                               int y)
        Draws an area form another Pixmap to this Pixmap.
        Parameters:
        pixmap - The other Pixmap
        x - The target x-coordinate (top left corner)
        y - The target y-coordinate (top left corner)
      • drawPixmap

        public void drawPixmap​(Pixmap pixmap,
                               int x,
                               int y,
                               int srcx,
                               int srcy,
                               int srcWidth,
                               int srcHeight)
        Draws an area form another Pixmap to this Pixmap.
        Parameters:
        pixmap - The other Pixmap
        x - The target x-coordinate (top left corner)
        y - The target y-coordinate (top left corner)
        srcx - The source x-coordinate (top left corner)
        srcy - The source y-coordinate (top left corner);
        srcWidth - The width of the area form the other Pixmap in pixels
        srcHeight - The height of the area form the other Pixmap in pixles
      • drawPixmap

        public void drawPixmap​(Pixmap pixmap,
                               int srcx,
                               int srcy,
                               int srcWidth,
                               int srcHeight,
                               int dstx,
                               int dsty,
                               int dstWidth,
                               int dstHeight)
        Draws an area form another Pixmap to this Pixmap. This will automatically scale and stretch the source image to the specified target rectangle. Use setFilter(Filter) to specify the type of filtering to be used (nearest neighbour or bilinear).
        Parameters:
        pixmap - The other Pixmap
        srcx - The source x-coordinate (top left corner)
        srcy - The source y-coordinate (top left corner);
        srcWidth - The width of the area form the other Pixmap in pixels
        srcHeight - The height of the area form the other Pixmap in pixles
        dstx - The target x-coordinate (top left corner)
        dsty - The target y-coordinate (top left corner)
        dstWidth - The target width
        dstHeight - the target height
      • fillRectangle

        public void fillRectangle​(int x,
                                  int y,
                                  int width,
                                  int height)
        Fills a rectangle starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using the current color.
        Parameters:
        x - The x coordinate
        y - The y coordinate
        width - The width in pixels
        height - The height in pixels
      • drawCircle

        public void drawCircle​(int x,
                               int y,
                               int radius)
        Draws a circle outline with the center at x,y and a radius using the current color and stroke width.
        Parameters:
        x - The x-coordinate of the center
        y - The y-coordinate of the center
        radius - The radius in pixels
      • fillCircle

        public void fillCircle​(int x,
                               int y,
                               int radius)
        Fills a circle with the center at x,y and a radius using the current color.
        Parameters:
        x - The x-coordinate of the center
        y - The y-coordinate of the center
        radius - The radius in pixels
      • fillTriangle

        public void fillTriangle​(int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int x3,
                                 int y3)
        Fills a triangle with vertices at x1,y1 and x2,y2 and x3,y3 using the current color.
        Parameters:
        x1 - The x-coordinate of vertex 1
        y1 - The y-coordinate of vertex 1
        x2 - The x-coordinate of vertex 2
        y2 - The y-coordinate of vertex 2
        x3 - The x-coordinate of vertex 3
        y3 - The y-coordinate of vertex 3
      • getPixel

        public int getPixel​(int x,
                            int y)
        Returns the 32-bit RGBA8888 value of the pixel at x, y. For Alpha formats the RGB components will be one.
        Parameters:
        x - The x-coordinate
        y - The y-coordinate
        Returns:
        The pixel color in RGBA8888 format.
      • drawPixel

        public void drawPixel​(int x,
                              int y)
        Draws a pixel at the given location with the current color.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
      • drawPixel

        public void drawPixel​(int x,
                              int y,
                              int color)
        Draws a pixel at the given location with the given color.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        color - the color in RGBA8888 format.