How to set the background of an image?
- From: Frank Hrebabetzky <hreba terra com br>
- To: gtk-app-devel list <gtk-app-devel-list gnome org>
- Subject: How to set the background of an image?
- Date: Tue, 05 Oct 2004 22:36:57 -0300
In order to rotate text by 90 degrees I want to render the text to a
bitmap, create a GdkImage from that, read pixel by pixel, transform
their coordinates, write them back to another image and draw that one
finally. No I wrote a small program as an exercise, without the
transformation part, and the problem is the black background which I
don't see how to change. Any help?
The expose-event callback function which contains my experimental code
is here:
void draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GdkGC * gc;
GdkColor red;
GdkPixmap *hpixmap;
PangoLayout *layout;
GdkImage *image;
int width, height;
red.pixel = 0;
red.red = 0xffff;
red.green = 0;
red.blue = 0;
gc = gdk_gc_new (widget->window);
gdk_gc_set_rgb_fg_color (gc, &red);
gdk_draw_arc (widget->window, gc,
FALSE, 0, 0, widget->allocation.width,
widget->allocation.height, 0, 64*360);
hpixmap = gdk_pixmap_new (widget->window, 512, 32, -1);
layout = gtk_widget_create_pango_layout (widget, "Demo");
gdk_draw_layout (hpixmap, gc, 0, 0, layout);
pango_layout_get_pixel_size (layout, &width, &height);
image = gdk_drawable_get_image (hpixmap, 0, 0, width, height);
gdk_draw_image (widget->window, gc, image, 0, 0, 0, 0, width, height);
g_object_unref (gc);
}
--
Frank Hrebabetzky +55 / 48 / 235 1106
Florianopolis, Brazil
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]