Gammu internals  1.38.0
gsmlogo.h File Reference
#include <gammu-calendar.h>
#include <gammu-bitmap.h>
Include dependency graph for gsmlogo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  GSM_Phone_Bitmap_Types {
  GSM_NokiaStartupLogo = 1, GSM_NokiaOperatorLogo, GSM_Nokia7110OperatorLogo, GSM_Nokia6510OperatorLogo,
  GSM_NokiaCallerLogo, GSM_NokiaPictureImage, GSM_Nokia7110StartupLogo, GSM_Nokia6210StartupLogo,
  GSM_AlcatelBMMIPicture, GSM_EMSSmallPicture, GSM_EMSMediumPicture, GSM_EMSBigPicture,
  GSM_EMSVariablePicture
}
 

Functions

void GSM_GetMaxBitmapWidthHeight (GSM_Bitmap_Types Type, size_t *width, size_t *height)
 
void GSM_ResizeBitmap (GSM_Bitmap *dest, GSM_Bitmap *src, size_t width, size_t height)
 
void GSM_ReverseBitmap (GSM_Bitmap *Bitmap)
 
size_t GSM_GetBitmapSize (GSM_Bitmap *bmp)
 
GSM_Error BMP2Bitmap (unsigned char *buffer, FILE *file, GSM_Bitmap *bitmap)
 
GSM_Error Bitmap2BMP (unsigned char *buffer, FILE *file, GSM_Bitmap *bitmap)
 
