Update gwin Images to properly use new GFILE based images
parent
695bcbee5b
commit
bd48279227
|
@ -60,42 +60,51 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *widget, GWindowInit *pInit);
|
||||||
#define gwinImageCreate(w, pInit) gwinGImageCreate(GDISP, w, pInit)
|
#define gwinImageCreate(w, pInit) gwinGImageCreate(GDISP, w, pInit)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the input routines that support reading the image from memory
|
* @brief Opens the image using a GFILE
|
||||||
* in RAM or flash.
|
* @return TRUE if the image can be opened
|
||||||
* @return TRUE if the IO open function succeeds
|
|
||||||
*
|
*
|
||||||
* @param[in] gh The widget (must be an image widget)
|
* @param[in] gh The widget (must be an image widget)
|
||||||
* @param[in] memory A pointer to the image in RAM or Flash
|
* @param[in] f The open (for reading) GFILE to use
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
bool_t gwinImageOpenMemory(GHandle gh, const void* memory);
|
bool_t gwinImageOpenGFile(GHandle gh, GFILE *f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Opens the image using the specified filename
|
||||||
|
* @return TRUE if the open succeeds
|
||||||
|
*
|
||||||
|
* @param[in] gh The widget (must be an image widget)
|
||||||
|
* @param[in] filename The filename to open
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define gwinImageOpenFile(gh, filename) gwinImageOpenGFile((gh), gfileOpen((filename), "rb"))
|
||||||
|
|
||||||
#if defined(WIN32) || GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_OSX || defined(__DOXYGEN__)
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the input routines that support reading the image from a file
|
* @brief Sets the input routines that support reading the image from memory
|
||||||
|
* in RAM or flash.
|
||||||
|
* @pre GFILE_NEED_MEMFS must be TRUE
|
||||||
* @return TRUE if the IO open function succeeds
|
* @return TRUE if the IO open function succeeds
|
||||||
*
|
*
|
||||||
* @param[in] gh The widget (must be an image widget)
|
* @param[in] gh The widget (must be an image widget)
|
||||||
* @param[in] filename The filename to open
|
* @param[in] ptr A pointer to the image in RAM or Flash
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
bool_t gwinImageOpenFile(GHandle gh, const char* filename);
|
#define gwinImageOpenMemory(gh, ptr) gwinImageOpenGFile((gh), gfileOpenMemory((void *)(ptr), "rb"))
|
||||||
#endif
|
|
||||||
|
|
||||||
#if GFX_USE_OS_CHIBIOS || defined(__DOXYGEN__)
|
/**
|
||||||
/**
|
* @brief Sets the input routines that support reading the image from a BaseFileStream (eg. an SD-Card).
|
||||||
* @brief Sets the input routines that support reading the image from a BaseFileStream (eg. an SD-Card).
|
* @return TRUE if the IO open function succeeds
|
||||||
* @return TRUE if the IO open function succeeds
|
* @pre GFILE_NEED_CHIBIOSFS and GFX_USE_OS_CHIBIOS must be TRUE
|
||||||
*
|
*
|
||||||
* @param[in] gh The widget (must be an image widget)
|
* @param[in] gh The widget (must be an image widget)
|
||||||
* @param[in] streamPtr A pointer to the (open) BaseFileStream object.
|
* @param[in] streamPtr A pointer to the (open) BaseFileStream object.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
bool_t gwinImageOpenStream(GHandle gh, void *streamPtr);
|
#define gwinImageOpenStream(gh, streamPtr) gwinImageOpenGFile((gh), gfileOpenBaseFIleStream((streamPtr), "rb"))
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cache the image.
|
* @brief Cache the image.
|
||||||
|
|
|
@ -139,14 +139,11 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *gobj, GWindowInit *pInit) {
|
||||||
return (GHandle)gobj;
|
return (GHandle)gobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t gwinImageOpenMemory(GHandle gh, const void* memory) {
|
bool_t gwinImageOpenGFile(GHandle gh, GFILE *f) {
|
||||||
if (gdispImageIsOpen(&widget(gh)->image))
|
if (gdispImageIsOpen(&widget(gh)->image))
|
||||||
gdispImageClose(&widget(gh)->image);
|
gdispImageClose(&widget(gh)->image);
|
||||||
|
|
||||||
if (!gdispImageSetMemoryReader(&widget(gh)->image, memory))
|
if ((gdispImageOpenGFile(&widget(gh)->image, f) & GDISP_IMAGE_ERR_UNRECOVERABLE))
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (gdispImageOpen(&widget(gh)->image) != GDISP_IMAGE_ERR_OK)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((gh->flags & GWIN_FLG_VISIBLE)) {
|
if ((gh->flags & GWIN_FLG_VISIBLE)) {
|
||||||
|
@ -161,54 +158,6 @@ bool_t gwinImageOpenMemory(GHandle gh, const void* memory) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) || GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_OSX || defined(__DOXYGEN__)
|
|
||||||
bool_t gwinImageOpenFile(GHandle gh, const char* filename) {
|
|
||||||
if (gdispImageIsOpen(&widget(gh)->image))
|
|
||||||
gdispImageClose(&widget(gh)->image);
|
|
||||||
|
|
||||||
if (!gdispImageSetFileReader(&widget(gh)->image, filename))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (gdispImageOpen(&widget(gh)->image) != GDISP_IMAGE_ERR_OK)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if ((gh->flags & GWIN_FLG_VISIBLE)) {
|
|
||||||
// Setting the clip here shouldn't be necessary if the redraw doesn't overdraw
|
|
||||||
// but we put it in for safety anyway
|
|
||||||
#if GDISP_NEED_CLIP
|
|
||||||
gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
|
|
||||||
#endif
|
|
||||||
_redraw(gh);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if GFX_USE_OS_CHIBIOS || defined(__DOXYGEN__)
|
|
||||||
bool_t gwinImageOpenStream(GHandle gh, void *streamPtr) {
|
|
||||||
if (gdispImageIsOpen(&widget(gh)->image))
|
|
||||||
gdispImageClose(&widget(gh)->image);
|
|
||||||
|
|
||||||
if (!gdispImageSetBaseFileStreamReader(&widget(gh)->image, streamPtr))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (gdispImageOpen(&widget(gh)->image) != GDISP_IMAGE_ERR_OK)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if ((gh->flags & GWIN_FLG_VISIBLE)) {
|
|
||||||
// Setting the clip here shouldn't be necessary if the redraw doesn't overdraw
|
|
||||||
// but we put it in for safety anyway
|
|
||||||
#if GDISP_NEED_CLIP
|
|
||||||
gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
|
|
||||||
#endif
|
|
||||||
_redraw(gh);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gdispImageError gwinImageCache(GHandle gh) {
|
gdispImageError gwinImageCache(GHandle gh) {
|
||||||
return gdispImageCache(&widget(gh)->image);
|
return gdispImageCache(&widget(gh)->image);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue