I'm trying to make a python program that can run Photoshop Plugins by using this DLL library from Spetric - https://github.com/spetric/Photoshop-Plugin-Host
I need to send an image loaded by opencv to the dll (while I can read c++ I cannot program in it and have never been able to get the dll to compile for edits such as loading the image directly from a filename)
The description of the function is
pspiSetImage(TImgType type, int width, int height, void *imageBuff, int imageStride, void *alphaBuff = 0, int alphaStride = 0);
I have tried several suggestions and solutions found here on stackoverflow but they all result in the same thing "OSError: exception: access violation writing 0x00000000"
Which is weird because I thought the idea was to pass in a pointer to a long buffer of data and that number wouldn't be 0. I've checked the value/output and it never is zero that I pass in.
I have tried accessing the __array_interface++['data'][0], using ctypes.data_as built into the numpy object, various versions of POINTER and c_void_p. My fundamental misunderstanding of what's needed and how to get it and pass it is my problem.
Are there any suggestions or helpful hints to point me in the right direction?
EDIT: Here is the code I'm currently working with
import ctypes
import cv2
plugins = {}
def main(args=None):
plugin_host = ctypes.CDLL('.\\pspiHost.dll')
plugin_host.pspiSetPath(".\\8bf filters\\")
# Any image will do, I used a PNG to test alpha transparency
im = cv2.imread('.\\fish.png', cv2.IMREAD_UNCHANGED)
array = im.ctypes.data_as(ctypes.POINTER(ctypes.c_void_p))
width = im.shape[0]
height = im.shape[1]
# 1 in first parameter is for RGBA format, I'm using a png with transparency
plugin_host.pspiSetImage(ctypes.c_int(1),
ctypes.c_int(width),
ctypes.c_int(height),
array,
ctypes.c_int(0))
if __name__=='__main__':
main()