void PHONE_GetBitmapWidthHeight (GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
 
size_t PHONE_GetBitmapSize (GSM_Phone_Bitmap_Types Type, size_t width, size_t height)
 
void PHONE_ClearBitmap (GSM_Phone_Bitmap_Types Type, char *buffer, size_t width, size_t height)
 
void PHONE_DecodeBitmap (GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
 
void PHONE_EncodeBitmap (GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
 
void NOKIA_CopyBitmap (GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, size_t *Length)
 

Enumeration Type Documentation

§ GSM_Phone_Bitmap_Types

Enumerator
GSM_NokiaStartupLogo 
GSM_NokiaOperatorLogo 
GSM_Nokia7110OperatorLogo 
GSM_Nokia6510OperatorLogo 
GSM_NokiaCallerLogo 
GSM_NokiaPictureImage 
GSM_Nokia7110StartupLogo 
GSM_Nokia6210StartupLogo 
GSM_AlcatelBMMIPicture 
GSM_EMSSmallPicture 
GSM_EMSMediumPicture 
GSM_EMSBigPicture 
GSM_EMSVariablePicture 

Definition at line 9 of file gsmlogo.h.

Function Documentation

§ Bitmap2BMP()

GSM_Error Bitmap2BMP ( unsigned char *  buffer,
FILE *  file,
GSM_Bitmap bitmap 
)

Definition at line 321 of file gsmlogo.c.

References GSM_Bitmap::BitmapHeight, GSM_Bitmap::BitmapWidth, chk_fwrite, dbgprintf, ERR_NONE, ERR_WRITING_FILE, FALSE, GSM_IsPointBitmap(), and TRUE.

Referenced by savebmp().

322 {
323  size_t x,i,sizeimage,buffpos=0;
324  ssize_t y, pos;
325  unsigned char buff[1];
326  div_t division;
327  gboolean isfile=FALSE;
328 
329  unsigned char header[]={
330 /*1'st header*/ 'B','M', /* BMP file ID */
331  0x00,0x00,0x00,0x00, /* Size of file */
332  0x00,0x00, /* Reserved for future use */
333  0x00,0x00, /* Reserved for future use */
334  62,0x00,0x00,0x00, /* Offset for image data */
335 
336 /*2'nd header*/ 40,0x00,0x00,0x00, /* Length of this part of header */
337  0x00,0x00,0x00,0x00, /* Width of image */
338  0x00,0x00,0x00,0x00, /* Height of image */
339  1,0x00, /* How many planes in target device */
340  1,0x00, /* How many colors in image. 1 means 2^1=2 colors */
341  0x00,0x00,0x00,0x00, /* Type of compression. 0 means no compression */
342 /*Sometimes */ 0x00,0x00,0x00,0x00, /* Size of part with image data */
343 /*ttttttt...*/ 0xE8,0x03,0x00,0x00, /* XPelsPerMeter */
344 /*hhiiiiissss*/ 0xE8,0x03,0x00,0x00, /* YPelsPerMeter */
345 /*part of header*/0x02,0x00,0x00,0x00, /* How many colors from palette is used */
346 /*doesn't exist*/ 0x00,0x00,0x00,0x00, /* How many colors from palette is required to display image. 0 means all */
347 
348 /*Color palette*/ 0x00,0x00,0x00, /* First color in palette in Blue, Green, Red. Here white */
349  0x00, /* Each color in palette is end by 4'th byte */
350  102, 204, 102, /* Second color in palette in Blue, Green, Red. Here green */
351  0x00}; /* Each color in palette is end by 4'th byte */
352 
353  if (file!=NULL) isfile=TRUE;
354 
355  header[22]=bitmap->BitmapHeight;
356  header[18]=bitmap->BitmapWidth;
357 
358  pos = 7;
359  sizeimage = 0;
360  /*lines are written from the last to the first*/
361  for (y = bitmap->BitmapHeight - 1; y >= 0; y--) {
362  i=1;
363  for (x=0;x<bitmap->BitmapWidth;x++) {
364  /*new byte !*/
365  if (pos==7) {
366  if (x!=0) sizeimage++;
367  i++;
368  /*each line is written in multiply of 4 bytes*/
369  if(i==5) i=1;
370  }
371  pos--;
372  /*going to new byte*/
373  if (pos<0) pos=7;
374  }
375  /*going to new byte*/
376  pos=7;
377  sizeimage++;
378  if (i!=1) {
379  /*each line is written in multiply of 4 bytes*/
380  while (i!=5) {
381  sizeimage++;
382  i++;
383  }
384  }
385  }
386  dbgprintf(NULL, "Data size in BMP file: %ld\n", (long)sizeimage);
387  division=div(sizeimage,256);
388  header[35]=division.quot;
389  header[34]=sizeimage-(division.quot*256);
390  sizeimage=sizeimage+sizeof(header);
391  dbgprintf(NULL, "Size of BMP file: %ld\n", (long)sizeimage);
392  division=div(sizeimage,256);
393  header[3]=division.quot;
394  header[2]=sizeimage-(division.quot*256);
395 
396  if (isfile) {
397  chk_fwrite(header,1,sizeof(header),file);
398  } else {
399  memcpy(buffer,header,sizeof(header));
400  buffpos += sizeof(header);
401  }
402 
403  pos=7;
404  /*lines are written from the last to the first*/
405  for (y=bitmap->BitmapHeight-1;y>=0;y--) {
406  i=1;
407  for (x=0;x<bitmap->BitmapWidth;x++) {
408  /*new byte !*/
409  if (pos==7) {
410  if (x!=0) {
411  if (isfile) {
412  chk_fwrite(buff, 1, sizeof(buff), file);
413  } else {
414  memcpy (buffer+buffpos,buff,1);
415  buffpos++;
416  }
417  }
418  i++;
419  /*each line is written in multiply of 4 bytes*/
420  if(i==5) i=1;
421  buff[0]=0;
422  }
423  if (!GSM_IsPointBitmap(bitmap,x,y)) buff[0]|=(1<<pos);
424  pos--;
425  /*going to new byte*/
426  if (pos<0) pos=7;
427  }
428  /*going to new byte*/
429  pos=7;
430  if (isfile) {
431  chk_fwrite(buff, 1, sizeof(buff), file);
432  } else {
433  memcpy (buffer+buffpos,buff,1);
434  buffpos++;
435  }
436  if (i!=1) {
437  /*each line is written in multiply of 4 bytes*/
438  while (i!=5) {
439  buff[0]=0;
440  if (isfile) {
441  chk_fwrite(buff, 1, sizeof(buff), file);
442  } else {
443  memcpy (buffer+buffpos,buff,1);
444  buffpos++;
445  }
446  i++;
447  }
448  }
449  }
450  return ERR_NONE;
451 fail:
452  return ERR_WRITING_FILE;
453 }
#define chk_fwrite(data, size, count, file)
Definition: gsmlogo.c:20
int gboolean
Definition: gammu-types.h:23
#define FALSE
Definition: gammu-types.h:25
gboolean GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:238
#define dbgprintf
Definition: debug.h:72
size_t BitmapHeight
Definition: gammu-bitmap.h:152
size_t BitmapWidth
Definition: gammu-bitmap.h:156
#define TRUE
Definition: gammu-types.h:28

§ BMP2Bitmap()

GSM_Error BMP2Bitmap ( unsigned char *  buffer,
FILE *  file,
GSM_Bitmap bitmap 
)

Definition at line 705 of file gsmlogo.c.

References GSM_Bitmap::BitmapHeight, GSM_Bitmap::BitmapWidth, dbgprintf, ERR_FILENOTSUPPORTED, ERR_NONE, FALSE, GSM_ClearBitmap(), GSM_GetMaxBitmapWidthHeight(), GSM_None, GSM_SetPointBitmap(), GSM_StartupLogo, TRUE, and GSM_Bitmap::Type.

Referenced by loadbmp().

706 {
707  gboolean first_white,isfile=FALSE;
708  unsigned char buff[60];
709  size_t w,h,x,i,buffpos=0;
710  ssize_t y, pos;
711  size_t readbytes;
712 #ifdef DEBUG
713  int sizeimage=0;
714 #endif
715 
716  if (bitmap->Type == GSM_None) bitmap->Type = GSM_StartupLogo;
717  if (file!=NULL) isfile=TRUE;
718 
719  /* Read the header */
720  if (isfile) {
721  readbytes = fread(buff, 1, 54, file);
722  if (readbytes != 54) return ERR_FILENOTSUPPORTED;
723  } else {
724  memcpy(buff,buffer,54);
725  }
726 
727  /* height and width of image in the file */
728  h=buff[22]+256*buff[21];
729  w=buff[18]+256*buff[17];
730  dbgprintf(NULL, "Image Size in BMP file: %ldx%ld\n", (long)w, (long)h);
731 
732  GSM_GetMaxBitmapWidthHeight(bitmap->Type, &bitmap->BitmapWidth, &bitmap->BitmapHeight);
733  if (h<bitmap->BitmapHeight) bitmap->BitmapHeight=h;
734  if (w<bitmap->BitmapWidth) bitmap->BitmapWidth=w;
735  dbgprintf(NULL, "Height %ld %ld width %ld %ld\n",
736  (long)h,
737  (long)bitmap->BitmapHeight,
738  (long)w,
739  (long)bitmap->BitmapWidth);
740 
741  GSM_ClearBitmap(bitmap);
742 
743 #ifdef DEBUG
744  dbgprintf(NULL, "Number of colors in BMP file: ");
745  switch (buff[28]) {
746  case 1 : dbgprintf(NULL, "2 (supported)\n"); break;
747  case 4 : dbgprintf(NULL, "16 (NOT SUPPORTED)\n"); break;
748  case 8 : dbgprintf(NULL, "256 (NOT SUPPORTED)\n"); break;
749  case 24 : dbgprintf(NULL, "True Color (NOT SUPPORTED)\n"); break;
750  default : dbgprintf(NULL, "unknown\n"); break;
751  }
752 #endif
753  if (buff[28]!=1) {
754  dbgprintf(NULL, "Wrong number of colors\n");
755  return ERR_FILENOTSUPPORTED;
756  }
757 
758 #ifdef DEBUG
759  dbgprintf(NULL, "Compression in BMP file: ");
760  switch (buff[30]) {
761  case 0 :dbgprintf(NULL, "no compression (supported)\n"); break;
762  case 1 :dbgprintf(NULL, "RLE8 (NOT SUPPORTED)\n"); break;
763  case 2 :dbgprintf(NULL, "RLE4 (NOT SUPPORTED)\n"); break;
764  default :dbgprintf(NULL, "unknown\n"); break;
765  }
766 #endif
767  if (buff[30]!=0) {
768  dbgprintf(NULL, "Compression type not supported\n");
769  return ERR_FILENOTSUPPORTED;
770  }
771 
772  /* Read palette */
773  if (isfile) {
774  pos=buff[10]-54;
775  readbytes = fread(buff, 1, pos, file);
776  if (readbytes != (size_t)pos) return ERR_FILENOTSUPPORTED;
777  } else {
778  pos=buff[10]-54;
779  buffpos=buff[10];
780  memcpy (buff,buffer+54,pos);
781  }
782 
783  first_white = ((buff[6] * buff[5] * buff[4]) > (buff[2] * buff[1] * buff[0]));
784 #ifdef DEBUG
785  dbgprintf(NULL, "First color in BMP file: #%02x%02x%02x%s\n",
786  buff[2], buff[1], buff[0],
787  first_white ? " (used as white)" : " (used as black)"
788  );
789  dbgprintf(NULL, "Second color in BMP file: #%02x%02x%02x%s\n",
790  buff[6], buff[5], buff[4],
791  !first_white ? " (used as white)" : " (used as black)"
792  );
793 #endif
794 
795  pos=7;
796  /* lines are written from the last to the first */
797  for (y=h-1;y>=0;y--) {
798  i=1;
799  for (x=0;x<w;x++) {
800  /* new byte ! */
801  if (pos==7) {
802  if (isfile) {
803  readbytes = fread(buff, 1, 1, file);
804  if (readbytes != 1) return ERR_FILENOTSUPPORTED;
805  } else {
806  memcpy (buff,buffer+buffpos,1);
807  buffpos++;
808  }
809 #ifdef DEBUG
810  sizeimage++;
811 #endif
812  i++;
813  /* each line is written in multiply of 4 bytes */
814  if(i==5) i=1;
815  }
816  /* we have top left corner ! */
817  if (x<=bitmap->BitmapWidth && (size_t)y<=bitmap->BitmapHeight) {
818  if (first_white) {
819  if ((buff[0]&(1<<pos))<=0) GSM_SetPointBitmap(bitmap,x,y);
820  } else {
821  if ((buff[0]&(1<<pos))>0) GSM_SetPointBitmap(bitmap,x,y);
822  }
823  }
824  pos--;
825  /* going to new byte */
826  if (pos<0) pos=7;
827  }
828  /* going to new byte */
829  pos=7;
830  if (i!=1) {
831  /* each line is written in multiply of 4 bytes */
832  while (i!=5) {
833  if (isfile) {
834  readbytes = fread(buff, 1, 1, file);
835  if (readbytes != 1) return ERR_FILENOTSUPPORTED;
836  } else {
837  memcpy (buff,buffer+buffpos,1);
838  buffpos++;
839  }
840 #ifdef DEBUG
841  sizeimage++;
842 #endif
843  i++;
844  }
845  }
846  }
847 #ifdef DEBUG
848  dbgprintf(NULL, "Data size in BMP file: %i\n",sizeimage);
849 #endif
850  return(ERR_NONE);
851 }
GSM_Bitmap_Types Type
Definition: gammu-bitmap.h:107
int gboolean
Definition: gammu-types.h:23
#define FALSE
Definition: gammu-types.h:25
#define dbgprintf
Definition: debug.h:72
void GSM_ClearBitmap(GSM_Bitmap *bmp)
Definition: gsmlogo.c:247
size_t BitmapHeight
Definition: gammu-bitmap.h:152
size_t BitmapWidth
Definition: gammu-bitmap.h:156
void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:228
#define TRUE
Definition: gammu-types.h:28
void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:217

§ GSM_GetBitmapSize()

size_t GSM_GetBitmapSize ( GSM_Bitmap bmp)

Definition at line 252 of file gsmlogo.c.

References GSM_Bitmap::BitmapHeight, and GSM_Bitmap::BitmapWidth.

Referenced by GSM_ClearBitmap().

253 {
254  return ((bmp->BitmapWidth * bmp->BitmapHeight) / 8) + 1;
255 }
size_t BitmapHeight
Definition: gammu-bitmap.h:152
size_t BitmapWidth
Definition: gammu-bitmap.h:156

§ GSM_GetMaxBitmapWidthHeight()

void GSM_GetMaxBitmapWidthHeight ( GSM_Bitmap_Types  Type,
size_t *  width,
size_t *  height 
)

Definition at line 217 of file gsmlogo.c.

References GSM_CallerGroupLogo, GSM_OperatorLogo, GSM_PictureImage, and GSM_StartupLogo.

Referenced by BMP2Bitmap(), loadnlm(), and loadnolngg().

218 {
219  switch (Type) {
220  case GSM_CallerGroupLogo: *width=72; *height=14; break;
221  case GSM_OperatorLogo : *width=101;*height=21; break;
222  case GSM_StartupLogo : *width=96; *height=65; break;
223  case GSM_PictureImage : *width=72; *height=28; break;
224  default : break;
225  }
226 }

§ GSM_ResizeBitmap()

void GSM_ResizeBitmap ( GSM_Bitmap dest,
GSM_Bitmap src,
size_t  width,
size_t  height 
)

Definition at line 288 of file gsmlogo.c.

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

Referenced by GSM_EncodeEMSMultiPartSMS(), and PHONE_EncodeBitmap().

289 {
290  size_t startx=0,endx=0,setx=0, starty=0,endy=0,sety=0, x, y;
291 
292  if (src->BitmapWidth<=width) {
293  startx = 0;
294  endx = src->BitmapWidth;
295  setx = (width-src->BitmapWidth)/2;
296  } else {
297  startx = (src->BitmapWidth-width)/2;
298  endx = startx + width;
299  setx = 0;
300  }
301  if (src->BitmapHeight<=height) {
302  starty = 0;
303  endy = src->BitmapHeight;
304  sety = (height-src->BitmapHeight)/2;
305  } else {
306  starty = (src->BitmapHeight-height)/2;
307  endy = starty + height;
308  sety = 0;
309  }
310  dest->BitmapHeight = height;
311  dest->BitmapWidth = width;
312  GSM_ClearBitmap(dest);
313  for (x=startx;x<endx;x++) {
314  for (y=starty;y<endy;y++) {
315  if (GSM_IsPointBitmap(src,x,y))
316  GSM_SetPointBitmap(dest,setx+x-startx,sety+y-starty);
317  }
318  }
319 }
gboolean GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:238
void GSM_ClearBitmap(GSM_Bitmap *bmp)
Definition: gsmlogo.c:247
size_t BitmapHeight
Definition: gammu-bitmap.h:152
size_t BitmapWidth
Definition: gammu-bitmap.h:156
void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:228

§ GSM_ReverseBitmap()

void GSM_ReverseBitmap ( GSM_Bitmap Bitmap)

Definition at line 273 of file gsmlogo.c.

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

Referenced by loadwbmp().

274 {
275  size_t x, y;
276 
277  for (x=0;x<Bitmap->BitmapWidth;x++) {
278  for (y=0;y<Bitmap->BitmapHeight;y++) {
279  if (GSM_IsPointBitmap(Bitmap,x,y)) {
280  GSM_ClearPointBitmap(Bitmap, x, y);
281  } else {
282  GSM_SetPointBitmap(Bitmap, x, y);
283  }
284  }
285  }
286 }
gboolean GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:238
size_t BitmapHeight
Definition: gammu-bitmap.h:152
void GSM_ClearPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:233
size_t BitmapWidth
Definition: gammu-bitmap.h:156
void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:228

§ NOKIA_CopyBitmap()

void NOKIA_CopyBitmap ( GSM_Phone_Bitmap_Types  Type,
GSM_Bitmap Bitmap,
char *  Buffer,
size_t *  Length 
)

Definition at line 1132 of file gsmlogo.c.

References PHONE_EncodeBitmap(), PHONE_GetBitmapSize(), and PHONE_GetBitmapWidthHeight().

Referenced by GSM_EncodeMultiPartSMS(), and GSM_EncodeSMS30MultiPartSMS().

1133 {
1134  size_t Width, Height;
1135 
1136  Buffer[(*Length)++] = 0x00;
1137  PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
1138  Buffer[(*Length)++] = Width;
1139  Buffer[(*Length)++] = Height;
1140  Buffer[(*Length)++] = 0x01;
1141  PHONE_EncodeBitmap(Type, Buffer + (*Length), Bitmap);
1142  (*Length) = (*Length) + PHONE_GetBitmapSize(Type,0,0);
1143 }
size_t PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, size_t Width, size_t Height)
Definition: gsmlogo.c:44
void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:197
void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:23

§ PHONE_ClearBitmap()

void PHONE_ClearBitmap ( GSM_Phone_Bitmap_Types  Type,
char *  buffer,
size_t  width,
size_t  height 
)

Definition at line 192 of file gsmlogo.c.

References PHONE_GetBitmapSize().

Referenced by PHONE_EncodeBitmap().

193 {
194  memset(buffer,0,PHONE_GetBitmapSize(Type,width,height));
195 }
size_t PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, size_t Width, size_t Height)
Definition: gsmlogo.c:44

§ PHONE_DecodeBitmap()

void PHONE_DecodeBitmap ( GSM_Phone_Bitmap_Types  Type,
char *  buffer,
GSM_Bitmap Bitmap 
)

Definition at line 141 of file gsmlogo.c.

References GSM_Bitmap::BitmapEnabled, GSM_Bitmap::BitmapHeight, GSM_Bitmap::BitmapWidth, GSM_Bitmap::DefaultBitmap, GSM_Bitmap::DefaultName, GSM_Bitmap::DefaultRingtone, FALSE, GSM_Bitmap::FileSystemPicture, GSM_AlcatelBMMIPicture, GSM_CallerGroupLogo, GSM_ClearBitmap(), GSM_EMSBigPicture, GSM_EMSMediumPicture, GSM_EMSSmallPicture, GSM_EMSVariablePicture, GSM_Nokia6210StartupLogo, GSM_Nokia6510OperatorLogo, GSM_Nokia7110OperatorLogo, GSM_Nokia7110StartupLogo, GSM_NokiaCallerLogo, GSM_NokiaOperatorLogo, GSM_NokiaPictureImage, GSM_NokiaStartupLogo, GSM_OperatorLogo, GSM_PictureImage, GSM_SetPointBitmap(), GSM_StartupLogo, GSM_Bitmap::ID, GSM_Bitmap::Location, GSM_Bitmap::Name, GSM_Bitmap::NetworkCode, PHONE_GetBitmapWidthHeight(), PHONE_IsPointBitmap(), GSM_Bitmap::RingtoneID, GSM_Bitmap::Sender, GSM_Bitmap::Text, and GSM_Bitmap::Type.

Referenced by GSM_DecodeEMSMultiPartSMS(), GSM_DecodeMultiPartSMS(), GSM_DecodeNokiaProfile(), loadnsl(), loadwbmp(), and N71_65_DecodePhonebook().

142 {
143  size_t width, height, x,y;
144 
145  PHONE_GetBitmapWidthHeight(Type, &width, &height);
147  Bitmap->BitmapHeight = height;
148  Bitmap->BitmapWidth = width;
149  }
150  switch (Type) {
151  case GSM_NokiaOperatorLogo :
153  case GSM_Nokia6510OperatorLogo : Bitmap->Type=GSM_OperatorLogo; break;
154  case GSM_NokiaCallerLogo : Bitmap->Type=GSM_CallerGroupLogo; break;
156  case GSM_NokiaStartupLogo :
158  case GSM_Nokia6210StartupLogo : Bitmap->Type=GSM_StartupLogo; break;
159  case GSM_NokiaPictureImage :
161  case GSM_EMSSmallPicture :
162  case GSM_EMSMediumPicture :
163  case GSM_EMSBigPicture : Bitmap->Type=GSM_PictureImage; break;
164  }
165 
166  Bitmap->Location = 0;
167  Bitmap->Text[0] = 0;
168  Bitmap->Text[1] = 0;
169  Bitmap->BitmapEnabled = FALSE;
170  Bitmap->DefaultName = FALSE;
171  Bitmap->DefaultBitmap = FALSE;
172  Bitmap->DefaultRingtone = FALSE;
173  Bitmap->RingtoneID = 0;
174  Bitmap->FileSystemPicture = 0;
175  Bitmap->NetworkCode[0] = 0;
176  Bitmap->Sender[0] = 0;
177  Bitmap->Sender[1] = 0;
178  Bitmap->ID = 0;
179  Bitmap->Name[0] = 0;
180  Bitmap->Name[1] = 0;
181 
182  GSM_ClearBitmap(Bitmap);
183  for (x=0;x<Bitmap->BitmapWidth;x++) {
184  for (y=0;y<Bitmap->BitmapHeight;y++) {
185  if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) {
186  GSM_SetPointBitmap(Bitmap,x,y);
187  }
188  }
189  }
190 }
gboolean DefaultRingtone
Definition: gammu-bitmap.h:134
unsigned char ID
Definition: gammu-bitmap.h:168
GSM_Bitmap_Types Type
Definition: gammu-bitmap.h:107
unsigned char Sender[2 *(GSM_MAX_NUMBER_LENGTH+1)]
Definition: gammu-bitmap.h:164
gboolean FileSystemPicture
Definition: gammu-bitmap.h:144
unsigned char Location
Definition: gammu-bitmap.h:112
char NetworkCode[10]
Definition: gammu-bitmap.h:160
unsigned char RingtoneID
Definition: gammu-bitmap.h:138
#define FALSE
Definition: gammu-types.h:25
gboolean BitmapEnabled
Definition: gammu-bitmap.h:122
gboolean DefaultBitmap
Definition: gammu-bitmap.h:130
unsigned char Name[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:176
void GSM_ClearBitmap(GSM_Bitmap *bmp)
Definition: gsmlogo.c:247
gboolean DefaultName
Definition: gammu-bitmap.h:126
void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:23
size_t BitmapHeight
Definition: gammu-bitmap.h:152
static gboolean PHONE_IsPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int x, int y, int width, int height)
Definition: gsmlogo.c:77
size_t BitmapWidth
Definition: gammu-bitmap.h:156
unsigned char Text[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:118
void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:228

§ PHONE_EncodeBitmap()

void PHONE_EncodeBitmap ( GSM_Phone_Bitmap_Types  Type,
char *  buffer,
GSM_Bitmap Bitmap 
)

Definition at line 197 of file gsmlogo.c.

References GSM_Bitmap::BitmapHeight, GSM_Bitmap::BitmapWidth, GSM_IsPointBitmap(), GSM_ResizeBitmap(), PHONE_ClearBitmap(), PHONE_GetBitmapWidthHeight(), and PHONE_SetPointBitmap().

Referenced by GSM_EncodeEMSMultiPartSMS(), GSM_EncodeMultiPartSMS(), NOKIA_CopyBitmap(), and savensl().

198 {
199  size_t width, height, x, y;
200  GSM_Bitmap dest;
201 
202  PHONE_GetBitmapWidthHeight(Type, &width, &height);
203  if (width == 0 && height == 0) {
204  width = Bitmap->BitmapWidth;
205  height = Bitmap->BitmapHeight;
206  }
207  GSM_ResizeBitmap(&dest, Bitmap, width, height);
208  PHONE_ClearBitmap(Type, buffer, width, height);
209 
210  for (x=0;x<width;x++) {
211  for (y=0;y<height;y++) {
212  if (GSM_IsPointBitmap(&dest,x,y)) PHONE_SetPointBitmap(Type, buffer, x, y, width, height);
213  }
214  }
215 }
static void PHONE_SetPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int x, int y, int width, int height)
Definition: gsmlogo.c:109
void GSM_ResizeBitmap(GSM_Bitmap *dest, GSM_Bitmap *src, size_t width, size_t height)
Definition: gsmlogo.c:288
gboolean GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:238
void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:23
size_t BitmapHeight
Definition: gammu-bitmap.h:152
size_t BitmapWidth
Definition: gammu-bitmap.h:156
void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, size_t width, size_t height)
Definition: gsmlogo.c:192

