Mercurial > hg > xemacs-beta
comparison src/glyphs-msw.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | b2472a1930f2 |
children | 6330739388db |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
77 int bpline=(int)(~3UL & (unsigned long)((width*3) +3)); | 77 int bpline=(int)(~3UL & (unsigned long)((width*3) +3)); |
78 /* FIXME: we can do this because 24bpp implies no colour table, once | 78 /* FIXME: we can do this because 24bpp implies no colour table, once |
79 * we start paletizing this is no longer true. The X versions of | 79 * we start paletizing this is no longer true. The X versions of |
80 * this function quantises to 256 colours or bit masks down to a | 80 * this function quantises to 256 colours or bit masks down to a |
81 * long. Windows can actually handle rgb triples in the raw so I | 81 * long. Windows can actually handle rgb triples in the raw so I |
82 * don't see much point trying to optimise down to the best | 82 * don't see much point trying to optimize down to the best |
83 * structure - unless it has memory / color allocation implications | 83 * structure - unless it has memory / color allocation implications |
84 * .... */ | 84 * .... */ |
85 bmp_info=xnew_and_zero (BITMAPINFO); | 85 bmp_info=xnew_and_zero (BITMAPINFO); |
86 | 86 |
87 if (!bmp_info) | 87 if (!bmp_info) |
93 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */ | 93 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */ |
94 bmp_info->bmiHeader.biSizeImage=width*height*3; | 94 bmp_info->bmiHeader.biSizeImage=width*height*3; |
95 | 95 |
96 /* bitmap data needs to be in blue, green, red triples - in that | 96 /* bitmap data needs to be in blue, green, red triples - in that |
97 order, eimage is in RGB format so we need to convert */ | 97 order, eimage is in RGB format so we need to convert */ |
98 *bmp_data = xnew_array_and_zero (unsigned char, width * height * 3); | 98 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height); |
99 *bit_count = width * height * 3; | 99 *bit_count = width * height * 3; |
100 | 100 |
101 if (!bmp_data) | 101 if (!bmp_data) |
102 { | 102 { |
103 xfree(bmp_info); | 103 xfree (bmp_info); |
104 return NULL; | 104 return NULL; |
105 } | 105 } |
106 for (i=0; i<width*height; i++) | 106 |
107 { | 107 ip = pic; |
108 (*bmp_data)[2]=*pic; | 108 for (i = height-1; i >= 0; i--) { |
109 (*bmp_data)[1]= pic[1]; | 109 dp = (*bmp_data) + (i * bpline); |
110 **bmp_data = pic[2]; | 110 for (j = 0; j < width; j++) { |
111 (*bmp_data) += 3; | 111 dp[2] =*ip++; |
112 } | 112 dp[1] =*ip++; |
113 *dp =*ip++; | |
114 dp += 3; | |
115 } | |
116 } | |
113 } | 117 } |
114 else /* scale to 256 colors */ | 118 else /* scale to 256 colors */ |
115 { | 119 { |
116 int rd,gr,bl, j; | 120 int rd,gr,bl; |
117 unsigned char *ip, *dp; | |
118 quant_table *qtable; | 121 quant_table *qtable; |
119 int bpline= (int)(~3UL & (unsigned long)(width +3)); | 122 int bpline= (int)(~3UL & (unsigned long)(width +3)); |
120 /* Quantize the image and get a histogram while we're at it. | 123 /* Quantize the image and get a histogram while we're at it. |
121 Do this first to save memory */ | 124 Do this first to save memory */ |
122 qtable = build_EImage_quantable(pic, width, height, 256); | 125 qtable = build_EImage_quantable(pic, width, height, 256); |
123 if (qtable == NULL) return NULL; | 126 if (qtable == NULL) return NULL; |
124 | 127 |
125 /* use our quantize table to allocate the colors */ | 128 /* use our quantize table to allocate the colors */ |
126 ncolors = qtable->num_active_colors; | 129 ncolors = qtable->num_active_colors; |
127 bmp_info=(BITMAPINFO*)xmalloc_and_zero(sizeof(BITMAPINFOHEADER) + | 130 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + |
128 sizeof(RGBQUAD) * ncolors); | 131 sizeof(RGBQUAD) * ncolors); |
129 if (!bmp_info) | 132 if (!bmp_info) |
130 { | 133 { |
131 xfree(qtable); | 134 xfree (qtable); |
132 return NULL; | 135 return NULL; |
133 } | 136 } |
134 | 137 |
135 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER)); | 138 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER)); |
136 | 139 |
355 | 358 |
356 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = | 359 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = |
357 find_keyword_in_vector (instantiator, Q_file); | 360 find_keyword_in_vector (instantiator, Q_file); |
358 | 361 |
359 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; | 362 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; |
363 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = bitmap; | |
360 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; | 364 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; |
361 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; | 365 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; |
362 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; | 366 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; |
363 } | 367 } |
364 | 368 |
378 unsigned char* dptr; | 382 unsigned char* dptr; |
379 unsigned int* sptr; | 383 unsigned int* sptr; |
380 COLORREF color; /* the american spelling virus hits again .. */ | 384 COLORREF color; /* the american spelling virus hits again .. */ |
381 COLORREF* colortbl; | 385 COLORREF* colortbl; |
382 | 386 |
383 memset (&xpmimage, 0, sizeof (xpmimage)); | 387 xzero (xpmimage); |
384 memset (&xpminfo, 0, sizeof (xpmimage)); | 388 xzero (xpminfo); |
385 | 389 |
386 result = XpmCreateXpmImageFromBuffer ((char*)buffer, | 390 result = XpmCreateXpmImageFromBuffer ((char*)buffer, |
387 &xpmimage, | 391 &xpmimage, |
388 &xpminfo); | 392 &xpminfo); |
389 switch (result) | 393 switch (result) |
619 if (DEVICE_LIVE_P (XDEVICE (p->device))) | 623 if (DEVICE_LIVE_P (XDEVICE (p->device))) |
620 { | 624 { |
621 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)) | 625 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)) |
622 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); | 626 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); |
623 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0; | 627 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0; |
628 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) | |
629 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p)); | |
630 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0; | |
631 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p)) | |
632 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p)); | |
633 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0; | |
624 } | 634 } |
625 | 635 |
626 xfree (p->data); | 636 xfree (p->data); |
627 p->data = 0; | 637 p->data = 0; |
628 } | 638 } |