Closed felipetrentin closed 1 year ago
Your situation is why I added a "User pointer" to the JPEGDRAW structure. Use the setUserPointer(void *p) method (before you call decode) to pass a pointer to whatever info you need in your Draw callback. It's the pDraw->pUser variable.
this isn't a problem with the library itself rather than a misunderstanding of my part.
I'm doing a project which has 3 Adafruit_ST7789 screens. I've been trying to create a generic callback instead of having identical callbacks like JPEGDrawScreen_0 JPEGDrawScreen_1 etc...
what i've tried so far:
std::bind
then actually draw with
jpeg.openRAM((uint8_t *) imgBuf, datasize, (JPEG_DRAW_CALLBACK *) bind(&JPEGDrawScreen, std::placeholders::_1, screen))
and i get
error: invalid cast from type 'std::_Bind_helper<false, int (*)(jpeg_draw_tag*, Adafruit_ST7789*), const std::_Placeholder<1>&, Adafruit_ST7789*&>::type' {aka 'std::_Bind<int (*(std::_Placeholder<1>, Adafruit_ST7789*))(jpeg_draw_tag*, Adafruit_ST7789*)>'} to type 'int (*)(JPEGDRAW*)' {aka 'int (*)(jpeg_draw_tag*)'}
in both I ran into similar issues,
jpeg.openRAM
hasJPEG_DRAW_CALLBACK
that is incompatible with lambda and bind functions. Is there any way to do this other than having multiple callbacks?Keep in mind that i'm still learning C++ ;)