§ PHONE_GetBitmapSize()

size_t PHONE_GetBitmapSize ( GSM_Phone_Bitmap_Types  Type,
size_t  width,
size_t  height 
)

Definition at line 44 of file gsmlogo.c.

References GSM_AlcatelBMMIPicture, GSM_EMSBigPicture, GSM_EMSMediumPicture, GSM_EMSSmallPicture, GSM_EMSVariablePicture, GSM_Nokia6210StartupLogo, GSM_Nokia6510OperatorLogo, GSM_Nokia7110OperatorLogo, GSM_Nokia7110StartupLogo, GSM_NokiaCallerLogo, GSM_NokiaOperatorLogo, GSM_NokiaPictureImage, GSM_NokiaStartupLogo, and PHONE_GetBitmapWidthHeight().

Referenced by GSM_DecodeEMSMultiPartSMS(), GSM_EncodeEMSMultiPartSMS(), GSM_EncodeMultiPartSMS(), NOKIA_CopyBitmap(), PHONE_ClearBitmap(), and savensl().

45 {
46  size_t width, height, x;
47 
48  PHONE_GetBitmapWidthHeight(Type, &width, &height);
49  if (width == 0 && height == 0) {
50  width = Width;
51  height = Height;
52  }
53  switch (Type) {
55  x = width * height;
56  return x/8 + (x%8 > 0);
58  return (width*height + 7)/8;
65  case GSM_EMSBigPicture:
67  return height*width/8;
70  return (height+7)/8*width;
72  return width*((height+7)/8);
73  }
74  return 0;
75 }
void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:23

