static VALUE rg_s_from_image(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self) { VALUE cmap, src, src_x, src_y, width, height, dest, dest_x, dest_y; GdkPixbuf* buf; rb_scan_args(argc, argv, "63", &cmap, &src, &src_x, &src_y, &width, &height, &dest, &dest_x, &dest_y); buf = gdk_pixbuf_get_from_image(GDK_PIXBUF(RVAL2GOBJ(dest)), GDK_IMAGE(RVAL2GOBJ(src)), GDK_COLORMAP(RVAL2GOBJ(cmap)), NUM2INT(src_x), NUM2INT(src_y), NIL_P(dest_x) ? 0 : NUM2INT(dest_x), NIL_P(dest_y) ? 0 : NUM2INT(dest_y), NUM2INT(width), NUM2INT(height)); if (NIL_P(dest)) { if (buf) { return GOBJ2RVAL(buf); } else { return Qnil; } } else { return dest; } }
void GtkViewWidget::repaint() { GtkPaintContext >kContext = (GtkPaintContext&)view()->context(); Angle angle = rotation(); bool isRotated = (angle == DEGREES90) || (angle == DEGREES270); int w = isRotated ? myArea->allocation.height : myArea->allocation.width; int h = isRotated ? myArea->allocation.width : myArea->allocation.height; gtkContext.updatePixmap(myArea, w, h); view()->paint(); switch (angle) { default: cleanOriginalPixbuf(); cleanRotatedPixbuf(); gdk_draw_pixmap(myArea->window, myArea->style->white_gc, gtkContext.pixmap(), 0, 0, 0, 0, myArea->allocation.width, myArea->allocation.height); break; case DEGREES180: cleanRotatedPixbuf(); if ((myOriginalPixbuf != 0) && ((gdk_pixbuf_get_width(myOriginalPixbuf) != w) || (gdk_pixbuf_get_height(myOriginalPixbuf) != h))) { cleanOriginalPixbuf(); } if (myOriginalPixbuf == 0) { myOriginalPixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, w, h); myImage = gdk_image_new(GDK_IMAGE_FASTEST, gdk_drawable_get_visual(gtkContext.pixmap()), w, h); } gdk_drawable_copy_to_image(gtkContext.pixmap(), myImage, 0, 0, 0, 0, w, h); gdk_pixbuf_get_from_image(myOriginalPixbuf, myImage, gdk_drawable_get_colormap(gtkContext.pixmap()), 0, 0, 0, 0, w, h); ::rotate180(myOriginalPixbuf); gdk_draw_pixbuf(myArea->window, myArea->style->white_gc, myOriginalPixbuf, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0); break; case DEGREES90: case DEGREES270: if ((myOriginalPixbuf != 0) && ((gdk_pixbuf_get_width(myOriginalPixbuf) != w) || (gdk_pixbuf_get_height(myOriginalPixbuf) != h))) { cleanOriginalPixbuf(); } if ((myRotatedPixbuf != 0) && ((gdk_pixbuf_get_width(myRotatedPixbuf) != h) || (gdk_pixbuf_get_height(myRotatedPixbuf) != w))) { cleanRotatedPixbuf(); } if (myOriginalPixbuf == 0) { myOriginalPixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, w, h); myImage = gdk_image_new(GDK_IMAGE_FASTEST, gdk_drawable_get_visual(gtkContext.pixmap()), w, h); } if (myRotatedPixbuf == 0) { myRotatedPixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, h, w); } gdk_drawable_copy_to_image(gtkContext.pixmap(), myImage, 0, 0, 0, 0, w, h); gdk_pixbuf_get_from_image(myOriginalPixbuf, myImage, gdk_drawable_get_colormap(gtkContext.pixmap()), 0, 0, 0, 0, w, h); ::rotate90(myRotatedPixbuf, myOriginalPixbuf, angle == DEGREES90); gdk_draw_pixbuf(myArea->window, myArea->style->white_gc, myRotatedPixbuf, 0, 0, 0, 0, h, w, GDK_RGB_DITHER_NONE, 0, 0); break; } }