static void clear_light_marker (void) { /* Restore background if it has been saved */ /* ======================================= */ if (backbuf.image != NULL) { GdkColor color; color.red = 0x0; color.green = 0x0; color.blue = 0x0; gdk_gc_set_rgb_bg_color (gc, &color); color.red = 0xFFFF; color.green = 0xFFFF; color.blue = 0xFFFF; gdk_gc_set_rgb_fg_color (gc, &color); gdk_gc_set_function (gc, GDK_COPY); gdk_draw_image (previewarea->window, gc, backbuf.image, 0, 0, backbuf.x, backbuf.y, backbuf.w, backbuf.h); g_object_unref (backbuf.image); backbuf.image = NULL; } }
/* Redraw the screen from the backing pixmap */ static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event) { static GdkImage *image = NULL; GdkCursor *cursor; GdkPixbuf *pixbuf; if (framebuffer_allocated == FALSE) { rfbClientSetClientData (cl, gtk_init, widget); image = gdk_drawable_get_image (widget->window, 0, 0, widget->allocation.width, widget->allocation.height); cl->frameBuffer= image->mem; cl->width = widget->allocation.width; cl->height = widget->allocation.height; cl->format.bitsPerPixel = image->bits_per_pixel; cl->format.redShift = image->visual->red_shift; cl->format.greenShift = image->visual->green_shift; cl->format.blueShift = image->visual->blue_shift; cl->format.redMax = (1 << image->visual->red_prec) - 1; cl->format.greenMax = (1 << image->visual->green_prec) - 1; cl->format.blueMax = (1 << image->visual->blue_prec) - 1; #ifdef LIBVNCSERVER_CONFIG_LIBVA /* Allow libvncclient to use a more efficient way * of putting the framebuffer on the screen when * using the H.264 format. */ cl->outputWindow = GDK_WINDOW_XID(widget->window); #endif SetFormatAndEncodings (cl); framebuffer_allocated = TRUE; /* Also disable local cursor */ pixbuf = gdk_pixbuf_new_from_xpm_data(dot_cursor_xpm); cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, dot_cursor_x_hot, dot_cursor_y_hot); g_object_unref(pixbuf); gdk_window_set_cursor (gtk_widget_get_window(GTK_WIDGET(window)), cursor); gdk_cursor_unref(cursor); } #ifndef LIBVNCSERVER_CONFIG_LIBVA gdk_draw_image (GDK_DRAWABLE (widget->window), widget->style->fg_gc[gtk_widget_get_state(widget)], image, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height); #endif return FALSE; }
void GtkOvgGlue::render(int /* minx */, int /* miny */, int /* maxx */, int /* maxy */) { GNASH_REPORT_FUNCTION; #ifdef ENABLE_EGL_OFFSCREEN if (!_offscreenbuf) { log_error(_("No off screen buffer!")); return; } const int& x = minx; const int& y = miny; size_t width = std::min(_offscreenbuf->width, maxx - minx); size_t height = std::min(_offscreenbuf->height, maxy - miny); GdkGC* gc = gdk_gc_new(_drawing_area->window); gdk_draw_image(_drawing_area->window, gc, _offscreenbuf, x, y, x, y, width, height); gdk_gc_unref(gc); #else // _device->swapBbuffers(); #endif }
/* * Since the NES does everything in eight bit index mode, * we need to translate that indexed framebuffer into our * native format for display. */ void video_display_buffer( void ) { int i; unsigned short* buffer_16; int num_pixels; switch( cur_image->bpp ) { case 1: /* Empty. */ break; case 2: buffer_16 = (unsigned short*) cur_image->mem; num_pixels = video_buffer_width * video_buffer_height; for( i = 0; i < num_pixels; ++i ) { buffer_16[i] = translation_buffer_16[ (int) cur_video_buffer[i] ]; } break; default: fprintf( stderr, "darcnes: unknown display depth %d in video_display_buffer()\n", cur_image->bpp ); break; } gdk_draw_image( nes_gtk_window->window, gc, cur_image, 0, 0, 0, 0, video_buffer_width, video_buffer_height ); gdk_flush( ); cur_image = ( cur_image == image_1 ) ? image_2 : image_1; cur_video_buffer = ( cur_video_buffer == video_buffer_1 ) ? video_buffer_2 : video_buffer_1; }
static VALUE rg_draw_image(VALUE self, VALUE gc, VALUE image, VALUE xsrc, VALUE ysrc, VALUE xdst, VALUE ydst, VALUE w, VALUE h) { gdk_draw_image(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), GDK_IMAGE(RVAL2GOBJ(image)), NUM2INT(xsrc), NUM2INT(ysrc), NUM2INT(xdst), NUM2INT(ydst), NUM2INT(w), NUM2INT(h)); return self; }
void GtkAggGlue::render(int minx, int miny, int maxx, int maxy) { if (!_offscreenbuf) { return; } const int& x = minx; const int& y = miny; size_t width = std::min(_offscreenbuf->width, maxx - minx); size_t height = std::min(_offscreenbuf->height, maxy - miny); GdkGC* gc = gdk_gc_new(_drawing_area->window); gdk_draw_image(_drawing_area->window, gc, _offscreenbuf, x, y, x, y, width, height); gdk_gc_unref(gc); }
void FASTCALL WinDraw_Draw(void) { GtkWidget *w = (GtkWidget *)drawarea; GdkDrawable *d = (GdkDrawable *)drawarea->window; FrameCount++; if (!Draw_DrawFlag && is_installed_idle_process()) return; Draw_DrawFlag = 0; if (SplashFlag) WinDraw_ShowSplash(); if (screen_mode == 0) { gdk_draw_pixmap(d, w->style->fg_gc[GTK_WIDGET_STATE(w)], pixmap, 0, 0, 0, 0, TextDotX, TextDotY); } else { gdk_scale_image(scaled_screen, surface, NULL, &surface_rect); gdk_draw_image(d, w->style->fg_gc[GTK_WIDGET_STATE(w)], scaled_screen, 0, 0, 0, 0, WindowX, WindowY); } }
int x_tile_render_to_drawable(GdkDrawable *drawable, GdkGC *gc, int tile, int sx, int sy, int dest_x, int dest_y, int width, int height) { int srcx, srcy; srcx = (tile % tiles_per_row) * Tile->unit_width; srcy = (tile / tiles_per_row) * Tile->unit_height; if (sx < 0) { dest_x -= sx; width += sx; sx = 0; } if (sy < 0) { dest_y -= sy; height += sy; sy = 0; } if (sx + width > Tile->unit_width) width = Tile->unit_width - sx; if (sy + height > Tile->unit_height) height = Tile->unit_height - sy; if (tile_image) gdk_draw_image(drawable, gc, tile_image, srcx + sx, srcy + sy, dest_x, dest_y, width, height); else if (tile_pixbuf) gdk_pixbuf_render_to_drawable(tile_pixbuf, drawable, gc, srcx + sx, srcy + sy, dest_x, dest_y, width, height, GDK_RGB_DITHER_NORMAL, 0, 0); else gdk_draw_drawable(drawable, gc, tile_pixmap, srcx + sx, srcy + sy, dest_x, dest_y, width, height); return 1; }
static void draw_handles (void) { gdouble dxpos, dypos; gint startx, starty, pw, ph; GimpVector3 viewpoint; GimpVector3 light_position; gint k = mapvals.light_selected; gfloat length; gfloat delta_x = 0.0; gfloat delta_y = 0.0; /* calculate handle position */ compute_preview_rectangle (&startx, &starty, &pw, &ph); switch (mapvals.lightsource[k].type) { case NO_LIGHT: return; case POINT_LIGHT: case SPOT_LIGHT: /* swap z to reverse light position */ viewpoint = mapvals.viewpoint; viewpoint.z = -viewpoint.z; light_position = mapvals.lightsource[k].position; gimp_vector_3d_to_2d (startx, starty, pw, ph, &dxpos, &dypos, &viewpoint, &light_position); handle_xpos = (gint) (dxpos + 0.5); handle_ypos = (gint) (dypos + 0.5); break; case DIRECTIONAL_LIGHT: light_position.x = light_position.y = 0.5; light_position.z = 0; viewpoint.z = -viewpoint.z; gimp_vector_3d_to_2d (startx, starty, pw, ph, &dxpos, &dypos, &viewpoint, &light_position); length = PREVIEW_HEIGHT / 4; delta_x = mapvals.lightsource[k].direction.x * length; delta_y = mapvals.lightsource[k].direction.y * length; handle_xpos = dxpos + delta_x; handle_ypos = dypos + delta_y; break; } gdk_gc_set_function (gc, GDK_COPY); if (mapvals.lightsource[k].type != NO_LIGHT) { GdkColor color; /* Restore background if it has been saved */ /* ======================================= */ if (backbuf.image != NULL) { gdk_gc_set_function (gc, GDK_COPY); gdk_draw_image (previewarea->window, gc, backbuf.image, 0, 0, backbuf.x, backbuf.y, backbuf.w, backbuf.h); g_object_unref (backbuf.image); backbuf.image = NULL; } /* calculate backbuffer */ switch (mapvals.lightsource[k].type) { case POINT_LIGHT: backbuf.x = handle_xpos - LIGHT_SYMBOL_SIZE / 2; backbuf.y = handle_ypos - LIGHT_SYMBOL_SIZE / 2; backbuf.w = LIGHT_SYMBOL_SIZE; backbuf.h = LIGHT_SYMBOL_SIZE; break; case DIRECTIONAL_LIGHT: if (delta_x <= 0) backbuf.x = handle_xpos; else backbuf.x = startx + pw/2; if (delta_y <= 0) backbuf.y = handle_ypos; else backbuf.y = starty + ph/2; backbuf.x -= LIGHT_SYMBOL_SIZE/2; backbuf.y -= LIGHT_SYMBOL_SIZE/2; backbuf.w = fabs(delta_x) + LIGHT_SYMBOL_SIZE; backbuf.h = fabs(delta_y) + LIGHT_SYMBOL_SIZE; break; case SPOT_LIGHT: backbuf.x = handle_xpos - LIGHT_SYMBOL_SIZE / 2; backbuf.y = handle_ypos - LIGHT_SYMBOL_SIZE / 2; backbuf.w = LIGHT_SYMBOL_SIZE; backbuf.h = LIGHT_SYMBOL_SIZE; break; case NO_LIGHT: break; } /* Save background */ /* =============== */ if ((backbuf.x >= 0) && (backbuf.x <= PREVIEW_WIDTH) && (backbuf.y >= 0) && (backbuf.y <= PREVIEW_HEIGHT)) { /* clip coordinates to preview widget sizes */ if ((backbuf.x + backbuf.w) > PREVIEW_WIDTH) backbuf.w = (PREVIEW_WIDTH - backbuf.x); if ((backbuf.y + backbuf.h) > PREVIEW_HEIGHT) backbuf.h = (PREVIEW_HEIGHT - backbuf.y); backbuf.image = gdk_drawable_get_image (previewarea->window, backbuf.x, backbuf.y, backbuf.w, backbuf.h); } color.red = 0x0; color.green = 0x0; color.blue = 0x0; gdk_gc_set_rgb_bg_color (gc, &color); color.red = 0x0; color.green = 0x4000; color.blue = 0xFFFF; gdk_gc_set_rgb_fg_color (gc, &color); /* draw circle at light position */ switch (mapvals.lightsource[k].type) { case POINT_LIGHT: case SPOT_LIGHT: gdk_draw_arc (previewarea->window, gc, TRUE, handle_xpos - LIGHT_SYMBOL_SIZE / 2, handle_ypos - LIGHT_SYMBOL_SIZE / 2, LIGHT_SYMBOL_SIZE, LIGHT_SYMBOL_SIZE, 0, 360 * 64); break; case DIRECTIONAL_LIGHT: gdk_draw_arc (previewarea->window, gc, TRUE, handle_xpos - LIGHT_SYMBOL_SIZE / 2, handle_ypos - LIGHT_SYMBOL_SIZE / 2, LIGHT_SYMBOL_SIZE, LIGHT_SYMBOL_SIZE, 0, 360 * 64); gdk_draw_line (previewarea->window, gc, handle_xpos, handle_ypos, startx+pw/2 , starty + ph/2); break; case NO_LIGHT: break; } } }
static GdkBitmap * scale_bitmap (GdkWindow *window, GdkBitmap *bitmap, gdouble scale_x, gdouble scale_y) { GdkGC *gc; GdkVisual *visual = NULL; GdkImage *image = NULL, *new_image = NULL; GdkBitmap *new_bitmap = NULL; gint x, y, width, height, new_width, new_height; GdkColor color; if(!bitmap) return NULL; if(!window) return NULL; gc = gdk_gc_new(bitmap); gdk_window_get_size(bitmap, &width, &height); if(scale_x == 1.0 && scale_y == 1.0){ new_bitmap = gdk_pixmap_new(window, width, height, 1); color.pixel = 0; gdk_gc_set_foreground(gc, &color); gdk_draw_rectangle(new_bitmap, gc, TRUE, 0, 0, width, height); color.pixel = 1; gdk_gc_set_foreground(gc, &color); gdk_draw_pixmap(new_bitmap, gc, bitmap, 0, 0, 0, 0, width, height); gdk_gc_unref(gc); return new_bitmap; } new_width = roundint(width * scale_x); new_height = roundint(height * scale_y); /* make a client side image of the bitmap, and * scale the data into a another client side image */ visual = gdk_window_get_visual (bitmap); if(!visual) return NULL; new_image = gdk_image_new(GDK_IMAGE_FASTEST,visual,new_width,new_height); if(!new_image) return NULL; new_bitmap = gdk_pixmap_new(window, new_width, new_height, 1); image = gdk_drawable_get_image(bitmap, 0, 0, width, height); color.pixel = 0; gdk_gc_set_foreground(gc, &color); gdk_draw_rectangle(new_bitmap, gc, TRUE, 0, 0, width, height); color.pixel = 1; gdk_gc_set_foreground(gc, &color); for(x = 0; x < new_width; x++){ for(y = 0; y < new_height; y++){ gint px, py; gulong pixel; px = MIN(roundint(x / scale_x), width - 1); py = MIN(roundint(y / scale_y), height - 1); pixel = gdk_image_get_pixel(image, px, py); gdk_image_put_pixel(new_image, x, y, pixel); } } /* draw the image into a new pixmap */ gdk_draw_image(new_bitmap,gc,new_image,0,0,0,0,new_width,new_height); gdk_image_destroy(image); gdk_image_destroy(new_image); gdk_gc_unref(gc); return new_bitmap; }