A Pixmap represents an image in memory. It has a width and height expressed in pixels as well as a Format specifying
the number and order of color components per pixel. Coordinates of pixels are specified with respect to the top left corner of
the image, with the x-axis pointing to the right and the y-axis pointing downwards.
By default all methods use blending. You can disable blending with Pixmap#setBlending(Blending), which may reduce
blitting time by ~30%. The Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int) method will scale and
stretch the source image to a target image. There either nearest neighbour or bilinear filtering can be used.
A Pixmap stores its data in native heap memory. It is mandatory to call Pixmap#dispose() when the pixmap is no longer
needed, otherwise memory leaks will result
| Modifier and Type | Class and Description |
|---|---|
| public static enum | Pixmap.
Blending functions to be set with |
| public static interface | |
| public static enum | Pixmap.
Filters to be used with |
| public static enum | Pixmap.
Different pixel formats. |
| Modifier and Type | Field and Description |
|---|---|
| private Pixmap. | |
| pack-priv int | |
| private boolean | |
| private Pixmap. | |
| pack-priv final Gdx2DPixmap |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Pixmap(byte[]
the encoded image data encodedData, int the offset offset, int the length len)Creates a new Pixmap instance from the given encoded image data. |
| public | Pixmap(ByteBuffer
the encoded image data encodedData, int the offset relative to the base address of encodedData offset, int the length len)Creates a new Pixmap instance from the given encoded image data. |
| public | Pixmap(ByteBuffer
the encoded image data encodedData)Creates a new Pixmap instance from the given encoded image data. |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static Pixmap | Returns: the pixmapframebuffer region x x, int framebuffer region y y, int framebuffer region width w, int framebuffer region height h)Creates a Pixmap from a part of the current framebuffer. |
| public void | dispose()
Implements com. Releases all resources associated with this Pixmap. |
| public static void | downloadFromUrl(String
http url to download the image from url, final Pixmap.the listener to call once the image is available as a responseListenerPixmapDownloads an image from http(s) url and passes it as a |
| public void | drawCircle(int
The x-coordinate of the center x, int The y-coordinate of the center y, int The radius in pixels radius)Draws a circle outline with the center at x,y and a radius using the current color and stroke width. |
| public void | drawLine(int
The x-coodinate of the first point x, int The y-coordinate of the first point y, int The x-coordinate of the first point x2, int The y-coordinate of the first point y2)Draws a line between the given coordinates using the currently set color. |
| public void | drawPixel(int
the x-coordinate x, int the y-coordinate y)Draws a pixel at the given location with the current color. |
| public void | drawPixel(int
the x-coordinate x, int the y-coordinate y, int the color in RGBA8888 format. color)Draws a pixel at the given location with the given color. |
| public void | drawPixmap(Pixmap
The other Pixmap pixmap, int The target x-coordinate (top left corner) x, int The target y-coordinate (top left corner) y)Draws an area from another Pixmap to this Pixmap. |
| public void | drawPixmap(Pixmap
The other Pixmap pixmap, int The target x-coordinate (top left corner) x, int The target y-coordinate (top left corner) y, int The source x-coordinate (top left corner) srcx, int The source y-coordinate (top left corner); srcy, int The width of the area from the other Pixmap in pixels srcWidth, int The height of the area from the other Pixmap in pixels srcHeight)Draws an area from another Pixmap to this Pixmap. |
| public void | drawPixmap(Pixmap
The other Pixmap pixmap, int The source x-coordinate (top left corner) srcx, int The source y-coordinate (top left corner); srcy, int The width of the area from the other Pixmap in pixels srcWidth, int The height of the area from the other Pixmap in pixels srcHeight, int The target x-coordinate (top left corner) dstx, int The target y-coordinate (top left corner) dsty, int The target width dstWidth, int the target height dstHeight)Draws an area from another Pixmap to this Pixmap. |
| public void | drawRectangle(int
The x coordinate x, int The y coordinate y, int The width in pixels width, int The height in pixels 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. |
| public void | |
| public void | fillCircle(int
The x-coordinate of the center x, int The y-coordinate of the center y, int The radius in pixels radius)Fills a circle with the center at x,y and a radius using the current color. |
| public void | fillRectangle(int
The x coordinate x, int The y coordinate y, int The width in pixels width, int The height in pixels 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. |
| public void | fillTriangle(int
The x-coordinate of vertex 1 x1, int The y-coordinate of vertex 1 y1, int The x-coordinate of vertex 2 x2, int The y-coordinate of vertex 2 y2, int The x-coordinate of vertex 3 x3, int The y-coordinate of vertex 3 y3)Fills a triangle with vertices at x1,y1 and x2,y2 and x3,y3 using the current color. |
| public Pixmap. | |
| public Pixmap. | |
| public Pixmap. | |
| public int | Returns: one of GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, or GL_LUMINANCE_ALPHA.Returns the OpenGL ES format of this Pixmap. |
| public int | Returns: one of GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, or GL_LUMINANCE_ALPHA.Returns the OpenGL ES format of this Pixmap. |
| public int | Returns: one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_4_4_4_4Returns the OpenGL ES type of this Pixmap. |
| public int | |
| public int | Returns: The pixel color in RGBA8888 format.The x-coordinate x, int The y-coordinate y)Returns the 32-bit RGBA8888 value of the pixel at x, y. |
| public ByteBuffer | Returns: the directByteBuffer holding the pixel data.Returns the direct ByteBuffer holding the pixel data. |
| public int | |
| public boolean | |
| public void | setBlending(Pixmap.
the blending type blendingSets the type of |
| public void | setColor(int
the color, encoded as RGBA8888 color)Sets the color for the following drawing operations |
| public void | setColor(float
The red component. r, float The green component. g, float The blue component. b, float The alpha component. a)Sets the color for the following drawing operations. |
| public void | |
| public void | setFilter(Pixmap.
the filter. filterSets the type of interpolation |
| public void | setPixels(ByteBuffer
Pixels to copy from, should be a direct ByteBuffer and match Pixmap data size (see pixels)getPixels()).Sets pixels from a provided direct byte buffer. |
| blending | back to summary |
|---|---|
| private Pixmap. | |
| color | back to summary |
|---|---|
| pack-priv int color | |
| disposed | back to summary |
|---|---|
| private boolean disposed | |
| filter | back to summary |
|---|---|
| private Pixmap. | |
| pixmap | back to summary |
|---|---|
| pack-priv final Gdx2DPixmap pixmap | |
| Pixmap | back to summary |
|---|---|
| public Pixmap(int width, int height, Pixmap. Creates a new Pixmap instance with the given width, height and format. | |
| Pixmap | back to summary |
|---|---|
| public Pixmap(byte[] encodedData, int offset, int len) Creates a new Pixmap instance from the given encoded image data. The image can be encoded as JPEG, PNG or BMP. Not available on GWT backend.
| |
| Pixmap | back to summary |
|---|---|
| public Pixmap(ByteBuffer encodedData, int offset, int len) Creates a new Pixmap instance from the given encoded image data. The image can be encoded as JPEG, PNG or BMP. Not available on GWT backend.
| |
| Pixmap | back to summary |
|---|---|
| public Pixmap(ByteBuffer encodedData) Creates a new Pixmap instance from the given encoded image data. The image can be encoded as JPEG, PNG or BMP. Not available on GWT backend. Offset is based on the position of the buffer. Length is based on the remaining bytes of the buffer.
| |
| Pixmap | back to summary |
|---|---|
| public Pixmap(FileHandle file) Creates a new Pixmap instance from the given file. The file must be a Png, Jpeg or Bitmap. Paletted formats are not supported.
| |
| Pixmap | back to summary |
|---|---|
| public Pixmap(Gdx2DPixmap pixmap) Constructs a new Pixmap from a | |
| createFromFrameBuffer | back to summary |
|---|---|
| public static Pixmap createFromFrameBuffer(int x, int y, int w, int h) Creates a Pixmap from a part of the current framebuffer.
| |
| dispose | back to summary |
|---|---|
| public void dispose() Implements com. Releases all resources associated with this Pixmap. | |
| downloadFromUrl | back to summary |
|---|---|
| public static void downloadFromUrl(String url, final Pixmap. Downloads an image from http(s) url and passes it as a
| |
| drawCircle | back to summary |
|---|---|
| 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.
| |
| drawLine | back to summary |
|---|---|
| public void drawLine(int x, int y, int x2, int y2) Draws a line between the given coordinates using the currently set color.
| |
| drawPixel | back to summary |
|---|---|
| public void drawPixel(int x, int y) Draws a pixel at the given location with the current color.
| |
| drawPixel | back to summary |
|---|---|
| public void drawPixel(int x, int y, int color) Draws a pixel at the given location with the given color.
| |
| drawPixmap | back to summary |
|---|---|
| public void drawPixmap(Pixmap pixmap, int x, int y) Draws an area from another Pixmap to this Pixmap.
| |
| drawPixmap | back to summary |
|---|---|
| public void drawPixmap(Pixmap pixmap, int x, int y, int srcx, int srcy, int srcWidth, int srcHeight) Draws an area from another Pixmap to this Pixmap.
| |
| drawPixmap | back to summary |
|---|---|
| public void drawPixmap(Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, int dstx, int dsty, int dstWidth, int dstHeight) Draws an area from another Pixmap to this Pixmap. This will automatically scale and stretch the source image to the
specified target rectangle. Use
| |
| drawRectangle | back to summary |
|---|---|
| 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.
| |
| fill | back to summary |
|---|---|
| public void fill() Fills the complete bitmap with the currently set color. | |
| fillCircle | back to summary |
|---|---|
| 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.
| |
| fillRectangle | back to summary |
|---|---|
| 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.
| |
| fillTriangle | back to summary |
|---|---|
| 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.
| |
| getBlending | back to summary |
|---|---|
| public Pixmap. | |
| getFilter | back to summary |
|---|---|
| public Pixmap. | |
| getFormat | back to summary |
|---|---|
| public Pixmap. | |
| getGLFormat | back to summary |
|---|---|
| public int getGLFormat() Returns the OpenGL ES format of this Pixmap. Used as the seventh parameter to
| |
| getGLInternalFormat | back to summary |
|---|---|
| public int getGLInternalFormat() Returns the OpenGL ES format of this Pixmap. Used as the third parameter to
| |
| getGLType | back to summary |
|---|---|
| public int getGLType() Returns the OpenGL ES type of this Pixmap. Used as the eighth parameter to
| |
| getHeight | back to summary |
|---|---|
public int getHeight()
| |
| getPixel | back to summary |
|---|---|
| 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.
| |
| getPixels | back to summary |
|---|---|
| public ByteBuffer getPixels() Returns the direct ByteBuffer holding the pixel data. For the format Alpha each value is encoded as a byte. For the format LuminanceAlpha the luminance is the first byte and the alpha is the second byte of the pixel. For the formats RGB888 and RGBA8888 the color components are stored in a single byte each in the order red, green, blue (alpha). For the formats RGB565 and RGBA4444 the pixel colors are stored in shorts in machine dependent order.
| |
| getWidth | back to summary |
|---|---|
public int getWidth()
| |
| isDisposed | back to summary |
|---|---|
| public boolean isDisposed() | |
| setBlending | back to summary |
|---|---|
| public void setBlending(Pixmap. Sets the type of | |
| setColor | back to summary |
|---|---|
| public void setColor(int color) Sets the color for the following drawing operations
| |
| setColor | back to summary |
|---|---|
| public void setColor(float r, float g, float b, float a) Sets the color for the following drawing operations.
| |
| setColor | back to summary |
|---|---|
| public void setColor(Color color) Sets the color for the following drawing operations.
| |
| setFilter | back to summary |
|---|---|
| public void setFilter(Pixmap. Sets the type of interpolation | |
| setPixels | back to summary |
|---|---|
| public void setPixels(ByteBuffer pixels) Sets pixels from a provided direct byte buffer.
| |
Pixmap#setBlending.
| Modifier and Type | Field and Description |
|---|---|
| public static final Pixmap. | |
| public static final Pixmap. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Pixmap. | |
| public static Pixmap. |
| None | back to summary |
|---|---|
| public static final Pixmap. | |
| SourceOver | back to summary |
|---|---|
| public static final Pixmap. | |
| Blending | back to summary |
|---|---|
| private Blending() | |
| valueOf | back to summary |
|---|---|
| public static Pixmap. | |
| values | back to summary |
|---|---|
| public static Pixmap. | |
downloadFromUrl(String, DownloadPixmapResponseListener)
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void |
| downloadComplete | back to summary |
|---|---|
| public void downloadComplete(Pixmap pixmap) Called on the render thread when image was downloaded successfully. | |
| downloadFailed | back to summary |
|---|---|
| public void downloadFailed(Throwable t) Called when image download failed. This might get called on a background thread. | |
Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int).
| Modifier and Type | Field and Description |
|---|---|
| public static final Pixmap. | |
| public static final Pixmap. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Pixmap. | |
| public static Pixmap. |
| BiLinear | back to summary |
|---|---|
| public static final Pixmap. | |
| NearestNeighbour | back to summary |
|---|---|
| public static final Pixmap. | |
| Filter | back to summary |
|---|---|
| private Filter() | |
| valueOf | back to summary |
|---|---|
| public static Pixmap. | |
| values | back to summary |
|---|---|
| public static Pixmap. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Pixmap. | |
| public static final Pixmap. | |
| public static final Pixmap. | |
| public static final Pixmap. | |
| public static final Pixmap. | |
| public static final Pixmap. | |
| public static final Pixmap. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Pixmap. | |
| public static int | |
| public static int | |
| public static int | |
| public static Pixmap. | |
| public static Pixmap. |
| Alpha | back to summary |
|---|---|
| public static final Pixmap. | |
| Intensity | back to summary |
|---|---|
| public static final Pixmap. | |
| LuminanceAlpha | back to summary |
|---|---|
| public static final Pixmap. | |
| RGB565 | back to summary |
|---|---|
| public static final Pixmap. | |
| RGB888 | back to summary |
|---|---|
| public static final Pixmap. | |
| RGBA4444 | back to summary |
|---|---|
| public static final Pixmap. | |
| RGBA8888 | back to summary |
|---|---|
| public static final Pixmap. | |
| Format | back to summary |
|---|---|
| private Format() | |
| fromGdx2DPixmapFormat | back to summary |
|---|---|
| public static Pixmap. | |
| toGdx2DPixmapFormat | back to summary |
|---|---|
| public static int toGdx2DPixmapFormat(Pixmap. | |
| toGlFormat | back to summary |
|---|---|
| public static int toGlFormat(Pixmap. | |
| toGlType | back to summary |
|---|---|
| public static int toGlType(Pixmap. | |
| valueOf | back to summary |
|---|---|
| public static Pixmap. | |
| values | back to summary |
|---|---|
| public static Pixmap. | |