2013-07-01 08:10:45 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
|
|
|
*
|
2013-07-21 20:20:37 +00:00
|
|
|
* http://ugfx.org/license.html
|
2013-07-01 08:10:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-08-20 07:42:53 +00:00
|
|
|
* @file src/gwin/gwin_image.h
|
2013-07-01 08:10:45 +00:00
|
|
|
* @brief GWIN image widget header file.
|
|
|
|
*
|
2014-07-05 13:55:45 +00:00
|
|
|
* @defgroup ImageBox ImageBox
|
2014-05-20 16:05:38 +00:00
|
|
|
* @ingroup Widgets
|
2013-07-01 08:10:45 +00:00
|
|
|
*
|
2015-11-07 15:33:28 +00:00
|
|
|
* @brief ImageBox widget. Used to display images within the @p GWIN widget system.
|
|
|
|
*
|
2013-07-01 08:10:45 +00:00
|
|
|
* @details GWIN allos it to create an image widget. The widget
|
|
|
|
* takes no user input.
|
|
|
|
*
|
2018-02-27 07:44:21 +00:00
|
|
|
* @pre GFX_USE_GDISP must be set to GFXON in your gfxconf.h
|
|
|
|
* @pre GFX_USE_GWIN must be set to GFXON in your gfxconf.h
|
|
|
|
* @pre GDISP_NEED_IMAGE must be set to GFXON in your gfxconf.h
|
|
|
|
* @pre GWIN_NEED_IMAGE must be set to GFXON in your gfxconf.h
|
2013-07-01 15:40:31 +00:00
|
|
|
* @pre At least one image type must be enabled in your gfxconf.h
|
2013-07-01 08:10:45 +00:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GWIN_IMAGE_H
|
|
|
|
#define _GWIN_IMAGE_H
|
|
|
|
|
2015-01-21 07:26:24 +00:00
|
|
|
// This file is included within "src/gwin/gwin.h"
|
2013-07-01 08:10:45 +00:00
|
|
|
|
|
|
|
// An image window
|
2013-07-07 09:40:37 +00:00
|
|
|
typedef struct GImageObject {
|
2013-07-01 08:10:45 +00:00
|
|
|
GWindowObject g;
|
2013-07-18 23:37:50 +00:00
|
|
|
gdispImage image; // The image itself
|
|
|
|
#if GWIN_NEED_IMAGE_ANIMATION
|
|
|
|
GTimer timer; // Timer used for animated images
|
|
|
|
#endif
|
2013-07-07 09:40:37 +00:00
|
|
|
} GImageObject;
|
2013-07-01 08:10:45 +00:00
|
|
|
|
2013-07-01 15:40:31 +00:00
|
|
|
/**
|
|
|
|
* @brief Create an image widget.
|
2013-07-07 09:40:37 +00:00
|
|
|
* @details Display's a picture.
|
2013-07-01 15:40:31 +00:00
|
|
|
* @return NULL if there is no resultant drawing area, otherwise the widget handle.
|
|
|
|
*
|
2013-10-24 08:36:11 +00:00
|
|
|
* @param[in] g The GDisplay to display this window on
|
2013-07-01 15:40:31 +00:00
|
|
|
* @param[in] widget The image widget structure to initialise. If this is NULL, the structure is dynamically allocated.
|
|
|
|
* @param[in] pInit The initialization parameters to use.
|
|
|
|
*
|
|
|
|
* @note The default background color gets set to the current default one.
|
2013-07-03 14:20:32 +00:00
|
|
|
* @note An image window knows how to redraw.
|
2013-07-01 15:40:31 +00:00
|
|
|
*
|
|
|
|
* @api
|
2013-07-03 14:20:32 +00:00
|
|
|
*/
|
2013-10-24 08:36:11 +00:00
|
|
|
GHandle gwinGImageCreate(GDisplay *g, GImageObject *widget, GWindowInit *pInit);
|
|
|
|
#define gwinImageCreate(w, pInit) gwinGImageCreate(GDISP, w, pInit)
|
2013-07-01 15:40:31 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-07 04:07:29 +00:00
|
|
|
* @brief Opens the image using a GFILE
|
2018-06-23 03:02:07 +00:00
|
|
|
* @return gTrue if the image can be opened
|
2013-07-01 15:40:31 +00:00
|
|
|
*
|
|
|
|
* @param[in] gh The widget (must be an image widget)
|
2014-02-07 04:07:29 +00:00
|
|
|
* @param[in] f The open (for reading) GFILE to use
|
2013-07-01 15:40:31 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2018-06-23 03:02:07 +00:00
|
|
|
gBool gwinImageOpenGFile(GHandle gh, GFILE *f);
|
2013-07-01 15:40:31 +00:00
|
|
|
|
2014-02-07 04:07:29 +00:00
|
|
|
/**
|
|
|
|
* @brief Opens the image using the specified filename
|
2018-06-23 03:02:07 +00:00
|
|
|
* @return gTrue if the open succeeds
|
2014-02-07 04:07:29 +00:00
|
|
|
*
|
|
|
|
* @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"))
|
2013-07-01 15:40:31 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-07 04:07:29 +00:00
|
|
|
* @brief Sets the input routines that support reading the image from memory
|
|
|
|
* in RAM or flash.
|
2018-02-27 07:44:21 +00:00
|
|
|
* @pre GFILE_NEED_MEMFS must be GFXON
|
2018-06-23 03:02:07 +00:00
|
|
|
* @return gTrue if the IO open function succeeds
|
2013-07-01 15:40:31 +00:00
|
|
|
*
|
|
|
|
* @param[in] gh The widget (must be an image widget)
|
2014-02-07 04:07:29 +00:00
|
|
|
* @param[in] ptr A pointer to the image in RAM or Flash
|
2013-07-01 15:40:31 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2014-02-07 04:07:29 +00:00
|
|
|
#define gwinImageOpenMemory(gh, ptr) gwinImageOpenGFile((gh), gfileOpenMemory((void *)(ptr), "rb"))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sets the input routines that support reading the image from a BaseFileStream (eg. an SD-Card).
|
2018-06-23 03:02:07 +00:00
|
|
|
* @return gTrue if the IO open function succeeds
|
2018-02-27 07:44:21 +00:00
|
|
|
* @pre GFILE_NEED_CHIBIOSFS and GFX_USE_OS_CHIBIOS must be GFXON
|
2014-02-07 04:07:29 +00:00
|
|
|
*
|
|
|
|
* @param[in] gh The widget (must be an image widget)
|
|
|
|
* @param[in] streamPtr A pointer to the (open) BaseFileStream object.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
#define gwinImageOpenStream(gh, streamPtr) gwinImageOpenGFile((gh), gfileOpenBaseFIleStream((streamPtr), "rb"))
|
2013-07-01 15:40:31 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-03 14:20:32 +00:00
|
|
|
* @brief Cache the image.
|
2013-07-01 15:40:31 +00:00
|
|
|
* @details Decodes and caches the current frame into RAM.
|
|
|
|
*
|
2013-07-17 02:44:29 +00:00
|
|
|
* @param[in] gh The widget (must be an image widget)
|
2013-07-01 15:40:31 +00:00
|
|
|
*
|
|
|
|
* @return GDISP_IMAGE_ERR_OK (0) on success or an error code.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
gdispImageError gwinImageCache(GHandle gh);
|
|
|
|
|
2013-07-01 08:10:45 +00:00
|
|
|
#endif // _GWIN_IMAGE_H
|
|
|
|
/** @} */
|
|
|
|
|