CVB++ 14.0
WrappedImage Class Reference

A wrapped image wraps another pixel buffer without owning it. More...

#include <cvb/wrapped_image.hpp>

Inherits Image.

Static Public Member Functions

static std::unique_ptr< WrappedImageFromGreyPixels (void *buffer, int bufferSize, int width, int height, DataType dataType, int pixelStride, int lineStride)
 Wraps, without copying, the given monochrome pixel buffer in an image. More...
 
static std::unique_ptr< WrappedImageFromGrey8Pixels (void *buffer, int width, int height)
 Wraps, without copying, the given Mono8 pixel buffer in a CvbImage. More...
 
static std::unique_ptr< WrappedImageFromRgbPixels (void *buffer, int bufferSize, int width, int height, DataType dataType, int pixelStride, int lineStride, int planeStride)
 Wraps, without copying, the given RGB pixel buffer in a CvbImage. More...
 
static std::unique_ptr< WrappedImageFromBgrPixels (void *buffer, int bufferSize, int width, int height, DataType dataType, int pixelStride, int lineStride, int planeStride)
 Wraps, without copying, the given BGR pixel buffer in a CvbImage. More...
 
static std::unique_ptr< WrappedImageFromHandle (HandleGuard< WrappedImage > &&guard)
 Creates a wrapped image from a classic API handle. More...
 
- Static Public Member Functions inherited from Image
static std::unique_ptr< ImageLoad (const String &fileName)
 Loads an image with the given file name. More...
 
static std::unique_ptr< ImageCreate (Size2D< int > size, int numPlanes=1, DataType dataType=DataType::Int8BppUnsigned())
 Creates an uninitialized image with the given parameters. More...
 
static std::unique_ptr< ImageCreate (int width, int height, int numPlanes=1, DataType dataType=DataType::Int8BppUnsigned())
 Creates an uninitialized image with the given parameters. More...
 
template<class RANGE >
static TypedRange< std::unique_ptr< Image >, ImagePtr, RANGE >::type FromImages (MappingOption mapping, const RANGE &images)
 Create an image that is the result of concatenating a series of input images. More...
 
template<class... IMAGES>
static VarArgRange< std::unique_ptr< Image >, constImage &, IMAGES... >::type FromImages (MappingOption mapping, const IMAGES &... images)
 Create an image that is the result of concatenating a series of input images. More...
 
template<class RANGE >
static TypedRange< std::unique_ptr< Image >, ImagePlane, RANGE >::type FromPlanes (MappingOption mapping, const RANGE &planes)
 Create an image that is the result of concatenating a series of input planes. More...
 
template<class... PLANES>
static VarArgRange< std::unique_ptr< Image >, ImagePlane &&, PLANES... >::type FromPlanes (MappingOption mapping, PLANES &&... planes)
 Create an image that is the result of concatenating a series of input planes. More...
 
static std::unique_ptr< ImageFromHandle (HandleGuard< Image > &&guard)
 Creates an image from a classic API handle. More...
 
template<class T , class... ARGS>
static std::unique_ptr< T > FromHandle (HandleGuard< Image > &&guard, ARGS &&... args)
 Creates an image from a classic API handle (typed). More...
 

Additional Inherited Members

- Public Member Functions inherited from Image
 Image (Size2D< int > size, int numPlanes=1, DataType dataType=DataType::Int8BppUnsigned())
 Constructs an uninitialized image with the given parameters. More...
 
 Image (int width, int height, int numPlanes=1, DataType dataType=DataType::Int8BppUnsigned())
 Constructs an uninitialized image with the given parameters. More...
 
 Image (const String &fileName)
 Loads an image with the given file name. More...
 
void * Handle () const noexcept
 Classic API image handle. More...
 
int PlanesCount () const noexcept
 Get the number of planes for this image. More...
 
bool PlaneDataTypesIdentical () const noexcept
 Check if all planes have the same data type. More...
 
ImagePlane Plane (int plane) const
 Indexed access to the individual plane information. More...
 
std::vector< ImagePlanePlanes () const noexcept
 Access all planes for this image. More...
 
std::vector< double > GetPixel (Point2D< int > position) const
 Gets the pixel values for all planes at a give position. More...
 
int Height () const noexcept
 Height of the image in pixels. More...
 
int Width () const noexcept
 Width of the image in pixels. More...
 
Cvb::ColorModel ColorModel () const noexcept
 Color model realized by this image. More...
 
void Save (const String &fileName) const
 Write the current content of the image into a file. More...
 
std::unique_ptr< ImageMap (Rect< int > rect) const
 Creates a mapped image of the region of this image. More...
 
std::unique_ptr< ImageMap (Rect< int > sourceRect, Size2D< int > targetSize) const
 Creates a mapped image of the region of that image scaled to the size. More...
 
std::unique_ptr< ImageClone () const
 Creates a new image object, that is a copy of the current instance. More...
 
void Copy (Image &targetImage, Rect< int > sourceRect, Point2D< int > targetPosition) const
 Copies the image data from the source rectangle of this image to the target position inside the target image. More...
 
void Copy (Image &targetImage) const
 Copies the image data from this image to the target image. More...
 
Size2D< int > Size () const noexcept
 Size of the image in pixels. More...
 
Rect< int > Bounds () const noexcept
 Bounding rectangle of the image in pixels. More...
 
