Gammu internals  1.38.0
Bitmap

Data Structures

struct  GSM_BinaryPicture
 
struct  GSM_Bitmap
 
struct  GSM_MultiBitmap
 

Enumerations

enum  GSM_BinaryPicture_Types {
  PICTURE_BMP = 1, PICTURE_GIF, PICTURE_JPG, PICTURE_ICN,
  PICTURE_PNG
}
 
enum  GSM_Bitmap_Types {
  GSM_None = 1, GSM_ColourStartupLogo_ID, GSM_StartupLogo, GSM_ColourOperatorLogo_ID,
  GSM_OperatorLogo, GSM_ColourWallPaper_ID, GSM_CallerGroupLogo, GSM_DealerNote_Text,
  GSM_WelcomeNote_Text, GSM_PictureImage, GSM_PictureBinary
}
 

Functions

GSM_Error GSM_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap)
 
GSM_Error GSM_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap)
 
void GSM_PrintBitmap (FILE *file, GSM_Bitmap *bitmap)
 
GSM_Error GSM_SaveBitmapFile (char *FileName, GSM_MultiBitmap *bitmap)
 
GSM_Error GSM_ReadBitmapFile (char *FileName, GSM_MultiBitmap *bitmap)
 
gboolean GSM_IsPointBitmap (GSM_Bitmap *bmp, int x, int y)
 
void GSM_SetPointBitmap (GSM_Bitmap *bmp, int x, int y)
 
void GSM_ClearPointBitmap (GSM_Bitmap *bmp, int x, int y)
 
void GSM_ClearBitmap (GSM_Bitmap *bmp)
 
GSM_Error GSM_GetScreenshot (GSM_StateMachine *s, GSM_BinaryPicture *picture)
 

Detailed Description

Bitmaps manipulations.

Enumeration Type Documentation

§ GSM_BinaryPicture_Types

Binary picture types.

Enumerator
PICTURE_BMP 
PICTURE_GIF 
PICTURE_JPG 
PICTURE_ICN 
PICTURE_PNG 

Definition at line 30 of file gammu-bitmap.h.

§ GSM_Bitmap_Types

Enum to handle all possible bitmaps, which are not saved in various filesystems.

Enumerator
GSM_None 
GSM_ColourStartupLogo_ID 

ID of static file in filesystem displayed during startup

GSM_StartupLogo 

Static mono bitmap/ID of animated mono bitmap displayed during startup

GSM_ColourOperatorLogo_ID 

ID of static file in filesystem displayed instead of operator name

GSM_OperatorLogo 

Mono bitmap displayed instead of operator name

GSM_ColourWallPaper_ID 

ID of static file in filesystem displayed as wallpaper

GSM_CallerGroupLogo 

Mono bitmap assigned to caller group

GSM_DealerNote_Text 

Text displayed during startup, which can't be removed from phone menu

GSM_WelcomeNote_Text 

Text displayed during startup

GSM_PictureImage 

Image defined in Smart Messaging specification

GSM_PictureBinary 

Binary picture (BMP, GIF, etc.)

Definition at line 54 of file gammu-bitmap.h.

Function Documentation

§ GSM_ClearBitmap()

void GSM_ClearBitmap ( GSM_Bitmap bmp)

Clears bitmap.

Parameters
bmpBitmap

Definition at line 247 of file gsmlogo.c.

References GSM_Bitmap::BitmapPoints, and GSM_GetBitmapSize().

Referenced by BMP2Bitmap(), GSM_EncodeEMSMultiPartSMS(), GSM_ResizeBitmap(), loadnlm(), loadnolngg(), and PHONE_DecodeBitmap().

248 {
249  memset(bmp->BitmapPoints,0,GSM_GetBitmapSize(bmp));
250 }
unsigned char BitmapPoints[GSM_BITMAP_SIZE]
Definition: gammu-bitmap.h:148
size_t GSM_GetBitmapSize(GSM_Bitmap *bmp)
Definition: gsmlogo.c:252

§ GSM_ClearPointBitmap()

void GSM_ClearPointBitmap ( GSM_Bitmap bmp,
int  x,
int  y 
)

Clears point in bitmap.

