Why we can't draw a bitmap?
- From: Dong JunYu <dongjunyu gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Why we can't draw a bitmap?
- Date: Wed, 13 Jul 2005 10:38:29 +0800
I have a project to want to display a 320*240 mono bitmap in a
GtkDrawArea or GtkImage
widget, bitmap data was generate by program in a array: "char
bitmap_data[9600];"
I know bitmap is a 1 bit depth pixmap, and GtkImage or GtkDrawArea is
24 bits depth, not match, My program source code as fellow, and it
called after gtk_widget_show() before
gtk_main():
// Create new bitmap
pBitmap = gdk_bitmap_create_from_data(MyDrawArea->window, bitmap_data,
320, 240);
// Create new GC with 1 bit depth
gc = gdk_gc_new(pCurBitmap);
// Create and fill white & black color to draw bitmap
colormap = gdk_colormap_get_system();
gdk_colormap_alloc_color(colormap, &white_color, TRUE, TRUE);
gdk_colormap_alloc_color(colormap, &black_color, TRUE, TRUE);
gdk_color_parse("white", &white_color);
gdk_color_parse("black", &black_color);
// Draw bitmap
gdk_gc_set_foreground(gc, &white_color);
gdk_draw_rectangle(pBitmap, gc, TRUE, 0, 0, 320, 240);
gdk_gc_set_clip_mask(gc, pBitmap);
gdk_gc_set_foreground(gc, &black_color);
gdk_draw_rectangle(pBitmap, gc, TRUE, 0, 0, 320, 240);
// display in screen
gtk_widget_queue_draw_area(MyDrawArea, 0, 0, 320, 240);
it seems program execute successful, but nothing display!!!, why?
what I will do?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]