Loading...
Searching...
No Matches
juce::Image::BitmapData Class Referencefinal

## Detailed Description

Retrieves a section of an image as raw pixel data, so it can be read or written to.

You should only use this class as a last resort - messing about with the internals of an image is only recommended for people who really know what they're doing!

A BitmapData object should be used as a temporary, stack-based object. Don't keep one hanging around while the image is being used elsewhere.

Depending on the way the image class is implemented, this may create a temporary buffer which is copied back to the image when the object is deleted, or it may just get a pointer directly into the image's raw data.

You can use the stride and data values in this class directly, but don't alter them! The actual format of the pixel data depends on the image's format - see Image::getFormat(), and the PixelRGB, PixelARGB and PixelAlpha classes for more info.

The documentation for this class was generated from the following file:

- juce_graphics/images/juce_Image.h

## Classes

class | BitmapDataReleaser
| Used internally by custom image types to manage pixel data lifetime. More...

## Public Types

enum | ReadWriteMode { readOnly , writeOnly , readWrite }

## Public Member Functions

| BitmapData (Image &image, int x, int y, int w, int h, ReadWriteMode mode)
| BitmapData (const Image &image, Rectangle< int >, ReadWriteMode mode)
| BitmapData (const Image &image, int x, int y, int w, int h)
| BitmapData (const Image &image, ReadWriteMode mode)
uint8 * | getLinePointer (int y) const noexcept
| Returns a pointer to the start of a line in the image.
uint8 * | getPixelPointer (int x, int y) const noexcept
| Returns a pointer to a pixel in the image.
Colour | getPixelColour (int x, int y) const noexcept
| Returns the colour of a given pixel.
void | setPixelColour (int x, int y, Colour colour) const noexcept
| Sets the colour of a given pixel.
Rectangle< int > | getBounds () const noexcept
| Returns the size of the bitmap.
bool | convertFrom (const Image::BitmapData &src)
| Attempts to copy the contents of src into this bitmap data.

## Public Attributes

uint8 * | data
| The raw pixel data, packed according to the image's pixel format.
size_t | size
| The number of valid/allocated bytes after data.
PixelFormat | pixelFormat
| The format of the data.
int | lineStride
| The number of bytes between each line.
int | pixelStride
| The number of bytes between each pixel.
int | width
int | height
std::unique_ptr< BitmapDataReleaser > | dataReleaser

## Member Enums

## ReadWriteMode

enum juce::Image::BitmapData::ReadWriteMode

Enumerator
readOnly |
writeOnly |
readWrite |

## Constructors and Destructors

## BitmapData() [1/4]

juce::Image::BitmapData::BitmapData | ( | Image & | image,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h,
|  | ReadWriteMode | mode )

References h, juce::Image::Image(), w, x, and y.

## BitmapData() [2/4]

juce::Image::BitmapData::BitmapData | ( | const Image & | image,
|  | Rectangle< int > | ,
|  | ReadWriteMode | mode )

References juce::Image::Image().

## BitmapData() [3/4]

juce::Image::BitmapData::BitmapData | ( | const Image & | image,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h )

References h, juce::Image::Image(), w, x, and y.

## BitmapData() [4/4]

juce::Image::BitmapData::BitmapData | ( | const Image & | image,
|  | ReadWriteMode | mode )

References juce::Image::Image().

## Member Functions

## getLinePointer()

uint8 * juce::Image::BitmapData::getLinePointer | ( | int | y | ) | const

inline noexcept

Returns a pointer to the start of a line in the image.

The coordinate you provide here isn't checked, so it's the caller's responsibility to make sure it's not out-of-range.

References data, lineStride, and y.

## getPixelPointer()

uint8 * juce::Image::BitmapData::getPixelPointer | ( | int | x,
|  | int | y ) const

inline noexcept

Returns a pointer to a pixel in the image.

The coordinates you give here are not checked, so it's the caller's responsibility to make sure they're not out-of-range.

References data, lineStride, pixelStride, x, and y.

## getPixelColour()

Colour juce::Image::BitmapData::getPixelColour | ( | int | x,
|  | int | y ) const

noexcept

Returns the colour of a given pixel.

For performance reasons, this won't do any bounds-checking on the coordinates, so it's the caller's responsibility to make sure they're within the image's size.

References x, and y.

## setPixelColour()

void juce::Image::BitmapData::setPixelColour | ( | int | x,
|  | int | y,
|  | Colour | colour ) const

noexcept

Sets the colour of a given pixel.

For performance reasons, this won't do any bounds-checking on the coordinates, so it's the caller's responsibility to make sure they're within the image's size.

References x, and y.

## getBounds()

Rectangle< int > juce::Image::BitmapData::getBounds | ( |  | ) | const

inline noexcept

Returns the size of the bitmap.

References height, and width.

## convertFrom()

bool juce::Image::BitmapData::convertFrom | ( | const Image::BitmapData & | src | ) |

Attempts to copy the contents of src into this bitmap data.

Returns true on success, and false otherwise.

The source BitmapData must be readable, and the destination (current) BitmapData must be writeable. This function cannot check for this precondition, so you must ensure this yourself!

## Member Data Documentation

## data

uint8* juce::Image::BitmapData::data

The raw pixel data, packed according to the image's pixel format.

Referenced by getLinePointer(), and getPixelPointer().

## size

size_t juce::Image::BitmapData::size

The number of valid/allocated bytes after data.

May be smaller than "lineStride * height" if this is a section of a larger image.

## pixelFormat

PixelFormat juce::Image::BitmapData::pixelFormat

The format of the data.

## lineStride

int juce::Image::BitmapData::lineStride

The number of bytes between each line.

Referenced by getLinePointer(), and getPixelPointer().

## pixelStride

int juce::Image::BitmapData::pixelStride

The number of bytes between each pixel.

Referenced by getPixelPointer().

## width

int juce::Image::BitmapData::width

Referenced by getBounds().

## height

int juce::Image::BitmapData::height

Referenced by getBounds().

## dataReleaser

std::unique_ptr<BitmapDataReleaser> juce::Image::BitmapData::dataReleaser

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited