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

ConstructorDescription
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

MethodDescription
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:

ParameterTypeDescription
widthintThe width, in pixels, of the new Bitmap.
heightintThe 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:

ParameterTypeDescription
filenamejava.lang.StringThe 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:

ParameterTypeDescription
filenamejava.lang.StringThe name of the bitmap file.
useIcmbooleantrue 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:

ParameterTypeDescription
streamjava.io.InputStreamThe 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:

ParameterTypeDescription
streamjava.io.InputStreamThe data stream used to load the image.
useIcmbooleantrue 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:

ParameterTypeDescription
widthintThe width, in pixels, of the new Bitmap.
heightintThe height, in pixels, of the new Bitmap.
formatintThe 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:

ParameterTypeDescription
widthintThe width, in pixels, of the new Bitmap.
heightintThe height, in pixels, of the new Bitmap.
strideintThe byte offset between the beginning of one scan line and the next, must be a multiple of four.
formatintThe PixelFormat(Image.getPixelFormat) enumeration for the new Bitmap.
dataint[]The pixel data.

Bitmap(Image original)

public Bitmap(Image original)

Initializes a new instance of the Bitmap class from the specified existing image.

Parameters:

ParameterTypeDescription
originalImageThe 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:

ParameterTypeDescription
originalImageThe Image from which to create the new Bitmap
newSizeSizeThe 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:

ParameterTypeDescription
originalImageThe Image from which to create the new Bitmap.
widthintThe width, in pixels, of the new Bitmap.
heightintThe 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:

ParameterTypeDescription
valueColorPalette

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:

ParameterTypeDescription
rectRectangleDefines the portion of this Bitmap to copy. Coordinates are relative to this Bitmap.
formatintSpecifies 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:

ParameterTypeDescription
rectRectangleFDefines the portion of this Bitmap to copy.
formatintSpecifies 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:

ParameterTypeDescription
xDpifloatThe horizontal resolution, in dots per inch, of the Bitmap.
yDpifloatThe 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:

ParameterTypeDescription
rectRectangleA Rectangle structure specifying the portion of the Bitmap to lock.
flagsintAn ImageLockMode enumeration specifying the access level (read/write) for the Bitmap.
formatintA 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:

ParameterTypeDescription
bitmapDataBitmapDataA 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:

ParameterTypeDescription
xintThe x-coordinate of the pixel to retrieve.
yintThe 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:

ParameterTypeDescription
xintThe x-coordinate of the pixel to set.
yintThe y-coordinate of the pixel to set.
colorColorA 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:

ParameterTypeDescription
pixelsint[]Array to place bitmap pixels. Must have enough capacity.

writeArgb32Pixels(int[] pixels)

public final void writeArgb32Pixels(int[] pixels)

Writes pixels to the bitmap.

Parameters:

ParameterTypeDescription
pixelsint[]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:

ParameterTypeDescription
transparentColorColorThe 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:

ParameterTypeDescription
rotateFlipTypeintA 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:

ParameterTypeDescription
propidintThe 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:

ParameterTypeDescription
propidintThe 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:

ParameterTypeDescription
propitemPropertyItemThe PropertyItem to be stored.