Bitmap
Inheritance: java.lang.Object, com.aspose.drawing.Image
public class Bitmap extends Image
Encapsulates a bitmap, which consists of the pixel data for a graphics image and its attributes. A Bitmap is an object used to work with images defined by pixel data.
Constructors
Constructor | Description |
---|---|
Bitmap(int width, int height) | Initializes a new instance of the Bitmap class with the specified size. |
Bitmap(String filename) | Initializes a new instance of the Bitmap class from the specified file. |
Bitmap(String filename, boolean useIcm) | Initializes a new instance of the Bitmap class from the specified file. |
Bitmap(InputStream stream) | Initializes a new instance of the Bitmap class from the specified data stream. |
Bitmap(InputStream stream, boolean useIcm) | Initializes a new instance of the Bitmap class from the specified data stream. |
Bitmap(int width, int height, int format) | Initializes a new instance of the Bitmap class with the specified size and format. |
Bitmap(int width, int height, int stride, int format, int[] data) | Initializes a new instance of the Bitmap class with the specified size and pixel data. |
Bitmap(Image original) | Initializes a new instance of the Bitmap class from the specified existing image. |
Bitmap(Image original, Size newSize) | Initializes a new instance of the Bitmap class from the specified existing image, scaled to the specified size. |
Bitmap(Image original, int width, int height) | Initializes a new instance of the Bitmap class from the specified existing image, scaled to the specified size. |
Methods
Method | Description |
---|---|
getWidth() | Gets the width, in pixels, of this Bitmap. |
getHeight() | Gets the height, in pixels, of this Bitmap. |
getRawFormat() | Gets the file format of this Image. |
getPixelFormat() | Gets the pixel format for this Image. |
getPalette() | Gets or sets the color palette used for this Image. |
setPalette(ColorPalette value) | Gets or sets the color palette used for this Image. |
getFrameDimensionsList() | Gets an array of GUIDs that represent the dimensions of frames within this Image. |
getPropertyIdList() | Gets IDs of the property items stored in this Image. |
getPropertyItems() | Gets all the property items (pieces of metadata) stored in this Image. |
deepClone(Rectangle rect, int format) | Creates a copy of the section of this Bitmap defined by Rectangle structure and with a specified PixelFormat (Image.getPixelFormat) enumeration. |
deepClone(RectangleF rect, int format) | Creates a copy of the section of this Bitmap defined with a specified PixelFormat enumeration. |
setResolution(float xDpi, float yDpi) | Sets the resolution for this Bitmap. |
lockBits(Rectangle rect, int flags, int format) | Locks a Bitmap into system memory. |
unlockBits(BitmapData bitmapData) | Unlocks this Bitmap from system memory. |
getPixel(int x, int y) | Gets the color of the specified pixel in this Bitmap. |
setPixel(int x, int y, Color color) | Sets the color of the specified pixel in this Bitmap. |
readArgb32Pixels(int[] pixels) | Reads bitmap pixels in ARGB32 format into given array. |
writeArgb32Pixels(int[] pixels) | Writes pixels to the bitmap. |
makeTransparent() | Makes the specified color transparent for this Bitmap. |
makeTransparent(Color transparentColor) | Makes the specified color transparent for this Bitmap. |
rotateFlip(int rotateFlipType) | This method rotates, flips, or rotates and flips the Image. |
getPropertyItem(int propid) | Gets the specified property item from this Image. |
removePropertyItem(int propid) | Removes the specified property item from this Image. |
setPropertyItem(PropertyItem propitem) | Stores a property item (piece of metadata) in this Image. |
Bitmap(int width, int height)
public Bitmap(int width, int height)
Initializes a new instance of the Bitmap class with the specified size.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The width, in pixels, of the new Bitmap. |
height | int | The height, in pixels, of the new Bitmap. |
The only supported internal bitmap format at the moment is equivalent to PixelFormat.Format32bppPArgb
. |
Bitmap(String filename)
public Bitmap(String filename)
Initializes a new instance of the Bitmap class from the specified file.
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | The name of the bitmap file. |
Bitmap(String filename, boolean useIcm)
public Bitmap(String filename, boolean useIcm)
Initializes a new instance of the Bitmap class from the specified file.
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | The name of the bitmap file. |
useIcm | boolean | true to use color correction for this Bitmap; otherwise, false. |
Bitmap(InputStream stream)
public Bitmap(InputStream stream)
Initializes a new instance of the Bitmap class from the specified data stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The data stream used to load the image. |
Bitmap(InputStream stream, boolean useIcm)
public Bitmap(InputStream stream, boolean useIcm)
Initializes a new instance of the Bitmap class from the specified data stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The data stream used to load the image. |
useIcm | boolean | true to use color correction for this Bitmap; otherwise, false . |
Bitmap(int width, int height, int format)
public Bitmap(int width, int height, int format)
Initializes a new instance of the Bitmap class with the specified size and format.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The width, in pixels, of the new Bitmap. |
height | int | The height, in pixels, of the new Bitmap. |
format | int | The PixelFormat (Image.getPixelFormat) enumeration for the new Bitmap. |
Bitmap(int width, int height, int stride, int format, int[] data)
public Bitmap(int width, int height, int stride, int format, int[] data)
Initializes a new instance of the Bitmap class with the specified size and pixel data.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The width, in pixels, of the new Bitmap. |
height | int | The height, in pixels, of the new Bitmap. |
stride | int | The byte offset between the beginning of one scan line and the next, must be a multiple of four. |
format | int | The PixelFormat (Image.getPixelFormat) enumeration for the new Bitmap. |
data | int[] | The pixel data. |
Bitmap(Image original)
public Bitmap(Image original)
Initializes a new instance of the Bitmap class from the specified existing image.
Parameters:
Parameter | Type | Description |
---|---|---|
original | Image | The Image from which to create the new Bitmap. |
Bitmap(Image original, Size newSize)
public Bitmap(Image original, Size newSize)
Initializes a new instance of the Bitmap class from the specified existing image, scaled to the specified size.
Parameters:
Parameter | Type | Description |
---|---|---|
original | Image | The Image from which to create the new Bitmap |
newSize | Size | The Size (Image.getSize) structure that represent the size of the new Bitmap. |
Bitmap(Image original, int width, int height)
public Bitmap(Image original, int width, int height)
Initializes a new instance of the Bitmap class from the specified existing image, scaled to the specified size.
Parameters:
Parameter | Type | Description |
---|---|---|
original | Image | The Image from which to create the new Bitmap. |
width | int | The width, in pixels, of the new Bitmap. |
height | int | The height, in pixels, of the new Bitmap. |
getWidth()
public int getWidth()
Gets the width, in pixels, of this Bitmap.
Returns: int
getHeight()
public int getHeight()
Gets the height, in pixels, of this Bitmap.
Returns: int
getRawFormat()
public ImageFormat getRawFormat()
Gets the file format of this Image.
Returns: ImageFormat - The ImageFormat that represents the file format of this Image.
getPixelFormat()
public int getPixelFormat()
Gets the pixel format for this Image.
Returns:
int - A PixelFormat
(Image.getPixelFormat) that represents the pixel format for this Image.
getPalette()
public ColorPalette getPalette()
Gets or sets the color palette used for this Image.
Returns: ColorPalette - A ColorPalette that represents the color palette used for this Image.
setPalette(ColorPalette value)
public void setPalette(ColorPalette value)
Gets or sets the color palette used for this Image.
Parameters:
Parameter | Type | Description |
---|---|---|
value | ColorPalette |
getFrameDimensionsList()
public UUID[] getFrameDimensionsList()
Gets an array of GUIDs that represent the dimensions of frames within this Image.
Returns: java.util.UUID[] - An array of GUIDs that specify the dimensions of frames within this Image from most significant to least significant.
getPropertyIdList()
public int[] getPropertyIdList()
Gets IDs of the property items stored in this Image.
Returns: int[] - An array of the property IDs, one for each property item stored in this image.
getPropertyItems()
public PropertyItem[] getPropertyItems()
Gets all the property items (pieces of metadata) stored in this Image.
Returns: com.aspose.drawing.imaging.PropertyItem[] - An array of PropertyItem objects, one for each property item stored in the image.
deepClone(Rectangle rect, int format)
public final Bitmap deepClone(Rectangle rect, int format)
Creates a copy of the section of this Bitmap defined by Rectangle structure and with a specified PixelFormat
(Image.getPixelFormat) enumeration.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | Defines the portion of this Bitmap to copy. Coordinates are relative to this Bitmap. |
format | int | Specifies the PixelFormat (Image.getPixelFormat) enumeration for the destination Bitmap. |
Returns: Bitmap - The new Bitmap that this method creates.
deepClone(RectangleF rect, int format)
public final Bitmap deepClone(RectangleF rect, int format)
Creates a copy of the section of this Bitmap defined with a specified PixelFormat enumeration.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | RectangleF | Defines the portion of this Bitmap to copy. |
format | int | Specifies the PixelFormat enumeration for the destination Bitmap. |
Returns: Bitmap - The Bitmap that this method creates.
setResolution(float xDpi, float yDpi)
public final void setResolution(float xDpi, float yDpi)
Sets the resolution for this Bitmap.
Parameters:
Parameter | Type | Description |
---|---|---|
xDpi | float | The horizontal resolution, in dots per inch, of the Bitmap. |
yDpi | float | The vertical resolution, in dots per inch, of the Bitmap. |
lockBits(Rectangle rect, int flags, int format)
public final BitmapData lockBits(Rectangle rect, int flags, int format)
Locks a Bitmap into system memory.
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | A Rectangle structure specifying the portion of the Bitmap to lock. |
flags | int | An ImageLockMode enumeration specifying the access level (read/write) for the Bitmap. |
format | int | A PixelFormat (Image.getPixelFormat) enumeration specifying the data format of this Bitmap. |
Returns: BitmapData - A BitmapData containing information about this lock operation.
unlockBits(BitmapData bitmapData)
public final void unlockBits(BitmapData bitmapData)
Unlocks this Bitmap from system memory.
Parameters:
Parameter | Type | Description |
---|---|---|
bitmapData | BitmapData | A BitmapData specifying information about the lock operation. |
getPixel(int x, int y)
public final Color getPixel(int x, int y)
Gets the color of the specified pixel in this Bitmap.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The x-coordinate of the pixel to retrieve. |
y | int | The y-coordinate of the pixel to retrieve. |
Returns: Color - A Color structure that represents the color of the specified pixel.
setPixel(int x, int y, Color color)
public final void setPixel(int x, int y, Color color)
Sets the color of the specified pixel in this Bitmap.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The x-coordinate of the pixel to set. |
y | int | The y-coordinate of the pixel to set. |
color | Color | A Color structure that represents the color to assign to the specified pixel. |
readArgb32Pixels(int[] pixels)
public final void readArgb32Pixels(int[] pixels)
Reads bitmap pixels in ARGB32 format into given array.
Parameters:
Parameter | Type | Description |
---|---|---|
pixels | int[] | Array to place bitmap pixels. Must have enough capacity. |
writeArgb32Pixels(int[] pixels)
public final void writeArgb32Pixels(int[] pixels)
Writes pixels to the bitmap.
Parameters:
Parameter | Type | Description |
---|---|---|
pixels | int[] | Array with source pixels in ARGB32 format. Must have enough length. |
makeTransparent()
public final void makeTransparent()
Makes the specified color transparent for this Bitmap.
makeTransparent(Color transparentColor)
public final void makeTransparent(Color transparentColor)
Makes the specified color transparent for this Bitmap.
Parameters:
Parameter | Type | Description |
---|---|---|
transparentColor | Color | The Color structure that represents the color to make transparent. |
rotateFlip(int rotateFlipType)
public void rotateFlip(int rotateFlipType)
This method rotates, flips, or rotates and flips the Image.
Parameters:
Parameter | Type | Description |
---|---|---|
rotateFlipType | int | A RotateFlipType member that specifies the type of rotation and flip to apply to the image. |
getPropertyItem(int propid)
public PropertyItem getPropertyItem(int propid)
Gets the specified property item from this Image.
Parameters:
Parameter | Type | Description |
---|---|---|
propid | int | The ID of the property item to get. |
Returns: PropertyItem - The PropertyItem this method gets.
removePropertyItem(int propid)
public void removePropertyItem(int propid)
Removes the specified property item from this Image.
Parameters:
Parameter | Type | Description |
---|---|---|
propid | int | The ID of the property item to remove. |
setPropertyItem(PropertyItem propitem)
public void setPropertyItem(PropertyItem propitem)
Stores a property item (piece of metadata) in this Image.
Parameters:
Parameter | Type | Description |
---|---|---|
propitem | PropertyItem | The PropertyItem to be stored. |