void RaisePixelContentChanged () const
 Inform clients listening to the pixel content changed event, that the image data has been completely updated (full area). More...
 
void RaisePixelContentChanged (Rect< int > rect) const
 Inform clients listening to the pixel content changed event, that the image data has been updated in the given rectangle. More...
 
EventCookie RegisterEventPixelContentChanged (std::function< void(const Image &, Rect< int >)> handler)
 Register a listener to the pixel content changed event. More...
 
void UnregisterEventPixelContentChanged (EventCookie eventCookie) noexcept
 Manually unregister a listener from the pixel content changed event. More...
 
Point2D< double > ImageToPixelCoordinates (Point2D< double > point) const noexcept
 Convert a point from image to pixel coordinates. More...
 
Area2D ImageToPixelCoordinates (Area2D area) const noexcept
 Convert an Area2D from image to pixel coordinates. More...
 
Point2D< double > PixelToImageCoordinates (Point2D< double > point) const noexcept
 Convert a point from pixel to image coordinates. More...
 
Area2D PixelToImageCoordinates (Area2D area) const noexcept
 Convert an Area2D from pixel to image coordinates. More...
 
AffineMatrix2D CoordinateSystem () const noexcept
 Get the coordinate system of the image. More...
 
void SetCoordinateSystem (AffineMatrix2D affineMatrix) noexcept
 Set the coordinate system of the image. More...
 

Detailed Description

A wrapped image wraps another pixel buffer without owning it.

This class is not intended for general use. Providing invalid values or not ensuring the validity of the associated buffer at all times will most likely lead to severe problems in your application.

Member Function Documentation

◆ FromBgrPixels()

static std::unique_ptr< WrappedImage > FromBgrPixels ( void *  buffer,
int  bufferSize,
int  width,
int  height,
DataType  dataType,
int  pixelStride,
int  lineStride,
int  planeStride 
)
inlinestatic

Wraps, without copying, the given BGR pixel buffer in a CvbImage.

Parameters
[in]bufferPointer to the start of the pixel buffer.
[in]bufferSizeSize of the buffer in bytes.
[in]widthWidth of the image in pixels.
[in]heightHeight of the image in pixels.
[in]dataTypePixel data type.
[in]pixelStrideDistance in bytes between two neighboring pixels of the same plane, i.e. 1 for normal Mono8 images.
[in]lineStrideDistance in bytes between two neighboring lines of the same plane, i.e. width + optional padding for Mono8 images.
[in]planeStrideDistance in bytes between two neighboring info, i.e. 1 for an interleaved RGB8 image.
Returns
Newly created image pointer.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromGrey8Pixels()

static std::unique_ptr< WrappedImage > FromGrey8Pixels ( void *  buffer,
int  width,
int  height 
)
inlinestatic

Wraps, without copying, the given Mono8 pixel buffer in a CvbImage.

Parameters
[in]bufferPointer to the start of the pixel buffer.
[in]widthWidth of the image in pixels.
[in]heightHeight of the image in pixels.
Returns
Newly created image pointer.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromGreyPixels()

static std::unique_ptr< WrappedImage > FromGreyPixels ( void *  buffer,
int  bufferSize,
int  width,
int  height,
DataType  dataType,
int  pixelStride,
int  lineStride 
)
inlinestatic

Wraps, without copying, the given monochrome pixel buffer in an image.

Parameters
[in]bufferPointer to the start of the pixel buffer.
[in]bufferSizeSize of the buffer in bytes.
[in]widthWidth of the image in pixels.
[in]heightHeight of the image in pixels.
[in]dataTypePixel data type.
[in]pixelStrideDistance in bytes between two neighboring pixels of the same plane, i.e. 1 for normal Mono8 images.
[in]lineStrideDistance in bytes between two neighboring lines of the same plane, i.e. width + optional padding for Mono8 images.
Returns
Newly created image pointer.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromHandle()

static std::unique_ptr< WrappedImage > FromHandle ( HandleGuard< WrappedImage > &&  guard)
inlinestatic

Creates a wrapped image from a classic API handle.

Parameters
[in]guardLife time guard for C-API handle.
Returns
The wrapped image created from the classic API handle.
Exceptions
Anyexception derived from std::exception including CvbException.

The wrapped image takes ownership of the handle, so you must share it before using this function.

◆ FromRgbPixels()

static std::unique_ptr< WrappedImage > FromRgbPixels ( void *  buffer,
int  bufferSize,
int  width,
int  height,
DataType  dataType,
int  pixelStride,
int  lineStride,
int  planeStride 
)
inlinestatic

Wraps, without copying, the given RGB pixel buffer in a CvbImage.

Parameters
[in]bufferPointer to the start of the pixel buffer.
[in]bufferSizeSize of the buffer in bytes.
[in]widthWidth of the image in pixels.
[in]heightHeight of the image in pixels.
[in]dataTypePixel data type.
[in]pixelStrideDistance in bytes between two neighboring pixels of the same plane, i.e. 1 for normal Mono8 images.
[in]lineStrideDistance in bytes between two neighboring lines of the same plane, i.e. width + optional padding for Mono8 images.
[in]planeStrideDistance in bytes between two neighboring info, i.e. 1 for an interleaved RGB8 image.
Returns
Newly created image pointer.
Exceptions
Anyexception derived from std::exception including CvbException.