set da1 [gnocl::drawingArea ]
set win1 [gnocl::window \
-child $da1 \
-widthRequest 200 \
-heightRequest 200 \
-allowShrink 0 \
-allowGrow 0]
update ;# ensure that the widgets are drawn first
set pb4 [gnocl::pixBuf load "wjg.jpg"]
$pb4 rotate 45
$pb4 draw $da1 \
-srcXY {0 0} \
-destXY {0 0} \
-ditherXY {0 0} \
-width 100 \
-height 100
This is the C code to handle the drawing process:
case DrawIdx:
{
/* draw the pixbuf to a GdkDrawable: ie. a drawing area */
GtkWidget *widget;
GdkDrawable *dest;
gint src_x, src_y;
gint dest_x, dest_y;
gint width, height;
gint x_dither, y_dither;
/* initialize the values with defaults */
src_x = 0;
src_y = 0;
dest_x = 10;
dest_y = 10;
x_dither = 0;
y_dither = 0;
/* what size of the buffer has to be drawn */
width = gdk_pixbuf_get_width ( pixbuf );
height = gdk_pixbuf_get_height ( pixbuf );
widget = gnoclGetWidgetFromName ( Tcl_GetString ( objv[2] ), interp );
if ( widget == NULL )
{
return TCL_ERROR;
}
dest = GDK_DRAWABLE ( widget->window );
/* change values based upon switches passed */
gdk_draw_pixbuf (
dest,
gdk_gc_new ( widget->window ),
pixbuf,
src_x, src_y,
dest_x, dest_y,
width,
height,
GDK_RGB_DITHER_NONE,
x_dither, y_dither );
}
break;
This is the output:
This is the C code to handle the drawing process:
{
/* draw the pixbuf to a GdkDrawable: ie. a drawing area */
GtkWidget *widget;
GdkDrawable *dest;
gint src_x, src_y;
gint dest_x, dest_y;
gint width, height;
gint x_dither, y_dither;
/* initialize the values with defaults */
src_x = 0;
src_y = 0;
dest_x = 10;
dest_y = 10;
x_dither = 0;
y_dither = 0;
/* what size of the buffer has to be drawn */
width = gdk_pixbuf_get_width ( pixbuf );
height = gdk_pixbuf_get_height ( pixbuf );
widget = gnoclGetWidgetFromName ( Tcl_GetString ( objv[2] ), interp );
if ( widget == NULL )
{
return TCL_ERROR;
}
dest = GDK_DRAWABLE ( widget->window );
/* change values based upon switches passed */
gdk_draw_pixbuf (
dest,
gdk_gc_new ( widget->window ),
pixbuf,
src_x, src_y,
dest_x, dest_y,
width,
height,
GDK_RGB_DITHER_NONE,
x_dither, y_dither );
}
break;

No comments:
Post a Comment