static void gtk_plot_gdk_draw_pixmap (GtkPlotPC *pc, GdkPixmap *pixmap, GdkBitmap *mask, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height, gdouble scale_x, gdouble scale_y) { GdkGC *gc; GdkPixmap *new_pixmap; GdkBitmap *new_mask = NULL; if(!GTK_PLOT_GDK(pc)->drawable) return; if(!GTK_PLOT_GDK(pc)->window) return; if(!GTK_PLOT_GDK(pc)->gc) return; gc = GTK_PLOT_GDK(pc)->gc; if(!gc) return; new_pixmap = scale_pixmap(GTK_PLOT_GDK(pc)->window, pixmap, scale_x, scale_y); if(mask) new_mask = scale_bitmap(GTK_PLOT_GDK(pc)->window, mask, scale_x, scale_y); gtk_plot_pc_clip_mask(pc, xdest, ydest, new_mask); gdk_draw_pixmap(GTK_PLOT_GDK(pc)->drawable, gc, new_pixmap, xsrc, ysrc, xdest, ydest, width*scale_x, height*scale_y); gtk_plot_pc_clip_mask(pc, xdest, ydest, NULL); if(new_mask) gdk_bitmap_unref(new_mask); gdk_pixmap_unref(new_pixmap); }
static void psdrawpixmap (GtkPlotPC *pc, GdkPixmap *pixmap, GdkBitmap *mask, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height, gdouble scale_x, gdouble scale_y) { FILE *psout = GTK_PLOT_PS(pc)->psfile; GdkColormap *colormap; colormap = gdk_colormap_get_system (); fprintf(psout, "gsave\n"); if(pixmap){ GdkImage *image; gint x, y; image = gdk_image_get(pixmap, xsrc, ysrc, width, height); if(mask) gtk_plot_pc_clip_mask(pc, xdest, ydest, mask); fprintf(psout, "%d %g translate\n", xdest, ydest + height * scale_y); fprintf(psout, "%g %g scale\n",width * scale_x, height * scale_y); fprintf(psout, "%d %d 8 [%d 0 0 %d 0 %d]\n",width, height, width, height, height); fprintf(psout, "/scanline %d 3 mul string def\n", width); fprintf(psout, "{ currentfile scanline readhexstring pop } false 3\n"); fprintf(psout, "colorimage\n"); for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ GdkColor color; gchar string[7]; color.pixel = gdk_image_get_pixel(image, x, y); gdk_colormap_query_color(colormap, color.pixel, &color); color_to_hex(color, string); fprintf(psout,"%s",string); if(fmod(x + 1, 13) == 0) fprintf(psout, "\n"); } fprintf(psout,"\n"); } gdk_image_destroy(image); if(mask) gtk_plot_pc_clip_mask(pc, xdest, ydest, NULL); } fprintf(psout, "grestore\n"); }