Dependencies:   emwin_lib

Fork of DMemWin by Embedded Artists

Committer:
destinyXfate
Date:
Thu Jun 02 04:55:08 2016 +0000
Revision:
4:20387dbf7ecf
Parent:
2:0e2ef1edf01b
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
destinyXfate 2:0e2ef1edf01b 1 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 2 * SEGGER Microcontroller GmbH & Co. KG *
destinyXfate 2:0e2ef1edf01b 3 * Solutions for real time microcontroller applications *
destinyXfate 2:0e2ef1edf01b 4 **********************************************************************
destinyXfate 2:0e2ef1edf01b 5 * *
destinyXfate 2:0e2ef1edf01b 6 * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
destinyXfate 2:0e2ef1edf01b 7 * *
destinyXfate 2:0e2ef1edf01b 8 * Internet: www.segger.com Support: support@segger.com *
destinyXfate 2:0e2ef1edf01b 9 * *
destinyXfate 2:0e2ef1edf01b 10 **********************************************************************
destinyXfate 2:0e2ef1edf01b 11
destinyXfate 2:0e2ef1edf01b 12 ** emWin V5.30 - Graphical user interface for embedded applications **
destinyXfate 2:0e2ef1edf01b 13 emWin is protected by international copyright laws. Knowledge of the
destinyXfate 2:0e2ef1edf01b 14 source code may not be used to write a similar product. This file may
destinyXfate 2:0e2ef1edf01b 15 only be used in accordance with a license and should not be re-
destinyXfate 2:0e2ef1edf01b 16 distributed in any way. We appreciate your understanding and fairness.
destinyXfate 2:0e2ef1edf01b 17 ----------------------------------------------------------------------
destinyXfate 2:0e2ef1edf01b 18 File : IMAGE_PNG.c
destinyXfate 2:0e2ef1edf01b 19 Purpose : Implementation of image widget, 'PNG' related code
destinyXfate 2:0e2ef1edf01b 20 ---------------------------END-OF-HEADER------------------------------
destinyXfate 2:0e2ef1edf01b 21 */
destinyXfate 2:0e2ef1edf01b 22
destinyXfate 2:0e2ef1edf01b 23 #include "GUI.h"
destinyXfate 2:0e2ef1edf01b 24
destinyXfate 2:0e2ef1edf01b 25 #if (GUI_VERSION >= 51300) && GUI_WINSUPPORT
destinyXfate 2:0e2ef1edf01b 26
destinyXfate 2:0e2ef1edf01b 27 #if defined(__cplusplus)
destinyXfate 2:0e2ef1edf01b 28 extern "C" { // Make sure we have C-declarations in C++ programs
destinyXfate 2:0e2ef1edf01b 29 #endif
destinyXfate 2:0e2ef1edf01b 30
destinyXfate 2:0e2ef1edf01b 31 #include "IMAGE_Private.h"
destinyXfate 2:0e2ef1edf01b 32
destinyXfate 2:0e2ef1edf01b 33 #if defined(__cplusplus)
destinyXfate 2:0e2ef1edf01b 34 }
destinyXfate 2:0e2ef1edf01b 35 #endif
destinyXfate 2:0e2ef1edf01b 36
destinyXfate 2:0e2ef1edf01b 37 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 38 *
destinyXfate 2:0e2ef1edf01b 39 * Static routines
destinyXfate 2:0e2ef1edf01b 40 *
destinyXfate 2:0e2ef1edf01b 41 **********************************************************************
destinyXfate 2:0e2ef1edf01b 42 */
destinyXfate 2:0e2ef1edf01b 43 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 44 *
destinyXfate 2:0e2ef1edf01b 45 * _DrawImageAt
destinyXfate 2:0e2ef1edf01b 46 */
destinyXfate 2:0e2ef1edf01b 47 static void _DrawImageAt(IMAGE_Handle hObj, int xPos, int yPos) {
destinyXfate 2:0e2ef1edf01b 48 IMAGE_OBJ * pObj;
destinyXfate 2:0e2ef1edf01b 49 const void * pData;
destinyXfate 2:0e2ef1edf01b 50 U32 FileSize;
destinyXfate 2:0e2ef1edf01b 51
destinyXfate 2:0e2ef1edf01b 52 pObj = IMAGE_LOCK_H(hObj); {
destinyXfate 2:0e2ef1edf01b 53 pData = (GUI_BITMAP *)pObj->pData;
destinyXfate 2:0e2ef1edf01b 54 FileSize = pObj->FileSize;
destinyXfate 2:0e2ef1edf01b 55 } GUI_UNLOCK_H(pObj);
destinyXfate 2:0e2ef1edf01b 56 GUI_PNG_Draw(pData, FileSize, xPos, yPos);
destinyXfate 2:0e2ef1edf01b 57 }
destinyXfate 2:0e2ef1edf01b 58
destinyXfate 2:0e2ef1edf01b 59 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 60 *
destinyXfate 2:0e2ef1edf01b 61 * _GetImageSize
destinyXfate 2:0e2ef1edf01b 62 */
destinyXfate 2:0e2ef1edf01b 63 static void _GetImageSize(IMAGE_Handle hObj, int * pxSize, int * pySize) {
destinyXfate 2:0e2ef1edf01b 64 IMAGE_OBJ * pObj;
destinyXfate 2:0e2ef1edf01b 65 const void * pData;
destinyXfate 2:0e2ef1edf01b 66 U32 FileSize;
destinyXfate 2:0e2ef1edf01b 67
destinyXfate 2:0e2ef1edf01b 68 pObj = IMAGE_LOCK_H(hObj); {
destinyXfate 2:0e2ef1edf01b 69 pData = (GUI_BITMAP *)pObj->pData;
destinyXfate 2:0e2ef1edf01b 70 FileSize = pObj->FileSize;
destinyXfate 2:0e2ef1edf01b 71 } GUI_UNLOCK_H(pObj);
destinyXfate 2:0e2ef1edf01b 72 *pxSize = GUI_PNG_GetXSize(pData, FileSize);
destinyXfate 2:0e2ef1edf01b 73 *pySize = GUI_PNG_GetYSize(pData, FileSize);
destinyXfate 2:0e2ef1edf01b 74 }
destinyXfate 2:0e2ef1edf01b 75
destinyXfate 2:0e2ef1edf01b 76 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 77 *
destinyXfate 2:0e2ef1edf01b 78 * _DrawImageAtEx
destinyXfate 2:0e2ef1edf01b 79 */
destinyXfate 2:0e2ef1edf01b 80 static void _DrawImageAtEx(IMAGE_Handle hObj, int xPos, int yPos) {
destinyXfate 2:0e2ef1edf01b 81 IMAGE_OBJ * pObj;
destinyXfate 2:0e2ef1edf01b 82 void * pVoid;
destinyXfate 2:0e2ef1edf01b 83 GUI_GET_DATA_FUNC * pfGetData;
destinyXfate 2:0e2ef1edf01b 84
destinyXfate 2:0e2ef1edf01b 85 pObj = IMAGE_LOCK_H(hObj); {
destinyXfate 2:0e2ef1edf01b 86 pVoid = pObj->pVoid;
destinyXfate 2:0e2ef1edf01b 87 pfGetData = pObj->pfGetData;
destinyXfate 2:0e2ef1edf01b 88 } GUI_UNLOCK_H(pObj);
destinyXfate 2:0e2ef1edf01b 89 GUI_PNG_DrawEx(pfGetData, pVoid, xPos, yPos);
destinyXfate 2:0e2ef1edf01b 90 }
destinyXfate 2:0e2ef1edf01b 91
destinyXfate 2:0e2ef1edf01b 92 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 93 *
destinyXfate 2:0e2ef1edf01b 94 * _GetImageSizeEx
destinyXfate 2:0e2ef1edf01b 95 */
destinyXfate 2:0e2ef1edf01b 96 static void _GetImageSizeEx(IMAGE_Handle hObj, int * pxSize, int * pySize) {
destinyXfate 2:0e2ef1edf01b 97 IMAGE_OBJ * pObj;
destinyXfate 2:0e2ef1edf01b 98 void * pVoid;
destinyXfate 2:0e2ef1edf01b 99 GUI_GET_DATA_FUNC * pfGetData;
destinyXfate 2:0e2ef1edf01b 100
destinyXfate 2:0e2ef1edf01b 101 pObj = IMAGE_LOCK_H(hObj); {
destinyXfate 2:0e2ef1edf01b 102 pVoid = pObj->pVoid;
destinyXfate 2:0e2ef1edf01b 103 pfGetData = pObj->pfGetData;
destinyXfate 2:0e2ef1edf01b 104 } GUI_UNLOCK_H(pObj);
destinyXfate 2:0e2ef1edf01b 105 *pxSize = GUI_PNG_GetXSizeEx(pfGetData, pVoid);
destinyXfate 2:0e2ef1edf01b 106 *pySize = GUI_PNG_GetYSizeEx(pfGetData, pVoid);
destinyXfate 2:0e2ef1edf01b 107 }
destinyXfate 2:0e2ef1edf01b 108
destinyXfate 2:0e2ef1edf01b 109 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 110 *
destinyXfate 2:0e2ef1edf01b 111 * Public routines
destinyXfate 2:0e2ef1edf01b 112 *
destinyXfate 2:0e2ef1edf01b 113 **********************************************************************
destinyXfate 2:0e2ef1edf01b 114 */
destinyXfate 2:0e2ef1edf01b 115 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 116 *
destinyXfate 2:0e2ef1edf01b 117 * IMAGE_SetPNG
destinyXfate 2:0e2ef1edf01b 118 */
destinyXfate 2:0e2ef1edf01b 119 void IMAGE_SetPNG(IMAGE_Handle hObj, const void * pData, U32 FileSize) {
destinyXfate 2:0e2ef1edf01b 120 IMAGE_OBJ * pObj;
destinyXfate 2:0e2ef1edf01b 121
destinyXfate 2:0e2ef1edf01b 122 if (hObj && pData && FileSize) {
destinyXfate 2:0e2ef1edf01b 123 WM_LOCK();
destinyXfate 2:0e2ef1edf01b 124 pObj = IMAGE_LOCK_H(hObj); {
destinyXfate 2:0e2ef1edf01b 125 pObj->pData = pData;
destinyXfate 2:0e2ef1edf01b 126 pObj->FileSize = FileSize;
destinyXfate 2:0e2ef1edf01b 127 pObj->pfDrawImageAt = _DrawImageAt;
destinyXfate 2:0e2ef1edf01b 128 pObj->pfGetImageSize = _GetImageSize;
destinyXfate 2:0e2ef1edf01b 129 } GUI_UNLOCK_H(pObj);
destinyXfate 2:0e2ef1edf01b 130 IMAGE__FreeAttached(hObj, 0);
destinyXfate 2:0e2ef1edf01b 131 IMAGE__SetWindowSize(hObj);
destinyXfate 2:0e2ef1edf01b 132 WM_InvalidateWindow(hObj);
destinyXfate 2:0e2ef1edf01b 133 WM_UNLOCK();
destinyXfate 2:0e2ef1edf01b 134 }
destinyXfate 2:0e2ef1edf01b 135 }
destinyXfate 2:0e2ef1edf01b 136
destinyXfate 2:0e2ef1edf01b 137 /*********************************************************************
destinyXfate 2:0e2ef1edf01b 138 *
destinyXfate 2:0e2ef1edf01b 139 * IMAGE_SetPNGEx
destinyXfate 2:0e2ef1edf01b 140 */
destinyXfate 2:0e2ef1edf01b 141 void IMAGE_SetPNGEx(IMAGE_Handle hObj, GUI_GET_DATA_FUNC * pfGetData, void * pVoid) {
destinyXfate 2:0e2ef1edf01b 142 IMAGE_OBJ * pObj;
destinyXfate 2:0e2ef1edf01b 143
destinyXfate 2:0e2ef1edf01b 144 if (hObj && pfGetData) {
destinyXfate 2:0e2ef1edf01b 145 WM_LOCK();
destinyXfate 2:0e2ef1edf01b 146 pObj = IMAGE_LOCK_H(hObj); {
destinyXfate 2:0e2ef1edf01b 147 pObj->pfGetData = pfGetData;
destinyXfate 2:0e2ef1edf01b 148 pObj->pVoid = pVoid;
destinyXfate 2:0e2ef1edf01b 149 pObj->pfDrawImageAt = _DrawImageAtEx;
destinyXfate 2:0e2ef1edf01b 150 pObj->pfGetImageSize = _GetImageSizeEx;
destinyXfate 2:0e2ef1edf01b 151 } GUI_UNLOCK_H(pObj);
destinyXfate 2:0e2ef1edf01b 152 IMAGE__FreeAttached(hObj, 0);
destinyXfate 2:0e2ef1edf01b 153 IMAGE__SetWindowSize(hObj);
destinyXfate 2:0e2ef1edf01b 154 WM_InvalidateWindow(hObj);
destinyXfate 2:0e2ef1edf01b 155 WM_UNLOCK();
destinyXfate 2:0e2ef1edf01b 156 }
destinyXfate 2:0e2ef1edf01b 157 }
destinyXfate 2:0e2ef1edf01b 158
destinyXfate 2:0e2ef1edf01b 159 #else /* avoid empty object files */
destinyXfate 2:0e2ef1edf01b 160
destinyXfate 2:0e2ef1edf01b 161 void IMAGE_PNG_C(void);
destinyXfate 2:0e2ef1edf01b 162 void IMAGE_PNG_C(void){}
destinyXfate 2:0e2ef1edf01b 163
destinyXfate 2:0e2ef1edf01b 164 #endif /* #if GUI_WINSUPPORT */
destinyXfate 2:0e2ef1edf01b 165
destinyXfate 2:0e2ef1edf01b 166 /*************************** End of file ****************************/
destinyXfate 2:0e2ef1edf01b 167