Help Using Gdk_image
- From: Michael Noonan <mick_n_10 yahoo ie>
- To: gtk-app-devel-list gnome org
- Subject: Help Using Gdk_image
- Date: Tue, 29 Nov 2005 15:07:44 +0000 (GMT)
Hello,
I'm new to using gtk and would really appreciate it if
anybody could help me.
I'm trying to display an image on the screen thats
created from individual pixel information. I create
the image and then set the indivisual pixels. Then I
try to display the image but I keep getting errors
when I try to execute.
Am I going about this the wrong way! I've attached the
code below.
Thanks in advance.
Mike
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdktypes.h>
using namespace std;
int main( int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *canvas;
GdkVisual *visual;
GdkImage *image;
GdkGC *gc;
int i, j;
unsigned char frame_data[128][64];
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(GTK_WIDGET(window), 1024,
768);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
visual = gdk_visual_get_system();
image = gdk_image_new( GDK_IMAGE_FASTEST, visual, 64,
128 );
gc = gdk_gc_new( GTK_WIDGET( window )->window );
canvas = gtk_drawing_area_new();
gtk_container_add( GTK_CONTAINER( window ), canvas);
gtk_widget_show(canvas);
//set the individual pixels
for( i = 0; i < 128; i++ )
{
for( j = 0; j < 64; j++ )
{
gdk_image_put_pixel( image, i, j, data[i][j] );
}
}
gdk_draw_image( GTK_WIDGET( canvas )->window, gc,
image, 0,0,0,0, 64, 128);
gtk_widget_show(window);
gtk_main();
}
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
http://uk.security.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]