Gammu internals  1.38.0
gsmlogo.c
Go to the documentation of this file.
1 /* (c) 2001-2004 by Marcin Wiacek */
2 
3 #define _GNU_SOURCE
4 #include <string.h>
5 #include <stdlib.h>
6 #include <sys/stat.h>
7 
8 #include <gammu-debug.h>
9 
10 #include "../misc/coding/coding.h"
11 #include "../debug.h"
12 #include "gsmlogo.h"
13 #include "gsmnet.h"
14 
15 #include "../../helper/string.h"
16 
20 #define chk_fwrite(data, size, count, file) \
21  if (fwrite(data, size, count, file) != count) goto fail;
22 
23 void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
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 }
43 
44 size_t PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, size_t Width, size_t Height)
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 }
76 
77 static gboolean PHONE_IsPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int x, int y, int width, int height)
78 {
79  int i=0, pixel;
80 
81  if (x > width || y > height) return FALSE;
82 
83  switch (Type) {
88  i=(buffer[(y / 8 * width) + x] & (1 << (y % 8)));
89  break;
96  case GSM_EMSBigPicture:
97  pixel=width*y + x;
98  i=(buffer[pixel / 8] & (1 << (7 - (pixel % 8))));
99  break;
101  i=(buffer[(9 * y) + (x / 8)] & (1 << (7 - (x % 8))));
102  break;
104  break;
105  }
106  if (i) return TRUE; else return FALSE;
107 }
108 
109 static void PHONE_SetPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int x, int y, int width, int height)
110 {
111  int pixel;
112 
113  switch (Type) {
118  buffer[(y / 8 * width)+x] |= 1 << (y % 8);
119  break;
122  case GSM_NokiaCallerLogo:
123  case GSM_EMSSmallPicture:
125  case GSM_EMSBigPicture:
127  pixel = width*y + x;
128  buffer[pixel / 8] |= 1 << (7 - (pixel % 8));
129  break;
131  buffer[(9 * y) + (x / 8)] |= 1 << (7 - (x % 8));
132  break;
134  pixel = height / 8;
135  if ((height % 8) != 0) pixel++;
136  buffer[(pixel * x) + (y / 8)] |= 1 << (7 - (y % 8));
137  break;
138  }
139 }
140 
141 void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
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 }
191 
192 void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, size_t width, size_t height)
193 {
194  memset(buffer,0,PHONE_GetBitmapSize(Type,width,height));
195 }
196 
197 void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
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 }
216 
217 void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, size_t *width, size_t *height)
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 }
227 
228 void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y)
229 {
230  SetBit(bmp->BitmapPoints,y*bmp->BitmapWidth+x);
231 }
232 
233 void GSM_ClearPointBitmap(GSM_Bitmap *bmp, int x, int y)
234 {
235  ClearBit(bmp->BitmapPoints,y*bmp->BitmapWidth+x);
236 }
237 
239 {
240  if (GetBit(bmp->BitmapPoints, (y * bmp->BitmapWidth) + x)) {
241  return TRUE;
242  } else {
243  return FALSE;
244  }
245 }
246 
248 {
249  memset(bmp->BitmapPoints,0,GSM_GetBitmapSize(bmp));
250 }
251 
253 {
254  return ((bmp->BitmapWidth * bmp->BitmapHeight) / 8) + 1;
255 }
256 
257 void GSM_PrintBitmap(FILE *file, GSM_Bitmap *bitmap)
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 }
272 
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 }
287 
288 void GSM_ResizeBitmap(GSM_Bitmap *dest, GSM_Bitmap *src, size_t width, size_t height)
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 }
320 
321 GSM_Error Bitmap2BMP(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap)
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 }
454 
455 static GSM_Error savebmp(FILE *file, GSM_MultiBitmap *bitmap)
456 {
457  GSM_Error error;
458 
459  error=Bitmap2BMP(NULL,file,&bitmap->Bitmap[0]);
460  return error;
461 }
462 
463 static GSM_Error PrivSaveNLMWBMP(FILE *file, GSM_Bitmap *Bitmap)
464 {
465  unsigned char buffer[1000];
466  size_t x,y,pos;
467  ssize_t pos2;
468  div_t division;
469 
470  pos=0;pos2=7;
471  for (y=0;y<Bitmap->BitmapHeight;y++) {
472  for (x=0;x<Bitmap->BitmapWidth;x++) {
473  if (pos2==7) buffer[pos]=0;
474  if (GSM_IsPointBitmap(Bitmap,x,y)) buffer[pos]|=(1<<pos2);
475  pos2--;
476  /* going to new line */
477  if (pos2<0) {pos2=7;pos++;}
478  }
479  /* for startup logos - new line with new byte */
480  if (pos2!=7) {pos2=7;pos++;}
481  }
482 
483  division=div(Bitmap->BitmapWidth,8);
484  /* For startup logos */
485  if (division.rem!=0) division.quot++;
486 
487  chk_fwrite(buffer,1,(size_t)(division.quot*Bitmap->BitmapHeight),file);
488  return ERR_NONE;
489 fail:
490  return ERR_WRITING_FILE;
491 }
492 
493 static GSM_Error savenlm(FILE *file, GSM_MultiBitmap *bitmap)
494 {
495  int i;
496  GSM_Error error;
497  char header[]={
498  'N','L','M',' ', /* Nokia Logo Manager file ID. */
499  0x01,
500  0x00, /* 0x00 (OP), 0x01 (CLI), 0x02 (Startup), 0x03 (Picture)*/
501  0x00, /* Number of images inside file - 1. 0x01==2 images, 0x03==4 images, etc. */
502  0x00, /* Width. */
503  0x00, /* Height. */
504  0x01};
505 
506  switch (bitmap->Bitmap[0].Type) {
507  case GSM_OperatorLogo : header[5]=0x00; break;
508  case GSM_CallerGroupLogo : header[5]=0x01; break;
509  case GSM_StartupLogo : header[5]=0x02; break;
510  case GSM_PictureImage : header[5]=0x03; break;
511  default : return ERR_UNKNOWN;
512  }
513  header[6] = bitmap->Number - 1;
514  header[7] = bitmap->Bitmap[0].BitmapWidth;
515  header[8] = bitmap->Bitmap[0].BitmapHeight;
516  chk_fwrite(header,1,sizeof(header),file);
517 
518  for (i=0;i<bitmap->Number;i++) {
519  error = PrivSaveNLMWBMP(file, &bitmap->Bitmap[i]);
520  if (error != ERR_NONE) {
521  return error;
522  }
523  }
524 
525  return ERR_NONE;
526 fail:
527  return ERR_WRITING_FILE;
528 }
529 
530 static GSM_Error PrivSaveNGGNOL(FILE *file, GSM_MultiBitmap *bitmap)
531 {
532  char *buffer=NULL;
533  size_t x=0,y=0;
534  size_t current=0;
535 
536  buffer = (char *)malloc(bitmap->Bitmap[0].BitmapHeight * bitmap->Bitmap[0].BitmapWidth);
537  if (buffer == NULL) {
538  return ERR_MOREMEMORY;
539  }
540 
541  for (y=0;y<bitmap->Bitmap[0].BitmapHeight;y++) {
542  for (x=0;x<bitmap->Bitmap[0].BitmapWidth;x++) {
543  if (GSM_IsPointBitmap(&bitmap->Bitmap[0],x,y)) {
544  buffer[current++] = '1';
545  } else {
546  buffer[current++] = '0';
547  }
548  }
549  }
550  chk_fwrite(buffer,1,current,file);
551  free(buffer);
552  buffer=NULL;
553  return ERR_NONE;
554 fail:
555  free(buffer);
556  buffer=NULL;
557  return ERR_WRITING_FILE;
558 }
559 
560 static GSM_Error savengg(FILE *file, GSM_MultiBitmap *bitmap)
561 {
562  char header[]={
563  'N','G','G',0x00,0x01,0x00,
564  0x00,0x00, /* Width */
565  0x00,0x00, /* Height */
566  0x01,0x00,0x01,0x00,
567  0x00, /* Unknown.Can't be checksum - for */
568  /* the same logo files can be different */
569  0x00};
570 
571  header[6] = bitmap->Bitmap[0].BitmapWidth;
572  header[8] = bitmap->Bitmap[0].BitmapHeight;
573  chk_fwrite(header,1,sizeof(header),file);
574 
575  return PrivSaveNGGNOL(file,bitmap);
576 
577 fail:
578  return ERR_WRITING_FILE;
579 }
580 
581 static GSM_Error savenol(FILE *file, GSM_MultiBitmap *bitmap)
582 {
583  int country = 0,net = 0;
584  char header[]={
585  'N','O','L',0x00,0x01,0x00,
586  0x00,0x00, /* MCC */
587  0x00,0x00, /* MNC */
588  0x00,0x00, /* Width */
589  0x00,0x00, /* Height */
590  0x01,0x00,0x01,0x00,
591  0x00, /* Unknown.Can't be checksum - for */
592  /* the same logo files can be different */
593  0x00};
594 
595  if (bitmap->Bitmap[0].Type == GSM_OperatorLogo) {
596  sscanf(bitmap->Bitmap[0].NetworkCode, "%d %d", &country, &net);
597  }
598 
599  header[6] = country%256;
600  header[7] = country/256;
601  header[8] = net%256;
602  header[9] = net/256;
603  header[10] = bitmap->Bitmap[0].BitmapWidth;
604  header[12] = bitmap->Bitmap[0].BitmapHeight;
605  chk_fwrite(header,1,sizeof(header),file);
606 
607  return PrivSaveNGGNOL(file,bitmap);
608 
609 fail:
610  return ERR_WRITING_FILE;
611 }
612 
613 static GSM_Error savexpm(FILE *file, GSM_MultiBitmap *bitmap)
614 {
615  size_t x,y;
616 
617  fprintf(file,"/* XPM */\n");
618  fprintf(file,"static char * ala_xpm[] = {\n");
619  fprintf(file,"\"%ld %ld 2 1\",\n",
620  (long)bitmap->Bitmap[0].BitmapWidth,
621  (long)bitmap->Bitmap[0].BitmapHeight);
622  fprintf(file,"\". s c m #000000 g4 #000000 g #000000 c #000000\",\n");
623  fprintf(file,"\"# s c m #ffffff g4 #ffffff g #ffffff c #ffffff\",\n");
624 
625  for (y=0;y<bitmap->Bitmap[0].BitmapHeight;y++) {
626  fprintf(file,"\"");
627  for (x=0;x<bitmap->Bitmap[0].BitmapWidth;x++)
628  if (GSM_IsPointBitmap(&bitmap->Bitmap[0],x,y)) {
629  fprintf(file,".");
630  } else {
631  fprintf(file,"#");
632  }
633  fprintf(file,"\"");
634  if (y==bitmap->Bitmap[0].BitmapHeight-1) {
635  fprintf(file,"};\n");
636  } else {
637  fprintf(file,",\n");
638  }
639  }
640 
641  return ERR_NONE;
642 }
643 
644 static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap)
645 {
646  char buffer[GSM_BITMAP_SIZE];
647  unsigned char header[]={
648  'F','O','R','M', 0x01,0xFE, /* File ID block, size 1*256+0xFE=510*/
649  'N','S','L','D', 0x01,0xF8}; /* Startup Logo block, size 1*256+0xF8=504*/
650 
651  chk_fwrite(header,1,sizeof(header),file);
652  PHONE_EncodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]);
654 
655  return ERR_NONE;
656 fail:
657  return ERR_WRITING_FILE;
658 }
659 
660 static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap)
661 {
662  unsigned char buffer[4];
663 
664  buffer[0] = 0x00;
665  buffer[1] = 0x00;
666  buffer[2] = bitmap->Bitmap[0].BitmapWidth;
667  buffer[3] = bitmap->Bitmap[0].BitmapHeight;
668  chk_fwrite(buffer,1,4,file);
669 
670  return PrivSaveNLMWBMP(file, &bitmap->Bitmap[0]);
671 
672 fail:
673  return ERR_WRITING_FILE;
674 }
675 
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 }
704 
705 GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap)
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 }
852 
853 static GSM_Error loadbmp(FILE *file, GSM_MultiBitmap *bitmap)
854 {
855  GSM_Error error;
856 
857  error=BMP2Bitmap(NULL,file,&bitmap->Bitmap[0]);
858  bitmap->Number = 1;
859  return error;
860 }
861 
862 static GSM_Error loadnlm (FILE *file, GSM_MultiBitmap *bitmap)
863 {
864  unsigned char buffer[1000];
865  size_t pos,x,y,h,w,i,number;
866  ssize_t pos2;
867  div_t division;
868  size_t readbytes;
869 
870  readbytes = fread(buffer,1,5,file);
871  if (readbytes != 5) return ERR_FILENOTSUPPORTED;
872 
873  readbytes = fread(buffer,1,1,file);
874  if (readbytes != 1) return ERR_FILENOTSUPPORTED;
875 
876  switch (buffer[0]) {
877  case 0x00:
878  dbgprintf(NULL, "Operator logo\n");
879  if (bitmap->Bitmap[0].Type == GSM_None) bitmap->Bitmap[0].Type = GSM_OperatorLogo;
880  break;
881  case 0x01:
882  dbgprintf(NULL, "Caller logo\n");
883  if (bitmap->Bitmap[0].Type == GSM_None) bitmap->Bitmap[0].Type = GSM_CallerGroupLogo;
884  break;
885  case 0x02:
886  dbgprintf(NULL, "Startup logo\n");
887  if (bitmap->Bitmap[0].Type == GSM_None) bitmap->Bitmap[0].Type = GSM_StartupLogo;
888  break;
889  case 0x03:
890  dbgprintf(NULL, "Picture Image logo\n");
891  if (bitmap->Bitmap[0].Type == GSM_None) bitmap->Bitmap[0].Type = GSM_PictureImage;
892  break;
893  }
894 
895  bitmap->Number = 0;
896  readbytes = fread(buffer,1,4,file);
897  if (readbytes != 4) return ERR_FILENOTSUPPORTED;
898  number = buffer[0] + 1;
899  w = buffer[1];
900  h = buffer[2];
901  for (i=0;i<number;i++) {
902  bitmap->Bitmap[i].Type = bitmap->Bitmap[0].Type;
903  GSM_GetMaxBitmapWidthHeight(bitmap->Bitmap[i].Type, &bitmap->Bitmap[i].BitmapWidth, &bitmap->Bitmap[i].BitmapHeight);
904  if (h < bitmap->Bitmap[i].BitmapHeight) bitmap->Bitmap[i].BitmapHeight = h;
905  if (w < bitmap->Bitmap[i].BitmapWidth) bitmap->Bitmap[i].BitmapWidth = w;
906 
907  division=div(w,8);
908  /* For startup logos */
909  if (division.rem!=0) division.quot++;
910  if (fread(buffer,1,(division.quot*h),file)!=(unsigned int)(division.quot*h)) return ERR_UNKNOWN;
911 
912  GSM_ClearBitmap(&bitmap->Bitmap[i]);
913 
914  pos=0;pos2=7;
915  for (y=0;y<h;y++) {
916  for (x=0;x<w;x++) {
917  if ((buffer[pos]&(1<<pos2))>0) {
918  if (y<bitmap->Bitmap[i].BitmapHeight && x<bitmap->Bitmap[i].BitmapWidth) GSM_SetPointBitmap(&bitmap->Bitmap[i],x,y);
919  }
920  pos2--;
921  /* going to new byte */
922  if (pos2<0) {pos2=7;pos++;}
923  }
924  /* for startup logos-new line means new byte */
925  if (pos2!=7) {pos2=7;pos++;}
926  }
927  bitmap->Number++;
928  if (bitmap->Number == GSM_MAX_MULTI_BITMAP) break;
929  }
930  return (ERR_NONE);
931 }
932 
933 static GSM_Error loadnolngg(FILE *file, GSM_MultiBitmap *bitmap, gboolean nolformat)
934 {
935  unsigned char buffer[2000];
936  size_t i,h,w,x,y;
937  size_t readbytes;
938 
939  readbytes = fread(buffer, 1, 6, file);
940  if (readbytes != 6) return ERR_FILENOTSUPPORTED;
941 
942  if (bitmap->Bitmap[0].Type == GSM_None) bitmap->Bitmap[0].Type = GSM_CallerGroupLogo;
943  if (nolformat) {
944  readbytes = fread(buffer, 1, 4, file);
945  if (readbytes != 4) return ERR_FILENOTSUPPORTED;
946  sprintf(bitmap->Bitmap[0].NetworkCode, "%d %02d", buffer[0]+256*buffer[1], buffer[2]);
947  if (bitmap->Bitmap[0].Type == GSM_None) bitmap->Bitmap[0].Type = GSM_OperatorLogo;
948  }
949 
950  readbytes = fread(buffer, 1, 4, file);
951  if (readbytes != 4) return ERR_FILENOTSUPPORTED;
952 
953  w = buffer[0];
954  h = buffer[2];
955  GSM_GetMaxBitmapWidthHeight(bitmap->Bitmap[0].Type, &bitmap->Bitmap[0].BitmapWidth, &bitmap->Bitmap[0].BitmapHeight);
956  if (h < bitmap->Bitmap[0].BitmapHeight) bitmap->Bitmap[0].BitmapHeight = h;
957  if (w < bitmap->Bitmap[0].BitmapWidth) bitmap->Bitmap[0].BitmapWidth = w;
958 
959  /* Unknown bytes. */
960  readbytes = fread(buffer, 1, 6, file);
961  if (readbytes != 6) return ERR_FILENOTSUPPORTED;
962 
963  GSM_ClearBitmap(&bitmap->Bitmap[0]);
964 
965  x=0; y=0;
966  for (i=0; i<w*h; i++) {
967  if (fread(buffer, 1, 1, file)!=1) return ERR_FILENOTSUPPORTED;
968  if (buffer[0]=='1') GSM_SetPointBitmap(&bitmap->Bitmap[0],x,y);
969  x++;
970  if (x==w) {x=0; y++;}
971  }
972 
973 #ifdef DEBUG
974  /* Some programs writes here fileinfo */
975  if (fread(buffer, 1, 1, file) == 1) {
976  dbgprintf(NULL, "Fileinfo: %c",buffer[0]);
977  while (fread(buffer, 1, 1, file)==1) {
978  if (buffer[0]!=0x0A) dbgprintf(NULL, "%c",buffer[0]);
979  }
980  dbgprintf(NULL, "\n");
981  }
982 #endif
983  bitmap->Number = 1;
984  return(ERR_NONE);
985 }
986 
987 static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap)
988 {
989  unsigned char block[6],buffer[505];
990  size_t block_size;
991  size_t readbytes;
992  GSM_Bitmap_Types OldType;
993 
994  while (fread(block,1,6,file)==6) {
995  block_size = block[4]*256 + block[5];
996  dbgprintf(NULL, "Block %c%c%c%c, size %ld\n",block[0],block[1],block[2],block[3],(long)block_size);
997  if (!strncmp(block, "FORM", 4)) {
998  dbgprintf(NULL, "File ID\n");
999  } else {
1000  if (block_size>504) return ERR_FILENOTSUPPORTED;
1001  if (block_size!=0) {
1002  readbytes = fread(buffer,1,block_size,file);
1003  if (readbytes != block_size) return ERR_FILENOTSUPPORTED;
1004  /* if it's string, we end it with 0 */
1005  buffer[block_size]=0;
1006 #ifdef DEBUG
1007  if (!strncmp(block, "VERS", 4)) dbgprintf(NULL, "File saved by: %s\n",buffer);
1008  if (!strncmp(block, "MODL", 4)) dbgprintf(NULL, "Logo saved from: %s\n",buffer);
1009  if (!strncmp(block, "COMM", 4)) dbgprintf(NULL, "Phone was connected to COM port: %s\n",buffer);
1010 #endif
1011  if (!strncmp(block, "NSLD", 4)) {
1012  bitmap->Bitmap[0].BitmapHeight = 48;
1013  bitmap->Bitmap[0].BitmapWidth = 84;
1014  OldType = bitmap->Bitmap[0].Type;
1015  PHONE_DecodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]);
1016  if (OldType != GSM_None) bitmap->Bitmap[0].Type = OldType;
1017  dbgprintf(NULL, "Startup logo (size %ld)\n",(long)block_size);
1018  }
1019  }
1020  }
1021  }
1022  bitmap->Number = 1;
1023  return(ERR_NONE);
1024 }
1025 
1026 static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
1027 {
1028  unsigned char buffer[10000];
1029  size_t readbytes;
1030 
1031  readbytes = fread(buffer,1,4,file);
1032  if (readbytes != 4) return ERR_FILENOTSUPPORTED;
1033  bitmap->Bitmap[0].BitmapWidth = buffer[2];
1034  bitmap->Bitmap[0].BitmapHeight = buffer[3];
1035  bitmap->Number = 1;
1036 
1037  readbytes = fread(buffer,1,10000,file);
1038  /* FIXME: Decode function should receive how long is the buffer! */
1039  PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]);
1040  GSM_ReverseBitmap(&bitmap->Bitmap[0]);
1041 
1042  return ERR_NONE;
1043 }
1044 
1045 static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
1046 {
1047  GSM_Bitmap *bmap = &bitmap->Bitmap[0];
1048  char *buffer=NULL;
1049  struct stat st;
1050  size_t readbytes=0, length=0;
1051 
1052  dbgprintf(NULL, "loading gif file\n");
1053  fstat(fileno(file), &st);
1054  bmap->BinaryPic.Length = length = st.st_size;
1055  bmap->BinaryPic.Buffer = buffer = (char *)malloc(length);
1056  if (bmap->BinaryPic.Buffer == NULL)
1057  return ERR_MOREMEMORY;
1058 
1059  readbytes = fread(buffer, 1, length, file);
1060  if (readbytes != length) return ERR_FILENOTSUPPORTED;
1061  dbgprintf(NULL, "Length %ld name \"%s\"\n", (long)length,
1062  DecodeUnicodeString(bmap->Name));
1063 
1064  bmap->Type = GSM_PictureBinary;
1065  bmap->BinaryPic.Type = PICTURE_GIF;
1066  bmap->BitmapWidth = 256 * buffer[7] + buffer[6];
1067  bmap->BitmapHeight = 256 * buffer[9] + buffer[8];
1068  bitmap->Number = 1;
1069 
1070  return ERR_NONE;
1071 }
1072 
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 }
1131 
1132 void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, size_t *Length)
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 }
1144 
1145 /* How should editor hadle tabs in this file? Add editor commands here.
1146  * vim: noexpandtab sw=8 ts=8 sts=8:
1147  */
static void PHONE_SetPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int x, int y, int width, int height)
Definition: gsmlogo.c:109
gboolean DefaultRingtone
Definition: gammu-bitmap.h:134
unsigned char ID
Definition: gammu-bitmap.h:168
GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file, GSM_Bitmap *bitmap)
Definition: gsmlogo.c:705
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
size_t PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, size_t Width, size_t Height)
Definition: gsmlogo.c:44
GSM_Bitmap_Types Type
Definition: gammu-bitmap.h:107
static GSM_Error PrivSaveNGGNOL(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:530
unsigned char Sender[2 *(GSM_MAX_NUMBER_LENGTH+1)]
Definition: gammu-bitmap.h:164
static GSM_Error PrivSaveNLMWBMP(FILE *file, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:463
#define GSM_MAX_MULTI_BITMAP
Definition: gammu-limits.h:281
int ClearBit(unsigned char *Buffer, size_t BitNum)
Definition: coding.c:1258
GSM_Error
Definition: gammu-error.h:23
void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:197
gboolean FileSystemPicture
Definition: gammu-bitmap.h:144
GSM_Bitmap_Types
Definition: gammu-bitmap.h:54
GSM_BinaryPicture_Types Type
Definition: gammu-bitmap.h:44
#define GSM_BITMAP_SIZE
Definition: gammu-limits.h:267
unsigned char * Buffer
Definition: gammu-bitmap.h:45
static GSM_Error savengg(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:560
void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:141
unsigned char Location
Definition: gammu-bitmap.h:112
static GSM_Error savenlm(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:493
GSM_Phone_Bitmap_Types
Definition: gsmlogo.h:9
unsigned char BitmapPoints[GSM_BITMAP_SIZE]
Definition: gammu-bitmap.h:148
#define chk_fwrite(data, size, count, file)
Definition: gsmlogo.c:20
static GSM_Error savenol(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:581
void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, size_t *Length)
Definition: gsmlogo.c:1132
char NetworkCode[10]
Definition: gammu-bitmap.h:160
void GSM_ResizeBitmap(GSM_Bitmap *dest, GSM_Bitmap *src, size_t width, size_t height)
Definition: gsmlogo.c:288
unsigned char RingtoneID
Definition: gammu-bitmap.h:138
static GSM_Error savexpm(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:613
int gboolean
Definition: gammu-types.h:23
void GSM_PrintBitmap(FILE *file, GSM_Bitmap *bitmap)
Definition: gsmlogo.c:257
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
gboolean GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:238
static GSM_Error savebmp(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:455
static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:987
gboolean BitmapEnabled
Definition: gammu-bitmap.h:122
static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:660
GSM_Bitmap Bitmap[GSM_MAX_MULTI_BITMAP]
Definition: gammu-bitmap.h:192
gboolean DefaultBitmap
Definition: gammu-bitmap.h:130
GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:676
unsigned char Name[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:176
int SetBit(unsigned char *Buffer, size_t BitNum)
Definition: coding.c:1253
GSM_BinaryPicture BinaryPic
Definition: gammu-bitmap.h:172
#define dbgprintf
Definition: debug.h:72
unsigned char Number
Definition: gammu-bitmap.h:188
void GSM_ClearBitmap(GSM_Bitmap *bmp)
Definition: gsmlogo.c:247
static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:1045
gboolean DefaultName
Definition: gammu-bitmap.h:126
void GSM_ReverseBitmap(GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:273
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 GSM_GetBitmapSize(GSM_Bitmap *bmp)
Definition: gsmlogo.c:252
static gboolean PHONE_IsPointBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int x, int y, int width, int height)
Definition: gsmlogo.c:77
void GSM_ClearPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:233
size_t BitmapWidth
Definition: gammu-bitmap.h:156
unsigned char Text[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:118
static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:644
void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y)
Definition: gsmlogo.c:228
void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, size_t width, size_t height)
Definition: gsmlogo.c:192
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
GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:1073
int GetBit(unsigned char *Buffer, size_t BitNum)
Definition: coding.c:1248
void GSM_GetMaxBitmapWidthHeight(GSM_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:217
static GSM_Error loadnlm(FILE *file, GSM_MultiBitmap *bitmap)
Definition: gsmlogo.c:862
GSM_Error Bitmap2BMP(unsigned char *buffer, FILE *file, GSM_Bitmap *bitmap)
Definition: gsmlogo.c:321