Parameters
bmpBitmap
xHorizontal coordinate.
yVertical coordinate.

Definition at line 233 of file gsmlogo.c.

References GSM_Bitmap::BitmapPoints, GSM_Bitmap::BitmapWidth, and ClearBit().

Referenced by GSM_DecodeEMSMultiPartSMS(), and GSM_ReverseBitmap().

234 {
235  ClearBit(bmp->BitmapPoints,y*bmp->BitmapWidth+x);
236 }
int ClearBit(unsigned char *Buffer, size_t BitNum)
Definition: coding.c:1258
unsigned char BitmapPoints[GSM_BITMAP_SIZE]
Definition: gammu-bitmap.h:148
size_t BitmapWidth
Definition: gammu-bitmap.h:156

§ GSM_GetBitmap()

GSM_Error GSM_GetBitmap ( GSM_StateMachine s,
GSM_Bitmap Bitmap 
)

Gets bitmap from phone.

Gets bitmap.

Definition at line 1288 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetBitmap, _GSM_StateMachine::Phone, and PRINT_LOG_ERROR.

1289 {
1290  GSM_Error err;
1291 
1293 
1294  err = s->Phone.Functions->GetBitmap(s, Bitmap);
1295  PRINT_LOG_ERROR(err);
1296  return err;
1297 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Error(* GetBitmap)(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
Definition: gsmstate.h:1131
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ GSM_GetScreenshot()

GSM_Error GSM_GetScreenshot ( GSM_StateMachine s,
GSM_BinaryPicture picture 
)

Gets phone screenshot.

Parameters
sState machine pointer.
pictureStructure which will hold data.

Gets phone screenshot

Definition at line 1870 of file api.c.

References GSM_BinaryPicture::Buffer, CHECK_PHONE_CONNECTION, GSM_Phone::Functions, GSM_Phone_Functions::GetScreenshot, GSM_BinaryPicture::Length, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and GSM_BinaryPicture::Type.

1871 {
1872  GSM_Error err;
1873 
1875 
1876  picture->Length = 0;
1877  picture->Buffer = NULL;
1878  picture->Type = 0;
1879 
1880  err = s->Phone.Functions->GetScreenshot(s, picture);
1881  PRINT_LOG_ERROR(err);
1882  return err;
1883 }
GSM_Error
Definition: gammu-error.h:23
GSM_BinaryPicture_Types Type
Definition: gammu-bitmap.h:44
unsigned char * Buffer
Definition: gammu-bitmap.h:45
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
GSM_Error(* GetScreenshot)(GSM_StateMachine *s, GSM_BinaryPicture *picture)
Definition: gsmstate.h:1305

§ GSM_IsPointBitmap()

gboolean GSM_IsPointBitmap ( GSM_Bitmap bmp,
int  x,
int  y 
)

Checks whether point is set in bitmap.

Parameters
bmpBitmap
xHorizontal coordinate.
yVertical coordinate.
Returns
True if point is set.

Definition at line 238 of file gsmlogo.c.

References GSM_Bitmap::BitmapPoints, GSM_Bitmap::BitmapWidth, FALSE, GetBit(), and TRUE.

Referenced by Bitmap2BMP(), GSM_DecodeEMSMultiPartSMS(), GSM_EncodeEMSMultiPartSMS(), GSM_PrintBitmap(), GSM_ResizeBitmap(), GSM_ReverseBitmap(), PHONE_EncodeBitmap(), PrivSaveNGGNOL(), PrivSaveNLMWBMP(), and savexpm().

239 {
240  if (GetBit(bmp->BitmapPoints, (y * bmp->BitmapWidth) + x)) {
241  return TRUE;
242  } else {
243  return FALSE;
244  }
245 }
unsigned char BitmapPoints[GSM_BITMAP_SIZE]
Definition: gammu-bitmap.h:148
#define FALSE
Definition: gammu-types.h:25
size_t BitmapWidth
Definition: gammu-bitmap.h:156
#define TRUE
Definition: gammu-types.h:28
int GetBit(unsigned char *Buffer, size_t BitNum)
Definition: coding.c:1248

§ GSM_PrintBitmap()

void GSM_PrintBitmap ( FILE *  file,
GSM_Bitmap bitmap 
)

Prints bitmap to file descriptor.

Parameters
fileWhere to print.
bitmapBitmap to print.

Definition at line 257 of file gsmlogo.c.

References GSM_Bitmap::BitmapHeight, GSM_Bitmap::BitmapWidth, and GSM_IsPointBitmap().

Referenced by GSM_DecodeMultiPartSMS(), GSM_DecodeNokiaProfile(), and GSM_EncodeEMSMultiPartSMS().

258 {
259  size_t x,y;
260 
261  for (y=0;y<bitmap->BitmapHeight;y++) {
262  for (x=0;x<bitmap->BitmapWidth;x++) {
263  if (GSM_IsPointBitmap(bitmap,x,y)) {
264  fprintf(file,"#");
265  } else {
266  fprintf(file," ");
267  }
268  }
269  fprintf(file,"\n");
270  }
271 }
gboolean GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:238
size_t BitmapHeight
Definition: gammu-bitmap.h:152
size_t BitmapWidth
Definition: gammu-bitmap.h:156

§ GSM_ReadBitmapFile()

GSM_Error GSM_ReadBitmapFile ( char *  FileName,
GSM_MultiBitmap bitmap 
)

Reads bitmap from file.

Parameters
FileNameWhere to load from.
bitmapPointer where to load bitmap.
Returns
Error code

Definition at line 1073 of file gsmlogo.c.

References GSM_MultiBitmap::Bitmap, GSM_Bitmap::DefaultBitmap, EncodeUnicode(), ERR_CANTOPENFILE, ERR_FILENOTSUPPORTED, ERR_MOREMEMORY, FALSE, GSM_BITMAP_TEXT_LENGTH, loadbmp(), loadgif(), loadnlm(), loadnolngg(), loadnsl(), loadwbmp(), GSM_Bitmap::Name, and TRUE.

1074 {
1075  FILE *file;
1076  unsigned char buffer[300];
1078  char *file_only_name;
1079  size_t len;
1080 
1081  file = fopen(FileName, "rb");
1082  if (file == NULL) return ERR_CANTOPENFILE;
1083 
1084  file_only_name = strrchr(FileName, '/');
1085  if (file_only_name == NULL) {
1086  file_only_name = strrchr(FileName, '\\');
1087  } else {
1088  file_only_name++;
1089  }
1090  if (file_only_name == NULL) {
1091  file_only_name = FileName;
1092  } else {
1093  file_only_name++;
1094  }
1095  len = strlen(file_only_name);
1096  if (len > GSM_BITMAP_TEXT_LENGTH) {
1097  fclose(file);
1098  return ERR_MOREMEMORY;
1099  }
1100 
1101  EncodeUnicode(bitmap->Bitmap[0].Name, file_only_name, len);
1102 
1103  /* Read the header of the file. */
1104  if (fread(buffer, 1, 9, file) != 9) {
1105  fclose(file);
1106  return ERR_FILENOTSUPPORTED;
1107  }
1108  rewind(file);
1109 
1110  bitmap->Bitmap[0].DefaultBitmap = FALSE;
1111 
1112  /* Attempt to identify filetype */
1113  if (memcmp(buffer, "BM",2)==0) {
1114  error = loadbmp(file,bitmap);
1115  } else if (buffer[0] == 0x00 && buffer[1] == 0x00) {
1116  error = loadwbmp(file,bitmap);
1117  } else if (memcmp(buffer, "NLM",3)==0) {
1118  error = loadnlm(file,bitmap);
1119  } else if (memcmp(buffer, "NOL",3)==0) {
1120  error = loadnolngg(file,bitmap,TRUE);
1121  } else if (memcmp(buffer, "NGG",3)==0) {
1122  error = loadnolngg(file,bitmap,FALSE);
1123  } else if (memcmp(buffer, "FORM",4)==0) {
1124  error = loadnsl(file,bitmap);
1125  } else if (memcmp(buffer, "GIF",3)==0) {
1126  error = loadgif(file,bitmap);
1127  }
1128  fclose(file);
1129  return error;
1130 }
GSM_Error
Definition: gammu-error.h:23
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
Definition: coding.c:301
#define FALSE
Definition: gammu-types.h:25
#define GSM_BITMAP_TEXT_LENGTH
Definition: gammu-limits.h:274
static GSM_Error loadbmp(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:853
static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:987
GSM_Bitmap Bitmap[GSM_MAX_MULTI_BITMAP]
Definition: gammu-bitmap.h:192
gboolean DefaultBitmap
Definition: gammu-bitmap.h:130
unsigned char Name[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:176
static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:1045
static GSM_Error loadnolngg(FILE *file, GSM_MultiBitmap *bitmap, gboolean nolformat)
Definition: gsmlogo.c:933
#define TRUE
Definition: gammu-types.h:28
static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:1026
static GSM_Error loadnlm(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:862

§ GSM_SaveBitmapFile()

GSM_Error GSM_SaveBitmapFile ( char *  FileName,
GSM_MultiBitmap bitmap 
)

Saves bitmap to file.

Parameters
FileNameWhere to save.
bitmapBitmap to save.
Returns
Error code

Definition at line 676 of file gsmlogo.c.

References ERR_CANTOPENFILE, ERR_NONE, savebmp(), savengg(), savenlm(), savenol(), savensl(), savewbmp(), and savexpm().

677 {
678  FILE *file;
679  GSM_Error error=ERR_NONE;
680 
681  file = fopen(FileName, "wb");
682  if (file == NULL) return ERR_CANTOPENFILE;
683 
684  /* Attempt to identify filetype */
685  if (strcasestr(FileName,".nlm")) {
686  error=savenlm(file,bitmap);
687  } else if (strcasestr(FileName,".ngg")) {
688  error=savengg(file,bitmap);
689  } else if (strcasestr(FileName,".nol")) {
690  error=savenol(file,bitmap);
691  } else if (strcasestr(FileName,".xpm")) {
692  error=savexpm(file,bitmap);
693  } else if (strcasestr(FileName,".nsl")) {
694  error=savensl(file,bitmap);
695  } else if (strcasestr(FileName,".wbmp")) {
696  error=savewbmp(file,bitmap);
697  } else {
698  error=savebmp(file,bitmap);
699  }
700  fclose(file);
701 
702  return error;
703 }
GSM_Error
Definition: gammu-error.h:23
static GSM_Error savengg(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:560
static GSM_Error savenlm(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:493
static GSM_Error savenol(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:581
static GSM_Error savexpm(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:613
static GSM_Error savebmp(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:455
static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:660
static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:644

§ GSM_SetBitmap()

GSM_Error GSM_SetBitmap ( GSM_StateMachine s,
GSM_Bitmap Bitmap 
)

Sets bitmap in phone.

Sets bitmap.

Definition at line 1301 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, PRINT_LOG_ERROR, and GSM_Phone_Functions::SetBitmap.

1302 {
1303  GSM_Error err;
1304 
1306 
1307  err = s->Phone.Functions->SetBitmap(s, Bitmap);
1308  PRINT_LOG_ERROR(err);
1309  return err;
1310 }
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
GSM_Error(* SetBitmap)(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
Definition: gsmstate.h:1135

§ GSM_SetPointBitmap()

void GSM_SetPointBitmap ( GSM_Bitmap bmp,
int  x,
int  y 
)

Sets point in bitmap.

Parameters
bmpBitmap
xHorizontal coordinate.
yVertical coordinate.

Definition at line 228 of file gsmlogo.c.

References GSM_Bitmap::BitmapPoints, GSM_Bitmap::BitmapWidth, and SetBit().

Referenced by BMP2Bitmap(), GSM_DecodeEMSMultiPartSMS(), GSM_EncodeEMSMultiPartSMS(), GSM_ResizeBitmap(), GSM_ReverseBitmap(), loadnlm(), loadnolngg(), and PHONE_DecodeBitmap().

229 {
230  SetBit(bmp->BitmapPoints,y*bmp->BitmapWidth+x);
231 }
unsigned char BitmapPoints[GSM_BITMAP_SIZE]
Definition: gammu-bitmap.h:148
int SetBit(unsigned char *Buffer, size_t BitNum)
Definition: coding.c:1253
size_t BitmapWidth
Definition: gammu-bitmap.h:156