Pylon::CPylonImageUserBufferEventHandler#
The CPylonImage user buffer event handler base class. More…
#include <pylon/PylonImageUserBufferEventHandler.h>
Public Functions#
Name | |
---|---|
virtual void | OnPylonImageUserBufferDetached(void * pUserBuffer, size_t bufferSizeBytes) This method is called after the image class has released its user buffer. |
Detailed Description#
The CPylonImage user buffer event handler base class.
You can optionally pass an object derived from this class when calling CPylonImage::AttachUserBuffer(). When the CPylonImage doesn't need the user buffer anymore, it will call the CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() method. You can override this function to execute your custom code when the user buffer has been detached implicitly.
The user is responsible for ensuring the object is valid until CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() has been called.
Public Functions Documentation#
function OnPylonImageUserBufferDetached#
This method is called after the image class has released its user buffer.
Parameters:
- pUserBuffer Pointer to the user buffer passed when the user buffer was attached using CPylonImage::AttachUserBuffer().
- bufferSizeBytes Size of the user buffer passed when the user buffer was attached using CPylonImage::AttachUserBuffer().
Error Safety:
This function must not throw any exceptions.
This method is called after the image class releases its image buffer. In case a user buffer has been attached using CPylonImage::AttachUserBuffer() you can use this to free your user buffer.
In case you created the event handler on the heap using new
, you can call delete this
at the end of the function.
// Sample handler to show how to delete the handler when allocating the handler on the heap.
class MyHandler : public CPylonImageUserBufferEventHandler {
OnPylonImageUserBufferDetached( void* pUserBuffer, size_t bufferSizeBytes ) override {
// Use our custom memory allocator to free the user buffer.
MyCustomFreeMemory( pUserBuffer );
// Delete the handler.
delete this;
}
};
// Use our custom memory allocator for pixel data.
void* pUserBuffer = MyCustomAllocateMemory( 640 * 480 );
// Attach user buffer using a heap-allocated event handler.
CPylonImage image;
image.AttachUserBuffer(pUserBuffer, (640 * 480), PixelType_Mono8, 640, 480, 0, ImageOrientation_TopDown, new MyHandler() );
The default implementation does nothing. You can override this function to execute custom code.