]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: bitmap.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // RCS-ID: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "bitmap.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/bitmap.h" | |
15 | #include "wx/icon.h" | |
16 | #include "wx/filefn.h" | |
17 | #include "gdk/gdkprivate.h" | |
18 | #include "gdk/gdkx.h" | |
19 | ||
20 | //----------------------------------------------------------------------------- | |
21 | // wxMask | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
24 | IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject) | |
25 | ||
26 | wxMask::wxMask(void) | |
27 | { | |
28 | m_bitmap = (GdkBitmap *) NULL; | |
29 | } | |
30 | ||
31 | wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(colour) ) | |
32 | { | |
33 | } | |
34 | ||
35 | wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap), int WXUNUSED(paletteIndex) ) | |
36 | { | |
37 | } | |
38 | ||
39 | wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap) ) | |
40 | { | |
41 | } | |
42 | ||
43 | wxMask::~wxMask(void) | |
44 | { | |
45 | if (m_bitmap) gdk_bitmap_unref( m_bitmap ); | |
46 | } | |
47 | ||
48 | GdkBitmap *wxMask::GetBitmap(void) const | |
49 | { | |
50 | return m_bitmap; | |
51 | } | |
52 | ||
53 | //----------------------------------------------------------------------------- | |
54 | // wxBitmap | |
55 | //----------------------------------------------------------------------------- | |
56 | ||
57 | class wxBitmapRefData: public wxObjectRefData | |
58 | { | |
59 | public: | |
60 | wxBitmapRefData(void); | |
61 | ~wxBitmapRefData(void); | |
62 | ||
63 | GdkPixmap *m_pixmap; | |
64 | GdkBitmap *m_bitmap; | |
65 | wxMask *m_mask; | |
66 | int m_width; | |
67 | int m_height; | |
68 | int m_bpp; | |
69 | wxPalette *m_palette; | |
70 | }; | |
71 | ||
72 | wxBitmapRefData::wxBitmapRefData(void) | |
73 | { | |
74 | m_pixmap = (GdkPixmap *) NULL; | |
75 | m_bitmap = (GdkBitmap *) NULL; | |
76 | m_mask = (wxMask *) NULL; | |
77 | m_width = 0; | |
78 | m_height = 0; | |
79 | m_bpp = 0; | |
80 | m_palette = (wxPalette *) NULL; | |
81 | } | |
82 | ||
83 | wxBitmapRefData::~wxBitmapRefData(void) | |
84 | { | |
85 | if (m_pixmap) gdk_pixmap_unref( m_pixmap ); | |
86 | if (m_bitmap) gdk_bitmap_unref( m_bitmap ); | |
87 | if (m_mask) delete m_mask; | |
88 | if (m_palette) delete m_palette; | |
89 | } | |
90 | ||
91 | //----------------------------------------------------------------------------- | |
92 | ||
93 | #define M_BMPDATA ((wxBitmapRefData *)m_refData) | |
94 | ||
95 | IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject) | |
96 | ||
97 | wxBitmap::wxBitmap(void) | |
98 | { | |
99 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
100 | } | |
101 | ||
102 | wxBitmap::wxBitmap( int width, int height, int depth ) | |
103 | { | |
104 | wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" ) | |
105 | wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" ) | |
106 | ||
107 | m_refData = new wxBitmapRefData(); | |
108 | ||
109 | GdkWindow *parent = (GdkWindow*) &gdk_root_parent; | |
110 | ||
111 | M_BMPDATA->m_mask = (wxMask *) NULL; | |
112 | M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth ); | |
113 | M_BMPDATA->m_width = width; | |
114 | M_BMPDATA->m_height = height; | |
115 | M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; | |
116 | ||
117 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
118 | } | |
119 | ||
120 | wxBitmap::wxBitmap( char **bits ) | |
121 | { | |
122 | wxCHECK_RET( bits != NULL, "invalid bitmap data" ) | |
123 | ||
124 | m_refData = new wxBitmapRefData(); | |
125 | ||
126 | GdkBitmap *mask = (GdkBitmap*) NULL; | |
127 | GdkWindow *parent = (GdkWindow*) &gdk_root_parent; | |
128 | ||
129 | M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); | |
130 | ||
131 | if (mask) | |
132 | { | |
133 | M_BMPDATA->m_mask = new wxMask(); | |
134 | M_BMPDATA->m_mask->m_bitmap = mask; | |
135 | } | |
136 | ||
137 | gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); | |
138 | ||
139 | M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? | |
140 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
141 | } | |
142 | ||
143 | wxBitmap::wxBitmap( const wxBitmap& bmp ) | |
144 | { | |
145 | Ref( bmp ); | |
146 | ||
147 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
148 | } | |
149 | ||
150 | wxBitmap::wxBitmap( const wxBitmap* bmp ) | |
151 | { | |
152 | if (bmp) Ref( *bmp ); | |
153 | ||
154 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
155 | } | |
156 | ||
157 | wxBitmap::wxBitmap( const wxString &filename, int type ) | |
158 | { | |
159 | LoadFile( filename, type ); | |
160 | ||
161 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
162 | } | |
163 | ||
164 | wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth)) | |
165 | { | |
166 | m_refData = new wxBitmapRefData(); | |
167 | ||
168 | M_BMPDATA->m_mask = (wxMask *) NULL; | |
169 | M_BMPDATA->m_bitmap = | |
170 | gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height ); | |
171 | M_BMPDATA->m_width = width; | |
172 | M_BMPDATA->m_height = height; | |
173 | M_BMPDATA->m_bpp = 1; | |
174 | ||
175 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
176 | } | |
177 | ||
178 | wxBitmap::~wxBitmap(void) | |
179 | { | |
180 | if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this); | |
181 | } | |
182 | ||
183 | wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp ) | |
184 | { | |
185 | if (*this == bmp) return (*this); | |
186 | Ref( bmp ); | |
187 | return *this; | |
188 | } | |
189 | ||
190 | bool wxBitmap::operator == ( const wxBitmap& bmp ) | |
191 | { | |
192 | return m_refData == bmp.m_refData; | |
193 | } | |
194 | ||
195 | bool wxBitmap::operator != ( const wxBitmap& bmp ) | |
196 | { | |
197 | return m_refData != bmp.m_refData; | |
198 | } | |
199 | ||
200 | bool wxBitmap::Ok(void) const | |
201 | { | |
202 | return (m_refData != NULL); | |
203 | } | |
204 | ||
205 | int wxBitmap::GetHeight(void) const | |
206 | { | |
207 | if (!Ok()) | |
208 | { | |
209 | wxFAIL_MSG( "invalid bitmap" ); | |
210 | return -1; | |
211 | } | |
212 | ||
213 | return M_BMPDATA->m_height; | |
214 | } | |
215 | ||
216 | int wxBitmap::GetWidth(void) const | |
217 | { | |
218 | if (!Ok()) | |
219 | { | |
220 | wxFAIL_MSG( "invalid bitmap" ); | |
221 | return -1; | |
222 | } | |
223 | ||
224 | return M_BMPDATA->m_width; | |
225 | } | |
226 | ||
227 | int wxBitmap::GetDepth(void) const | |
228 | { | |
229 | if (!Ok()) | |
230 | { | |
231 | wxFAIL_MSG( "invalid bitmap" ); | |
232 | return -1; | |
233 | } | |
234 | ||
235 | return M_BMPDATA->m_bpp; | |
236 | } | |
237 | ||
238 | void wxBitmap::SetHeight( int height ) | |
239 | { | |
240 | if (!Ok()) return; | |
241 | ||
242 | wxFAIL_MSG( "wxBitmap::SetHeight not implemented" ); | |
243 | ||
244 | M_BMPDATA->m_height = height; | |
245 | } | |
246 | ||
247 | void wxBitmap::SetWidth( int width ) | |
248 | { | |
249 | if (!Ok()) return; | |
250 | ||
251 | wxFAIL_MSG( "wxBitmap::SetWidth not implemented" ); | |
252 | ||
253 | M_BMPDATA->m_width = width; | |
254 | } | |
255 | ||
256 | void wxBitmap::SetDepth( int depth ) | |
257 | { | |
258 | if (!Ok()) return; | |
259 | ||
260 | wxFAIL_MSG( "wxBitmap::SetDepth not implemented" ); | |
261 | ||
262 | M_BMPDATA->m_bpp = depth; | |
263 | } | |
264 | ||
265 | wxMask *wxBitmap::GetMask(void) const | |
266 | { | |
267 | if (!Ok()) | |
268 | { | |
269 | wxFAIL_MSG( "invalid bitmap" ); | |
270 | return (wxMask *) NULL; | |
271 | } | |
272 | ||
273 | return M_BMPDATA->m_mask; | |
274 | } | |
275 | ||
276 | void wxBitmap::SetMask( wxMask *mask ) | |
277 | { | |
278 | if (!Ok()) | |
279 | { | |
280 | wxFAIL_MSG( "invalid bitmap" ); | |
281 | return; | |
282 | } | |
283 | ||
284 | if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask; | |
285 | ||
286 | M_BMPDATA->m_mask = mask; | |
287 | } | |
288 | ||
289 | bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) ) | |
290 | { | |
291 | if (!Ok()) | |
292 | { | |
293 | wxFAIL_MSG( "invalid bitmap" ); | |
294 | return FALSE; | |
295 | } | |
296 | ||
297 | if (type == wxBITMAP_TYPE_PNG) | |
298 | { | |
299 | wxImage image = ConvertToImage(); | |
300 | if (image.Ok()) return image.SaveFile( name, type ); | |
301 | } | |
302 | ||
303 | return FALSE; | |
304 | } | |
305 | ||
306 | bool wxBitmap::LoadFile( const wxString &name, int type ) | |
307 | { | |
308 | UnRef(); | |
309 | ||
310 | if (!wxFileExists(name)) return FALSE; | |
311 | ||
312 | if (type == wxBITMAP_TYPE_XPM) | |
313 | { | |
314 | m_refData = new wxBitmapRefData(); | |
315 | ||
316 | GdkBitmap *mask = (GdkBitmap*) NULL; | |
317 | GdkWindow *parent = (GdkWindow*) &gdk_root_parent; | |
318 | ||
319 | M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( parent, &mask, NULL, name ); | |
320 | ||
321 | if (mask) | |
322 | { | |
323 | M_BMPDATA->m_mask = new wxMask(); | |
324 | M_BMPDATA->m_mask->m_bitmap = mask; | |
325 | } | |
326 | ||
327 | gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); | |
328 | M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; | |
329 | } | |
330 | else if (type == wxBITMAP_TYPE_PNG) | |
331 | { | |
332 | wxImage image; | |
333 | image.LoadFile( name, type ); | |
334 | if (image.Ok()) *this = wxBitmap( image ); | |
335 | } | |
336 | else if (type == wxBITMAP_TYPE_BMP) | |
337 | { | |
338 | wxImage image; | |
339 | image.LoadFile( name, type ); | |
340 | if (image.Ok()) *this = wxBitmap( image ); | |
341 | } | |
342 | else | |
343 | return FALSE; | |
344 | ||
345 | return TRUE; | |
346 | } | |
347 | ||
348 | wxPalette *wxBitmap::GetPalette(void) const | |
349 | { | |
350 | if (!Ok()) return (wxPalette *) NULL; | |
351 | return M_BMPDATA->m_palette; | |
352 | } | |
353 | ||
354 | GdkPixmap *wxBitmap::GetPixmap(void) const | |
355 | { | |
356 | if (!Ok()) | |
357 | { | |
358 | wxFAIL_MSG( "invalid bitmap" ); | |
359 | return (GdkPixmap *) NULL; | |
360 | } | |
361 | ||
362 | return M_BMPDATA->m_pixmap; | |
363 | } | |
364 | ||
365 | GdkBitmap *wxBitmap::GetBitmap(void) const | |
366 | { | |
367 | if (!Ok()) | |
368 | { | |
369 | wxFAIL_MSG( "invalid bitmap" ); | |
370 | return (GdkBitmap *) NULL; | |
371 | } | |
372 | ||
373 | return M_BMPDATA->m_bitmap; | |
374 | } | |
375 | ||
376 | wxBitmap::wxBitmap( const wxImage &image ) | |
377 | { | |
378 | if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); | |
379 | ||
380 | if (!image.Ok()) return; | |
381 | ||
382 | m_refData = new wxBitmapRefData(); | |
383 | ||
384 | M_BMPDATA->m_height = image.GetHeight(); | |
385 | M_BMPDATA->m_width = image.GetWidth(); | |
386 | int width = image.GetWidth(); | |
387 | int height = image.GetHeight(); | |
388 | ||
389 | // Create picture | |
390 | ||
391 | GdkImage *data_image = | |
392 | gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height ); | |
393 | ||
394 | M_BMPDATA->m_pixmap = | |
395 | gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 ); | |
396 | ||
397 | // Create mask | |
398 | ||
399 | GdkImage *mask_image = (GdkImage*) NULL; | |
400 | ||
401 | if (image.HasMask()) | |
402 | { | |
403 | unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); | |
404 | ||
405 | mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); | |
406 | ||
407 | M_BMPDATA->m_mask = new wxMask(); | |
408 | M_BMPDATA->m_mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ); | |
409 | } | |
410 | ||
411 | // Retrieve depth | |
412 | ||
413 | GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); | |
414 | if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); | |
415 | int bpp = visual->depth; | |
416 | if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; | |
417 | if (bpp < 8) bpp = 8; | |
418 | ||
419 | // Render | |
420 | ||
421 | enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; | |
422 | byte_order b_o = RGB; | |
423 | ||
424 | if (bpp >= 24) | |
425 | { | |
426 | GdkVisual *visual = gdk_visual_get_system(); | |
427 | if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB; | |
428 | else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB; | |
429 | else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG; | |
430 | else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR; | |
431 | else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB; | |
432 | else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR; | |
433 | } | |
434 | ||
435 | int r_mask = image.GetMaskRed(); | |
436 | int g_mask = image.GetMaskGreen(); | |
437 | int b_mask = image.GetMaskBlue(); | |
438 | ||
439 | unsigned char* data = image.GetData(); | |
440 | ||
441 | int index = 0; | |
442 | for (int y = 0; y < height; y++) | |
443 | { | |
444 | for (int x = 0; x < width; x++) | |
445 | { | |
446 | int r = data[index]; | |
447 | index++; | |
448 | int g = data[index]; | |
449 | index++; | |
450 | int b = data[index]; | |
451 | index++; | |
452 | ||
453 | if (image.HasMask()) | |
454 | { | |
455 | if ((r == r_mask) && (b == b_mask) && (g == g_mask)) | |
456 | gdk_image_put_pixel( mask_image, x, y, 1 ); | |
457 | else | |
458 | gdk_image_put_pixel( mask_image, x, y, 0 ); | |
459 | } | |
460 | ||
461 | switch (bpp) | |
462 | { | |
463 | case 8: | |
464 | { | |
465 | GdkColormap *cmap = gtk_widget_get_default_colormap(); | |
466 | GdkColor *colors = cmap->colors; | |
467 | int max = 3 * (65536); | |
468 | int index = -1; | |
469 | ||
470 | for (int i = 0; i < cmap->size; i++) | |
471 | { | |
472 | int rdiff = (r << 8) - colors[i].red; | |
473 | int gdiff = (g << 8) - colors[i].green; | |
474 | int bdiff = (b << 8) - colors[i].blue; | |
475 | int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); | |
476 | if (sum < max) { index = i; max = sum; } | |
477 | } | |
478 | ||
479 | gdk_image_put_pixel( data_image, x, y, index ); | |
480 | ||
481 | break; | |
482 | } | |
483 | case 15: | |
484 | { | |
485 | guint32 pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); | |
486 | gdk_image_put_pixel( data_image, x, y, pixel ); | |
487 | break; | |
488 | } | |
489 | case 16: | |
490 | { | |
491 | guint32 pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); | |
492 | gdk_image_put_pixel( data_image, x, y, pixel ); | |
493 | break; | |
494 | } | |
495 | case 32: | |
496 | case 24: | |
497 | { | |
498 | guint32 pixel = 0; | |
499 | switch (b_o) | |
500 | { | |
501 | case RGB: pixel = (r << 16) | (g << 8) | b; break; | |
502 | case RBG: pixel = (r << 16) | (b << 8) | g; break; | |
503 | case BRG: pixel = (b << 16) | (r << 8) | g; break; | |
504 | case BGR: pixel = (b << 16) | (g << 8) | r; break; | |
505 | case GRB: pixel = (g << 16) | (r << 8) | b; break; | |
506 | case GBR: pixel = (g << 16) | (b << 8) | r; break; | |
507 | } | |
508 | gdk_image_put_pixel( data_image, x, y, pixel ); | |
509 | } | |
510 | default: break; | |
511 | } | |
512 | } // for | |
513 | } // for | |
514 | ||
515 | // Blit picture | |
516 | ||
517 | GdkGC *data_gc = gdk_gc_new( M_BMPDATA->m_pixmap ); | |
518 | ||
519 | gdk_draw_image( M_BMPDATA->m_pixmap, data_gc, data_image, 0, 0, 0, 0, width, height ); | |
520 | ||
521 | gdk_image_destroy( data_image ); | |
522 | gdk_gc_unref( data_gc ); | |
523 | ||
524 | // Blit mask | |
525 | ||
526 | if (image.HasMask()) | |
527 | { | |
528 | GdkGC *mask_gc = gdk_gc_new( M_BMPDATA->m_mask->m_bitmap ); | |
529 | ||
530 | gdk_draw_image( M_BMPDATA->m_mask->m_bitmap, mask_gc, mask_image, 0, 0, 0, 0, width, height ); | |
531 | ||
532 | gdk_image_destroy( mask_image ); | |
533 | gdk_gc_unref( mask_gc ); | |
534 | } | |
535 | } | |
536 | ||
537 | wxImage wxBitmap::ConvertToImage() const | |
538 | { | |
539 | wxImage image; | |
540 | ||
541 | if (!Ok()) | |
542 | { | |
543 | wxFAIL_MSG( "invalid bitmap" ); | |
544 | return image; | |
545 | } | |
546 | ||
547 | GdkImage *gdk_image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height ); | |
548 | ||
549 | if (!gdk_image) return image; | |
550 | ||
551 | image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height ); | |
552 | char unsigned *data = image.GetData(); | |
553 | ||
554 | GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); | |
555 | if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); | |
556 | int bpp = visual->depth; | |
557 | if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; | |
558 | ||
559 | GdkColormap *cmap = gtk_widget_get_default_colormap(); | |
560 | ||
561 | long pos = 0; | |
562 | for (int j = 0; j < M_BMPDATA->m_height; j++) | |
563 | { | |
564 | for (int i = 0; i < M_BMPDATA->m_width; i++) | |
565 | { | |
566 | int pixel = gdk_image_get_pixel( gdk_image, i, j ); | |
567 | if (bpp <= 8) | |
568 | { | |
569 | data[pos] = cmap->colors[pixel].red >> 8; | |
570 | data[pos+1] = cmap->colors[pixel].green >> 8; | |
571 | data[pos+2] = cmap->colors[pixel].blue >> 8; | |
572 | } else if (bpp == 15) | |
573 | { | |
574 | data[pos] = (pixel >> 7) & 0xf8; | |
575 | data[pos+1] = (pixel >> 2) & 0xf8; | |
576 | data[pos+2] = (pixel << 3) & 0xf8; | |
577 | } else if (bpp == 16) | |
578 | { | |
579 | data[pos] = (pixel >> 8) & 0xf8; | |
580 | data[pos+1] = (pixel >> 3) & 0xfc; | |
581 | data[pos+2] = (pixel << 3) & 0xf8; | |
582 | } else | |
583 | { | |
584 | data[pos] = (pixel >> 16) & 0xff; | |
585 | data[pos+1] = (pixel >> 8) & 0xff; | |
586 | data[pos+2] = pixel & 0xff; | |
587 | } | |
588 | ||
589 | pos += 3; | |
590 | } | |
591 | } | |
592 | ||
593 | gdk_image_destroy( gdk_image ); | |
594 | ||
595 | return image; | |
596 | } | |
597 | ||
598 | ||
599 |