Hi, I need to call this function from an external method, and I'm not figuring out how to allocate the output pointer to pass it's pointer.
size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output);
I Have tried these two forms:
Note that the difference between my two attempts is that I've first declared the output Ptr ByRef and the second one was by value.
Declare Function WebPEncodeRGB Lib "libwebp.dylib" (rgb As Ptr, width As Int16, height As Int16, stride As Int16, quality_factor As Single, ByRef output As Ptr) As Uint16 Dim output As Ptr
and pass output as the last parameter, but it crashes:
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: EXC_I386_GPFLT Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler  Application Specific Information: Performing @selector(performClick:) from sender XOJButton 0x60000375dc30 Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libwebp.dylib 0x000000010d753243 ConvertRGB24ToY_SSE41 + 73 1 libwebp.dylib 0x000000010d75f75a ImportYUVAFromRGBA + 2427 2 libwebp.dylib 0x000000010d75ec64 Import + 269 3 libwebp.dylib 0x000000010d75e508 Encode + 286 4 libwebp.dylib 0x000000010d75e3e4 WebPEncodeRGB + 27
Declare Function WebPEncodeRGB Lib "libwebp.dylib" (rgb As Ptr, width As Int16, height As Int16, stride As Int16, quality_factor As Single, output As Ptr) As Uint16 Dim output As Ptr
and pass output as the last parameter, again. This time, the code runs ok, but the pointer remais &h0000000000000000 and I don't have a way to access the resulting data.
How can I allocate memory to pass it's pointer to an external method?