1 /** 2 * \file gammu-bitmap.h 3 * \author Michal Čihař 4 * 5 * Bitmap data and functions. 6 */ 7 #ifndef __gammu_bitmap_h 8 #define __gammu_bitmap_h 9 10 /** 11 * \defgroup Bitmap Bitmap 12 * Bitmaps manipulations. 13 */ 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #include <gammu-limits.h> 20 #include <gammu-types.h> 21 #include <gammu-error.h> 22 #include <gammu-statemachine.h> 23 #include <stdio.h> 24 25 /** 26 * Binary picture types. 27 * 28 * \ingroup Bitmap 29 */ 30 typedef enum { 31 PICTURE_BMP = 1, 32 PICTURE_GIF, 33 PICTURE_JPG, 34 PICTURE_ICN, 35 PICTURE_PNG 36 } GSM_BinaryPicture_Types; 37 38 /** 39 * Binary picture data. 40 * 41 * \ingroup Bitmap 42 */ 43 typedef struct { 44 GSM_BinaryPicture_Types Type; 45 unsigned char *Buffer; 46 size_t Length; 47 } GSM_BinaryPicture; 48 49 /** 50 * Enum to handle all possible bitmaps, which are not saved in various filesystems. 51 * 52 * \ingroup Bitmap 53 */ 54 typedef enum { 55 GSM_None = 1, 56 /** 57 * ID of static file in filesystem displayed during startup 58 */ 59 GSM_ColourStartupLogo_ID, 60 /** 61 * Static mono bitmap/ID of animated mono bitmap displayed during startup 62 */ 63 GSM_StartupLogo, 64 /** 65 * ID of static file in filesystem displayed instead of operator name 66 */ 67 GSM_ColourOperatorLogo_ID, 68 /** 69 * Mono bitmap displayed instead of operator name 70 */ 71 GSM_OperatorLogo, 72 /** 73 * ID of static file in filesystem displayed as wallpaper 74 */ 75 GSM_ColourWallPaper_ID, 76 /** 77 * Mono bitmap assigned to caller group 78 */ 79 GSM_CallerGroupLogo, 80 /** 81 * Text displayed during startup, which can't be removed from phone menu 82 */ 83 GSM_DealerNote_Text, 84 /** 85 * Text displayed during startup 86 */ 87 GSM_WelcomeNote_Text, 88 /** 89 * Image defined in Smart Messaging specification 90 */ 91 GSM_PictureImage, 92 /** 93 * Binary picture (BMP, GIF, etc.) 94 */ 95 GSM_PictureBinary 96 } GSM_Bitmap_Types; 97 98 /** 99 * Structure for all possible bitmaps, which are not saved in various filesystems 100 * 101 * \ingroup Bitmap 102 */ 103 typedef struct { 104 /** 105 * For all: bitmap type 106 */ 107 GSM_Bitmap_Types Type; 108 /** 109 * For caller group logos: number of group 110 * For startup logos: number of animated bitmap 111 */ 112 unsigned char Location; 113 /** 114 * For dealer/welcome note text: text 115 * For caller group logo: name of group 116 * For picture images: text assigned to it 117 */ 118 unsigned char Text[2 * (GSM_BITMAP_TEXT_LENGTH + 1)]; 119 /** 120 * For caller group logo: TRUE, when logo is enabled in group 121 */ 122 gboolean BitmapEnabled; 123 /** 124 * For caller group logo: TRUE, when group has default name 125 */ 126 gboolean DefaultName; 127 /** 128 * For caller group logo: TRUE, when group has default bitmap 129 */ 130 gboolean DefaultBitmap; 131 /** 132 * For caller group logo: TRUE, when group has default ringtone 133 */ 134 gboolean DefaultRingtone; 135 /** 136 * For caller group logo: ringtone ID. Phone model specific 137 */ 138 unsigned char RingtoneID; 139 gboolean FileSystemRingtone; 140 /** 141 * For caller group logo: picture ID. Phone model specific 142 */ 143 int PictureID; 144 gboolean FileSystemPicture; 145 /** 146 * For mono bitmaps: body of bitmap 147 */ 148 unsigned char BitmapPoints[GSM_BITMAP_SIZE]; 149 /** 150 * For mono bitmaps: height specified in pixels 151 */ 152 size_t BitmapHeight; 153 /** 154 * For mono bitmaps: width specified in pixels 155 */ 156 size_t BitmapWidth; 157 /** 158 * For operator logos: Network operator code 159 */ 160 char NetworkCode[10]; 161 /** 162 * For picture images: number of sender 163 */ 164 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)]; 165 /** 166 * For colour bitmaps: ID 167 */ 168 unsigned char ID; 169 /** 170 * For binary pictures (GIF, BMP, etc.): frame and length 171 */ 172 GSM_BinaryPicture BinaryPic; 173 /** 174 * Bitmap name 175 */ 176 unsigned char Name[2 * (GSM_BITMAP_TEXT_LENGTH + 1)]; 177 } GSM_Bitmap; 178 179 /** 180 * Structure to handle more than one bitmap 181 * 182 * \ingroup Bitmap 183 */ 184 typedef struct { 185 /** 186 * Number of bitmaps 187 */ 188 unsigned char Number; 189 /** 190 * All bitmaps 191 */ 192 GSM_Bitmap Bitmap[GSM_MAX_MULTI_BITMAP]; 193 } GSM_MultiBitmap; 194 195 /** 196 * Gets bitmap from phone. 197 * 198 * \ingroup Bitmap 199 */ 200 GSM_Error GSM_GetBitmap(GSM_StateMachine * s, GSM_Bitmap * Bitmap); 201 202 /** 203 * Sets bitmap in phone. 204 * 205 * \ingroup Bitmap 206 */ 207 GSM_Error GSM_SetBitmap(GSM_StateMachine * s, GSM_Bitmap * Bitmap); 208 209 /** 210 * Prints bitmap to file descriptor. 211 * 212 * \param file Where to print. 213 * \param bitmap Bitmap to print. 214 * 215 * \ingroup Bitmap 216 */ 217 void GSM_PrintBitmap(FILE * file, GSM_Bitmap * bitmap); 218 219 /** 220 * Saves bitmap to file. 221 * 222 * \param FileName Where to save. 223 * \param bitmap Bitmap to save. 224 * 225 * \return Error code 226 * 227 * \ingroup Bitmap 228 */ 229 GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap * bitmap); 230 231 /** 232 * Reads bitmap from file. 233 * 234 * \param FileName Where to load from. 235 * \param bitmap Pointer where to load bitmap. 236 * 237 * \return Error code 238 * 239 * \ingroup Bitmap 240 */ 241 GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap * bitmap); 242 243 /** 244 * Checks whether point is set in bitmap. 245 * 246 * \param bmp Bitmap 247 * \param x Horizontal coordinate. 248 * \param y Vertical coordinate. 249 * \return True if point is set. 250 * 251 * \ingroup Bitmap 252 */ 253 gboolean GSM_IsPointBitmap(GSM_Bitmap * bmp, int x, int y); 254 255 /** 256 * Sets point in bitmap. 257 * 258 * \param bmp Bitmap 259 * \param x Horizontal coordinate. 260 * \param y Vertical coordinate. 261 * 262 * \ingroup Bitmap 263 */ 264 void GSM_SetPointBitmap(GSM_Bitmap * bmp, int x, int y); 265 266 /** 267 * Clears point in bitmap. 268 * 269 * \param bmp Bitmap 270 * \param x Horizontal coordinate. 271 * \param y Vertical coordinate. 272 * 273 * \ingroup Bitmap 274 */ 275 void GSM_ClearPointBitmap(GSM_Bitmap * bmp, int x, int y); 276 277 /** 278 * Clears bitmap. 279 * 280 * \param bmp Bitmap 281 * 282 * \ingroup Bitmap 283 */ 284 void GSM_ClearBitmap(GSM_Bitmap * bmp); 285 286 /** 287 * Gets phone screenshot. 288 * 289 * \param s State machine pointer. 290 * \param picture Structure which will hold data. 291 * 292 * \ingroup Bitmap 293 */ 294 GSM_Error GSM_GetScreenshot(GSM_StateMachine *s, GSM_BinaryPicture *picture); 295 296 #ifdef __cplusplus 297 } 298 #endif 299 #endif 300 301 /* Editor configuration 302 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: 303 */ 304