83 private->klass = &klass;
96 BITMAPINFOHEADER bmiHeader;
100 RGBQUAD bmiColors[256];
123 width, height, depth));
136 bmi.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
137 bmi.bmiHeader.biWidth = width;
138 bmi.bmiHeader.biHeight = -height;
139 bmi.bmiHeader.biPlanes = 1;
141 bmi.bmiHeader.biBitCount = 16;
143 bmi.bmiHeader.biBitCount = depth;
146 bmi.bmiHeader.biCompression = BI_BITFIELDS;
149 bmi.bmiHeader.biCompression = BI_RGB;
150 bmi.bmiHeader.biSizeImage = 0;
151 bmi.bmiHeader.biXPelsPerMeter = bmi.bmiHeader.biYPelsPerMeter = 0;
152 bmi.bmiHeader.biClrUsed = 0;
153 bmi.bmiHeader.biClrImportant = 0;
155 iUsage = DIB_RGB_COLORS;
157 bmi.u.bmiColors[0].rgbBlue =
158 bmi.u.bmiColors[0].rgbGreen = bmi.u.bmiColors[0].rgbRed = 0x00;
159 bmi.u.bmiColors[0].rgbReserved = 0x00;
161 bmi.u.bmiColors[1].rgbBlue =
162 bmi.u.bmiColors[1].rgbGreen = bmi.u.bmiColors[1].rgbRed = 0xFF;
163 bmi.u.bmiColors[1].rgbReserved = 0x00;
164 private->colormap =
NULL;
167 if (private->colormap ==
NULL)
171 iUsage = DIB_PAL_COLORS;
172 for (i = 0; i < 256; i++)
173 bmi.u.bmiIndices[i] = i;
175 if (depth != visual->
depth)
177 (
"gdk_pixmap_new: depth %d doesn't match display depth %d",
178 depth, visual->
depth);
181 bmi.u.bmiMasks[0] = visual->
red_mask;
189 CreateDIBSection(hdc, (BITMAPINFO *) & bmi,
200 private->width = width;
201 private->height = height;
238 private->width = width;
239 private->height = height;
244 g_print(
"gdk_pixmap_create_on_shared_image: %dx%dx%d = %#x\n",
251 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
252 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
253 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
254 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
255 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
256 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
257 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
258 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
259 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
260 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
261 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
262 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
263 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
264 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
265 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
266 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
267 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
268 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
269 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
270 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
271 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
272 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
273 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
274 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
275 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
276 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
277 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
278 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
279 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
280 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
281 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
282 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
291 gint i, j, bpl, aligned_bpl;
307 private->width = width;
308 private->height = height;
310 bpl = ((width - 1) / 8 + 1);
311 aligned_bpl = ((bpl - 1) / 2 + 1) * 2;
312 bits =
g_malloc(aligned_bpl * height);
313 for (i = 0; i < height; i++)
314 for (j = 0; j < bpl; j++)
315 bits[i * aligned_bpl + j] = mirror[(
guchar) data[i * bpl + j]];
325 private->colormap =
NULL;
355 GDK_NOTE(MISC,
g_print(
"gdk_pixmap_create_from_data: %dx%dx%d = %#x\n",
366 while (!feof(infile)) {
367 fscanf(infile,
"%1023s", instr);
368 if (skip_comments ==
TRUE && strcmp(instr,
"/*") == 0) {
369 fscanf(infile,
"%1023s", instr);
370 while (!feof(infile) && strcmp(instr,
"*/") != 0)
371 fscanf(infile,
"%1023s", instr);
372 fscanf(infile,
"%1023s", instr);
374 if (strcmp(instr, str) == 0)
385 while ((b = getc(infile)) != EOF) {
386 if (c != b && b ==
'/') {
398 while (!(oldb ==
'*' && b ==
'/'));
414 bufsiz = *buffer_size;
416 bufsiz = 10 *
sizeof(
gchar);
422 while (c != EOF && c !=
'"');
427 while ((c = getc(infile)) != EOF) {
429 guint new_size = bufsiz * 2;
430 if (new_size > bufsiz)
436 buf[bufsiz - 1] =
'\0';
449 buf[bufsiz - 1] =
'\0';
451 *buffer_size = bufsiz;
459 while (buffer[index] != 0
460 && (buffer[index] == 0x20 || buffer[index] == 0x09))
463 return &buffer[index];
470 while (buffer[index] != 0 && buffer[index] != 0x20
471 && buffer[index] != 0x09)
474 return &buffer[index];
477 #define MAX_COLOR_LEN 120
481 gint counter, numnames;
487 while (ptr ==
NULL) {
488 if (buffer[counter] ==
'c') {
489 ch = buffer[counter + 1];
490 if (ch == 0x20 || ch == 0x09)
491 ptr = &buffer[counter + 1];
492 }
else if (buffer[counter] == 0)
502 else if (ptr[0] ==
'#') {
504 while (ptr[counter] != 0 &&
505 ((ptr[counter] >=
'0' && ptr[counter] <=
'9') ||
506 (ptr[counter] >=
'a' && ptr[counter] <=
'f') ||
507 (ptr[counter] >=
'A' && ptr[counter] <=
'F')))
511 strncpy(retcol, ptr, counter);
523 sscanf(ptr,
"%127s", temp);
525 if (((
gint) ptr[0] == 0) ||
526 (strcmp(
"s", temp) == 0) || (strcmp(
"m", temp) == 0) ||
527 (strcmp(
"g", temp) == 0) || (strcmp(
"g4", temp) == 0)) {
534 strncat(color, temp, space);
535 space -=
MIN(space, (
gint)strlen(temp));
556 _GdkPixmapInfo *info = (_GdkPixmapInfo *) data;
560 for (i = 0; i < info->ncolors; i++) {
561 color.
pixel = info->pixels[i];
584 gint width, height, num_cols, cpp,
n, ns,
cnt, xcnt, ycnt, wbytes;
585 gchar *buffer, pixel_str[32];
587 _GdkPixmapColor *color =
NULL, *fallbackcolor =
NULL;
591 _GdkPixmapInfo *color_info =
NULL;
593 if ((window ==
NULL) && (colormap ==
NULL))
594 g_warning(
"Creating pixmap from xpm with NULL window and colormap");
599 if (colormap ==
NULL) {
609 sscanf(buffer,
"%d %d %d %d", &width, &height, &num_cols, &cpp);
611 g_warning(
"Pixmap has more than 31 characters per color");
617 if (transparent_color ==
NULL) {
619 transparent_color = &tmp_color;
627 color_info =
g_malloc(
sizeof(_GdkPixmapInfo) +
628 sizeof(
gulong) * (num_cols - 1));
629 color_info->ncolors = num_cols;
630 color_info->colormap = colormap;
634 name_buf =
g_new(
gchar, num_cols * (cpp + 1));
635 colors =
g_new(_GdkPixmapColor, num_cols);
637 for (cnt = 0; cnt < num_cols; cnt++) {
640 buffer = (*get_buf) (
op_cmap, handle);
644 color = &colors[
cnt];
645 color->color_string = &name_buf[cnt * (cpp + 1)];
646 strncpy(color->color_string, buffer, cpp);
647 color->color_string[cpp] = 0;
648 buffer += strlen(color->color_string);
649 color->transparent =
FALSE;
653 if (color_name ==
NULL ||
655 color->color = *transparent_color;
656 color->transparent =
TRUE;
666 color_info->pixels[
cnt] = color->color.pixel;
670 fallbackcolor = color;
686 mask_pattern.
pixel = 0;
690 mask_pattern.
pixel = 1;
694 wbytes = width * cpp;
695 for (ycnt = 0; ycnt < height; ycnt++) {
696 buffer = (*get_buf) (
op_body, handle);
702 if ((buffer ==
NULL) || (
gint)strlen(buffer) < wbytes)
705 for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++) {
706 strncpy(pixel_str, &buffer[n], cpp);
713 color = fallbackcolor;
717 if (mask && color->transparent) {
724 if (mask && (cnt < xcnt))
746 }
else if (color_info)
749 if (color_hash !=
NULL)
755 if (name_buf !=
NULL)
771 struct file_handle *
h = handle;
784 fseek(h->infile, -1, SEEK_CUR);
801 struct file_handle h;
804 memset(&h, 0,
sizeof(h));
805 h.infile = fopen(filename,
"rb");
806 if (h.infile !=
NULL) {
823 transparent_color, filename);
834 struct mem_handle *
h = handle;
839 if (h->data[h->offset])
840 return h->data[h->offset++];
855 memset(&h, 0,
sizeof(h));
868 transparent_color, data);
877 unsigned int w_ret, h_ret;
884 xpixmap = (HBITMAP) anid;
888 GetBitmapDimensionEx(xpixmap, &size);
897 private->colormap =
NULL;
898 private->width = w_ret;
899 private->height = h_ret;
#define GDK_DRAWABLE_DESTROYED(d)
gint gdk_color_parse(const gchar *spec, GdkColor *color)
GdkPixmap * gdk_pixmap_create_from_xpm(GdkWindow *window, GdkBitmap **mask, GdkColor *transparent_color, const gchar *filename)
void gdk_gc_unref(GdkGC *gc)
virtual Pixmap_t CreateBitmap(Drawable_t id, const char *bitmap, UInt_t width, UInt_t height)
GHashTable * g_hash_table_new(GHashFunc hash_func, GEqualFunc key_equal_func)
g_hash_table_new: : a function to create a hash value from a key.
GdkColormap * gdk_drawable_get_colormap(GdkDrawable *drawable)
GdkWindow * gdk_parent_root
#define g_return_val_if_fail(expr, val)
GdkPixmap * gdk_pixmap_new(GdkWindow *window, gint width, gint height, gint depth)
void g_hash_table_destroy(GHashTable *hash_table)
g_hash_table_destroy: : a GHashTable.
#define GDK_NOTE(type, action)
GdkDrawable * gdk_drawable_alloc(void)
static const char * filename()
gpointer g_malloc(gulong n_bytes)
gboolean gdk_color_white(GdkColormap *colormap, GdkColor *color)
void g_hash_table_insert(GHashTable *hash_table, gpointer key, gpointer value)
g_hash_table_insert: : a GHashTable.
GdkPixmap * gdk_pixmap_create_on_shared_image(GdkImage **image_return, GdkWindow *window, GdkVisual *visual, gint width, gint height, gint depth)
static gchar * gdk_pixmap_skip_string(gchar *buffer)
G_BEGIN_DECLS typedef char gchar
GdkPixmap * gdk_pixmap_colormap_create_from_xpm_d(GdkWindow *window, GdkColormap *colormap, GdkBitmap **mask, GdkColor *transparent_color, gchar **data)
static gchar * gdk_pixmap_skip_whitespaces(gchar *buffer)
GdkPixmap * gdk_pixmap_create_from_xpm_d(GdkWindow *window, GdkBitmap **mask, GdkColor *transparent_color, gchar **data)
GdkPixmap * gdk_pixmap_colormap_create_from_xpm(GdkWindow *window, GdkColormap *colormap, GdkBitmap **mask, GdkColor *transparent_color, const gchar *filename)
guint g_str_hash(gconstpointer v)
static void gdk_win32_pixmap_destroy(GdkPixmap *pixmap)
void gdk_draw_line(GdkDrawable *drawable, GdkGC *gc, gint x1, gint y1, gint x2, gint y2)
static unsigned char mirror[256]
void gdk_xid_table_remove(HANDLE xid)
gboolean g_str_equal(gconstpointer v, gconstpointer v2)
void gdk_colormap_free_colors(GdkColormap *colormap, GdkColor *colors, gint ncolors)
GdkPixmap * gdk_pixmap_create_from_data(GdkWindow *window, const gchar *data, gint width, gint height, gint depth, GdkColor *fg, GdkColor *bg)
void gdk_xid_table_insert(HANDLE *hnd, gpointer data)
GdkGC * gdk_gc_new(GdkDrawable *drawable)
#define g_new(struct_type, n_structs)
GdkDrawableClass _gdk_win32_drawable_class
static GdkPixmap * _gdk_pixmap_create_from_xpm(GdkWindow *window, GdkColormap *colormap, GdkBitmap **mask, GdkColor *transparent_color, gchar *(*get_buf)(enum buffer_opop, gpointer handle), gpointer handle)
GdkPixmap * gdk_pixmap_foreign_new(guint32 anid)
typedefG_BEGIN_DECLS struct _GHashTable GHashTable
GdkColormap * gdk_colormap_ref(GdkColormap *cmap)
static gint gdk_pixmap_read_string(FILE *infile, gchar **buffer, guint *buffer_size)
void gdk_image_put_pixel(GdkImage *image, gint x, gint y, guint32 pixel)
static gchar * gdk_pixmap_extract_color(gchar *buffer)
void gdk_gc_set_background(GdkGC *gc, GdkColor *color)
GdkColormap * gdk_colormap_get_system(void)
#define WIN32_GDI_FAILED(api)
void gdk_drawable_set_data(GdkDrawable *drawable, const gchar *key, gpointer data, GDestroyNotify destroy_func)
void g_free(gpointer mem)
gboolean gdk_color_alloc(GdkColormap *colormap, GdkColor *color)
GdkPixmap * gdk_bitmap_create_from_data(GdkWindow *window, const gchar *data, gint width, gint height)
GdkImage * gdk_image_bitmap_new(GdkImageType type, GdkVisual *visual, gint width, gint height)
void gdk_draw_image(GdkDrawable *drawable, GdkGC *gc, GdkImage *image, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height)
static gint gdk_pixmap_seek_string(FILE *infile, const gchar *str, gint skip_comments)
static gchar * file_buffer(enum buffer_op op, gpointer handle)
void gdk_image_unref(GdkImage *image)
gpointer g_realloc(gpointer mem, gulong n_bytes)
void(* destroy)(GdkDrawable *drawable)
static gchar * mem_buffer(enum buffer_op op, gpointer handle)
static void g_warning(const gchar *format,...)
void gdk_gc_set_foreground(GdkGC *gc, GdkColor *color)
static gint gdk_pixmap_seek_char(FILE *infile, gchar c)
void gdk_colormap_unref(GdkColormap *cmap)
void gdk_drawable_unref(GdkDrawable *drawable)
gpointer g_hash_table_lookup(GHashTable *hash_table, gconstpointer key)
g_hash_table_lookup: : a GHashTable.
#define GDK_DRAWABLE_XID(win)
void g_print(const gchar *format,...)
void gdk_draw_drawable(GdkDrawable *drawable, GdkGC *gc, GdkDrawable *src, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height)
gchar * g_strdup(const gchar *str)
void gdk_draw_rectangle(GdkDrawable *drawable, GdkGC *gc, gint filled, gint x, gint y, gint width, gint height)
#define GDK_DRAWABLE_WIN32DATA(win)
static void gdk_xpm_destroy_notify(gpointer data)
static GdkDrawable * gdk_win32_pixmap_alloc(void)
GdkImage * gdk_image_new(GdkImageType type, GdkVisual *visual, gint width, gint height)
const char Int_t const char * image
GdkVisual * gdk_drawable_get_visual(GdkDrawable *drawable)