fb:porticula NoPaste
imagebuffer von freebasic in gtkfenster malen
Uploader: | Michael |
Datum/Zeit: | 09.09.2007 14:28:11 |
'gdk_image.bas aus dem examples ordner ein klein wenig angepasst (nur testcode!)
#include once "gtk/gtk.bi"
#define NULL 0
#define IMAGE_WIDTH 1024
#define IMAGE_HEIGHT 768
dim shared rgbbuf(IMAGE_WIDTH * IMAGE_HEIGHT * 3) as byte
declare function on_darea_expose cdecl( byval widget as GtkWidget ptr, _
byval event as GdkEventExpose ptr, _
byval userdata as gpointer ) as gboolean
'' main
dim as GtkWidget ptr win, drawarea
dim as integer x, y, i
'' initialize Gtk
gtk_init( NULL, NULL )
'' create a window
win = gtk_window_new( GTK_WINDOW_TOPLEVEL )
gtk_window_set_title( GTK_WINDOW(win), "RGB Test" )
gtk_signal_connect( GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(@gtk_main_quit), NULL )
'' create a drawable area on it
drawarea = gtk_drawing_area_new( )
gtk_widget_set_size_request( drawarea, IMAGE_WIDTH, IMAGE_HEIGHT )
gtk_container_add( GTK_CONTAINER(win), drawarea )
'' set the callback for when the window is redrawn
gtk_signal_connect( GTK_OBJECT(drawarea), "expose-event", GTK_SIGNAL_FUNC(@on_darea_expose), NULL )
gtk_widget_show_all( win )
'' create an 24-bit RGB image
screenres IMAGE_WIDTH, IMAGE_HEIGHT, 32,,-1
Circle (100, 400), 100, &Hff0000,,,, f
Line (10, 10)-(1000, 300), &H0000ff,bf
gtk_main()
end
'':::::
function on_darea_expose cdecl( byval widget as GtkWidget ptr, _
byval event as GdkEventExpose ptr, _
byval userdata as gpointer) as gboolean
'' draw the 24-bit RGB image (conversions are done automatically)
gdk_draw_rgb_32_image( widget->window, _
widget->style->fg_gc(GTK_STATE_NORMAL), _
0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, _
GDK_RGB_DITHER_MAX, screenptr, IMAGE_WIDTH * 4 )
'' return OK
return TRUE
end function