#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include "gwlib/gwlib.h"#include "OTAbitmap.h"Include dependency graph for OTAbitmap.c:

Go to the source code of this file.
Functions | |
| OTAbitmap * | OTAbitmap_create_empty (void) |
| void | OTAbitmap_delete (OTAbitmap *pic) |
| OTAbitmap * | OTAbitmap_create (int width, int height, int depth, Octet *data, int flags) |
| int | OTAbitmap_create_stream (OTAbitmap *pic, Octet **stream) |
|
||||||||||||||||||||||||
|
Definition at line 91 of file OTAbitmap.c. References data, OTA_bitmap::height, OTA_bitmap::infofield, OTA_bitmap::main_image, Octet, OTAbitmap, OTAbitmap_create_empty(), reverse_octet(), and OTA_bitmap::width. 00093 {
00094 OTAbitmap *new;
00095 int i, j, siz, osiz;
00096 Octet val;
00097
00098 new = OTAbitmap_create_empty();
00099
00100 if (width > 255 || height > 255)
00101 new->infofield = 0x10; /* set bit */
00102 else
00103 new->infofield = 0x00;
00104
00105 new->width = width;
00106 new->height = height;
00107
00108 siz = (width * height + 7)/8;
00109
00110 new->main_image = gw_malloc(siz);
00111 osiz = (width+7)/8 * height;
00112 for(i=j=0; i<osiz; i++, j+=8) {
00113 val = data[i];
00114 if (flags & REVERSE) val = reverse_octet(val);
00115 if (flags & NEGATIVE) val = ~val;
00116
00117 if (i > 0 && i % ((width+7)/8) == 0 && width % 8 > 0)
00118 j -= 8 + width % 8;
00119
00120 if (j % 8 == 0) {
00121 new->main_image[j/8] = val;
00122 }
00123 else {
00124 new->main_image[j/8] |= val >> (j % 8);
00125 new->main_image[j/8 + 1] = val << (8 - j % 8);
00126 }
00127 }
00128 /* no palette nor animated images, yet */
00129
00130 return new;
00131 }
|
Here is the call graph for this function:

|
|
Definition at line 69 of file OTAbitmap.c. References OTAbitmap. Referenced by OTAbitmap_create(). 00070 {
00071 OTAbitmap *new;
00072
00073 new = gw_malloc(sizeof(OTAbitmap));
00074 memset(new, 0, sizeof(OTAbitmap));
00075 return new;
00076 }
|
|
||||||||||||
|
Definition at line 137 of file OTAbitmap.c. References debug(), OTA_bitmap::depth, OTA_bitmap::height, OTA_bitmap::infofield, OTA_bitmap::main_image, Octet, OTAbitmap, and OTA_bitmap::width. 00138 {
00139 Octet tmp_header[10];
00140 int hdr_len;
00141 int pic_size;
00142
00143 if (pic->infofield & 0x10) {
00144 sprintf(tmp_header, "%c%c%c%c%c%c", pic->infofield, pic->width/256,
00145 pic->width%256, pic->height/256, pic->height%256, pic->depth);
00146 hdr_len = 6;
00147 } else {
00148 sprintf(tmp_header, "%c%c%c%c", pic->infofield,
00149 pic->width, pic->height, pic->depth);
00150 hdr_len = 4;
00151 }
00152
00153 pic_size = (pic->width * pic->height + 7)/8;
00154
00155 *stream = gw_malloc(pic_size+pic_size);
00156 memcpy(*stream, tmp_header, hdr_len);
00157 memcpy(*stream + hdr_len, pic->main_image, pic_size);
00158
00159 debug("util", 0, "picture %d x %d, stream length %d",
00160 pic->width, pic->height, hdr_len + pic_size);
00161
00162 return (hdr_len + pic_size);
00163 }
|
Here is the call graph for this function:

|
|
Definition at line 78 of file OTAbitmap.c. References OTA_bitmap::animated_image, OTA_bitmap::animimg_count, OTA_bitmap::ext_fields, OTA_bitmap::main_image, and OTAbitmap. 00079 {
00080 gw_free(pic->ext_fields);
00081 gw_free(pic->main_image);
00082 if (pic->animated_image) {
00083 int i;
00084 for(i=0; i < pic->animimg_count; i++)
00085 gw_free(pic->animated_image[i]);
00086 gw_free(pic->animated_image);
00087 }
00088 gw_free(pic);
00089 }
|