Skip to content

Commit

Permalink
Merge pull request #17 from Artomatix/FixPythonBindings
Browse files Browse the repository at this point in the history
Get AIMG python extension compiling
  • Loading branch information
cherylart authored Apr 8, 2019
2 parents 916a6d2 + ef1cc54 commit d6e59ad
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bindings/python/AImg/AImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ def write(io_or_path, data, fileFormat, profileName, colourProfile, encodeOption
if colourProfile is not None:
colourProfileLen = len(colourProfile)

errCode, imgCapsule = native.write(fileFormat.val, data, stream, width, height, fmt.val, profileName, colourProfile, colourProfileLen, encodeOptionsTuple)
AImgExceptions.checkErrorCode(imgCapsule, errCode)
errCode, imgCapsule = native.write(fileFormat.val, data, stream, width, height, fmt.val, fmt.val, profileName, colourProfile, colourProfileLen, encodeOptionsTuple)
AImgExceptions.checkErrorCode(imgCapsule, errCode)
Empty file modified bindings/python/tests.py
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src_c/AIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ int32_t AImgConvertFormat(void* src, void* dest, int32_t width, int32_t height,
return AImgErrorCode::AIMG_SUCCESS;
}

bool AImgIsFormatSupported(int32_t fileFormat, int32_t outputFormat)
int32_t AImgIsFormatSupported(int32_t fileFormat, int32_t outputFormat)
{
return loaders[fileFormat]->isFormatSupported(outputFormat);
}
Expand Down Expand Up @@ -896,4 +896,4 @@ void AIDestroySimpleMemoryBufferCallbacks(ReadCallback readCallback, WriteCallba

auto data = (SimpleMemoryCallbackData*)callbackData;
delete data;
}
}
2 changes: 1 addition & 1 deletion src_c/AIL.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extern "C"
EXPORT_FUNC void AIGetFormatDetails(int32_t format, int32_t* numChannels, int32_t* bytesPerChannel, int32_t* floatOrInt);
EXPORT_FUNC int32_t AImgConvertFormat(void* src, void* dest, int32_t width, int32_t height, int32_t inFormat, int32_t outFormat);

EXPORT_FUNC bool AImgIsFormatSupported(int32_t fileFormat, int32_t outputFormat);
EXPORT_FUNC int32_t AImgIsFormatSupported(int32_t fileFormat, int32_t outputFormat);

EXPORT_FUNC int32_t AImgGetWhatFormatWillBeWrittenForData(int32_t fileFormat, int32_t inputFormat, int32_t outputFormat);

Expand Down
5 changes: 3 additions & 2 deletions src_c/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@ static PyObject* pyail_write(PyObject* self, PyObject* args)
PyObject* fileLikeObj;
int width, height;
int inputFormat;
int outputFormat;
const char* profileName;
PyArrayObject* colourProfileObj;
int colourProfileLen;
PyObject* encodingOptionsTuple;
if (!PyArg_ParseTuple(args, "iOOiiisOIO", &fileFormat, &sourceArrayObj, &fileLikeObj, &width, &height, &inputFormat, &profileName, &colourProfileObj, &colourProfileLen, &encodingOptionsTuple))
if (!PyArg_ParseTuple(args, "iOOiiiisOIO", &fileFormat, &sourceArrayObj, &fileLikeObj, &width, &height, &inputFormat, &outputFormat, &profileName, &colourProfileObj, &colourProfileLen, &encodingOptionsTuple))
return NULL;

PyAIL_callback_data* callbackData;
Expand All @@ -288,7 +289,7 @@ static PyObject* pyail_write(PyObject* self, PyObject* args)

callbackData->threadState = PyEval_SaveThread();

int err = AImgWriteImage(wImg, PyArray_DATA(sourceArrayObj), width, height, inputFormat, profileName, colourProfile, colourProfileLen, pyail_WriteCallback, pyail_TellCallback, pyail_SeekCallback, callbackData, encodingOptions);
int err = AImgWriteImage(wImg, PyArray_DATA(sourceArrayObj), width, height, inputFormat, outputFormat, profileName, colourProfile, colourProfileLen, pyail_WriteCallback, pyail_TellCallback, pyail_SeekCallback, callbackData, encodingOptions);
PyEval_RestoreThread(callbackData->threadState);

pyail_destroyCallbackData(callbackData);
Expand Down

0 comments on commit d6e59ad

Please sign in to comment.