§ PHONE_GetBitmapWidthHeight()

void PHONE_GetBitmapWidthHeight ( GSM_Phone_Bitmap_Types  Type,
size_t *  width,
size_t *  height 
)

Definition at line 23 of file gsmlogo.c.

References GSM_AlcatelBMMIPicture, GSM_EMSBigPicture, GSM_EMSMediumPicture, GSM_EMSSmallPicture, GSM_EMSVariablePicture, GSM_Nokia6210StartupLogo, GSM_Nokia6510OperatorLogo, GSM_Nokia7110OperatorLogo, GSM_Nokia7110StartupLogo, GSM_NokiaCallerLogo, GSM_NokiaOperatorLogo, GSM_NokiaPictureImage, and GSM_NokiaStartupLogo.

Referenced by GSM_EncodeEMSMultiPartSMS(), NOKIA_CopyBitmap(), PHONE_DecodeBitmap(), PHONE_EncodeBitmap(), and PHONE_GetBitmapSize().

24 {
25  *width = 0;
26  *height = 0;
27  switch (Type) {
28  case GSM_EMSSmallPicture : *width=8; *height=8; break;
29  case GSM_EMSMediumPicture : *width=16; *height=16; break;
30  case GSM_EMSBigPicture : *width=32; *height=32; break;
32  case GSM_NokiaCallerLogo : *width=72; *height=14; break;
33  case GSM_NokiaPictureImage : *width=72; *height=28; break;
35  case GSM_Nokia6510OperatorLogo : *width=78; *height=21; break;
36  case GSM_NokiaStartupLogo : *width=84; *height=48; break;
37  case GSM_Nokia6210StartupLogo : *width=96; *height=60; break;
38  case GSM_Nokia7110StartupLogo : *width=96; *height=65; break;
39  case GSM_EMSVariablePicture : break;
40  case GSM_AlcatelBMMIPicture : break;
41  }
42 }