Skip to content

Commit

Permalink
Merged PR 17963: Prepare pypylon 1.9.0rc2 Release
Browse files Browse the repository at this point in the history
Added the ImageDecompressor fix
  • Loading branch information
Stefan Klug authored and Stefan Klug committed Feb 6, 2023
2 parents 71c5bd8 + 9d15453 commit 619c28e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
5 changes: 3 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Version 1.9.0rc1
- Date 2022-12-13
Version 1.9.0rc2
- Date 2023-02-06
- Reduced the number of the python versions that are used for CI on
Windows: Dropped 3.4 and 3.5 completely and the 32 bit builds of the
remaining versions.
- Added support for pixel formats Bayer**16 in GetArray()
- Fixed decoding problems when detecting MSVC version.
- Added CI builds for python 3.11
- Fixed memory leak in ImageDecompressor

Version 1.8.0
- Date 2022-02-14
Expand Down
46 changes: 31 additions & 15 deletions src/pylon/ImageDecompressor.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
%rename(ImageDecompressor) Pylon::CImageDecompressor;
%rename(CompressionInfo) Pylon::CompressionInfo_t;

%typemap(out) Pylon::CPylonImage*
%{
$result = SWIG_NewPointerObj($1, $descriptor(Pylon::CPylonImage*), SWIG_POINTER_OWN );
%}

%typemap(typecheck,precedence=SWIG_TYPECHECK_CHAR) (const void* pGrabBuffer, size_t payloadSize)
%{
$1 = (PyBytes_Check($input) || PyByteArray_Check($input)) ? 1 : 0;
%}

%typemap(in) (const void* pGrabBuffer, size_t payloadSize)
%{
if (PyBytes_Check($input)) {
$1 = PyBytes_AsString($input);
$2 = PyBytes_Size($input);
} else if (PyByteArray_Check($input)) {
$1 = PyByteArray_AsString($input);
$2 = PyByteArray_Size($input);
} else {
throw INVALID_ARGUMENT_EXCEPTION("Invalid type of buffer (bytes and bytearray are supported)!.");
}
%}

%extend Pylon::CompressionInfo_t {
%pythoncode %{
def to_dict(self):
Expand Down Expand Up @@ -135,24 +158,17 @@
return result;
}

Pylon::CPylonImage * DecompressImage(PyObject * pData)
Pylon::CPylonImage * DecompressImage(const CGrabResultPtr& grabResult)
{
PyObject * pGrabBuffer = NULL;

if (PyObject_HasAttrString(pData, "GetBuffer"))
{
// if this is something that supports "GetBuffer", we better use it.
pGrabBuffer = PyObject_CallMethod(pData, "GetBuffer", NULL);
} else {
// we have to assume that this is some kind of byte-like thing
pGrabBuffer = pData;
}

const char * payloadBuffer = NULL;
size_t payloadSize = extractByteLikePyObject(pGrabBuffer, payloadBuffer);
Pylon::CPylonImage * image = new Pylon::CPylonImage();
$self->DecompressImage(*image, grabResult);
return image;
}

Pylon::CPylonImage * DecompressImage(const void* pGrabBuffer, size_t payloadSize)
{
Pylon::CPylonImage * image = new Pylon::CPylonImage();
$self->DecompressImage(*image, payloadBuffer, payloadSize);
$self->DecompressImage(*image, pGrabBuffer, payloadSize);
return image;
}
}
Expand Down

0 comments on commit 619c28e

Please sign in to comment.