コード例 #1
1
gboolean switcher_button_on_expose(SwitcherButton *self, GdkEventExpose *event, gpointer data)
{
    GdkGC *gc = gdk_gc_new(GTK_WIDGET(self)->window);

    GdkPixbuf *icon = self->priv->current == 0 ? self->priv->icon0 : self->priv->icon1;
    if (icon == 0)
    {
        return TRUE;
    }

    int x = GTK_WIDGET(self)->allocation.x + (GTK_WIDGET(self)->allocation.width - gdk_pixbuf_get_width(icon)) / 2;
    int y = GTK_WIDGET(self)->allocation.y + (GTK_WIDGET(self)->allocation.height - gdk_pixbuf_get_height(icon)) / 2;

    gdk_draw_pixbuf(GTK_WIDGET(self)->window, gc,
        icon,
        0, 0, x, y, -1, -1,
        GDK_RGB_DITHER_NORMAL, 0, 0);

    if (self->priv->locked)
    {
        gdk_draw_pixbuf(GTK_WIDGET(self)->window, gc,
            self->priv->lock,
            0, 0, x, y, -1, -1,
            GDK_RGB_DITHER_NORMAL, 0, 0);
    }

    g_object_unref(gc);

    return TRUE;
}
コード例 #2
0
static void
redraw_viewer(void)
{
  flush_gdk_buffers();

  if (v_disparity_buffer)
  {
    gdk_draw_pixbuf(drawing_area->window,
        drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
        GDK_PIXBUF(v_disparity_buffer), 0, 0, 0, 0,
        v_disparity_map->width,
        drawing_area->allocation.height,
        GDK_RGB_DITHER_NONE, 0, 0);
  }

  if (road_profile_buffer)
  {
    gdk_draw_pixbuf(drawing_area->window,
        drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
        GDK_PIXBUF(road_profile_buffer), 0, 0, v_disparity_map->width + 10, 0,
        road_profile_image->width,
        drawing_area->allocation.height,
        GDK_RGB_DITHER_NONE, 0, 0);
  }

  if (right_buffer)
  {
    gdk_draw_pixbuf(drawing_area->window,
        drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
        GDK_PIXBUF(right_buffer), 0, 0,  v_disparity_map->width + road_profile_image->width + 20, 0,
        right_image->width,
        drawing_area->allocation.height,
        GDK_RGB_DITHER_NONE, 0, 0);
  }
}
コード例 #3
0
ファイル: playercam.c プロジェクト: Arkapravo/Player-3.0.2
gint
render_camera(gpointer data)
{
  GdkPixbuf *pixbuf = NULL;
  GdkPixbuf *blobbuf= NULL;
  GdkGC         *gc = NULL;
  GtkWidget *drawing_area = GTK_WIDGET(data);
  uint16_t i;

  gc = GTK_WIDGET(drawing_area)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(drawing_area))];

  player_update();

  if (g_blob_count > 0)
  {
    // Draw the blobs
    blobbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 1, 1);
    for (i=0; i< g_blob_count; ++i)
    {
      // shift the color by 8-bits to account for the alpha channel
      gdk_pixbuf_fill(blobbuf, g_blobs[i].color << 8);

      gdk_pixbuf_composite(blobbuf,
                           g_pixbuf,
                           g_blobs[i].left,
                           g_blobs[i].top,
                           abs(g_blobs[i].right - g_blobs[i].left),
                           abs(g_blobs[i].top   - g_blobs[i].bottom),
                           1, 1, 1, 1, GDK_INTERP_NEAREST, 128);
    }
    gdk_pixbuf_unref(blobbuf);
  }

  // scale everything at the end
  if ((g_width==g_window_width)&&(g_height==g_window_height))
  { // we don't need to worry about scaling
    gdk_draw_pixbuf(GTK_WIDGET(drawing_area)->window, gc,
                    g_pixbuf, 0, 0, 0, 0, g_width, g_height,
                    GDK_RGB_DITHER_NONE, 0, 0);
  }
  else
  {
    pixbuf = gdk_pixbuf_scale_simple(g_pixbuf, g_window_width,
                                     g_window_height, GDK_INTERP_BILINEAR);
    gdk_draw_pixbuf(GTK_WIDGET(drawing_area)->window, gc,
                    pixbuf, 0, 0, 0, 0, g_window_width, g_window_height,
                    GDK_RGB_DITHER_NONE, 0, 0);
    gdk_pixbuf_unref(pixbuf);
  }

  return TRUE;
}
コード例 #4
0
ファイル: explorer.c プロジェクト: ain101/Fyre
static void
update_image_preview (GtkFileChooser *chooser, GtkImage *image) {
    GdkPixbuf *image_pixbuf, *temp;
    static GdkPixbuf *emblem_pixbuf = NULL;
    gchar *filename;
    GdkPixmap *pixmap;
    gint width, height;

    if (emblem_pixbuf == NULL) {
	emblem_pixbuf = gdk_pixbuf_new_from_file (FYRE_DATADIR "/metadata-emblem.png", NULL);
	if (!emblem_pixbuf)
	    emblem_pixbuf = gdk_pixbuf_new_from_file (BR_DATADIR ("/fyre/metadata-emblem.png"), NULL);
    }

    filename = gtk_file_chooser_get_filename (chooser);
    if (filename == NULL) {
	gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
	return;
    }

    image_pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 112, 112, NULL);
    if (image_pixbuf == NULL) {
	gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
	return;
    }
    width = gdk_pixbuf_get_width (image_pixbuf);
    height = gdk_pixbuf_get_height (image_pixbuf);

    pixmap = gdk_pixmap_new (GTK_WIDGET (image)->window, width + 16, height + 16, -1);
    gdk_draw_rectangle (pixmap, GTK_WIDGET (image)->style->bg_gc[GTK_STATE_NORMAL], TRUE, 0, 0, width + 16, height + 16);
    gdk_draw_pixbuf (pixmap, NULL, image_pixbuf, 0, 0, 0, 0, width - 1, height - 1, GDK_RGB_DITHER_NONE, 0, 0);

    temp = gdk_pixbuf_new_from_file (filename, NULL);
    if (temp) {
        if (gdk_pixbuf_get_option (temp, "tEXt::fyre_params"))
            gdk_draw_pixbuf (pixmap, NULL, emblem_pixbuf, 0, 0, width - 16, height - 16, 31, 31, GDK_RGB_DITHER_NONE, 0, 0);
        else if (gdk_pixbuf_get_option (temp, "tEXt::de_jong_params"))
            gdk_draw_pixbuf (pixmap, NULL, emblem_pixbuf, 0, 0, width - 16, height - 16, 31, 31, GDK_RGB_DITHER_NONE, 0, 0);
        gdk_pixbuf_unref (temp);
    }

    if (image_pixbuf)
	gdk_pixbuf_unref (image_pixbuf);

    gtk_image_set_from_pixmap (GTK_IMAGE (image), pixmap, NULL);
    gdk_pixmap_unref (pixmap);
    gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
}
コード例 #5
0
static void
end_drawing_operation (struct graphics2d * gr)
{
  if (gr->drawbuf)
    { 
      gint drawable_width, drawable_height;
      gint pixbuf_width, pixbuf_height;
      gint width, height;
      
      gdk_drawable_get_size (gr->drawable, &drawable_width, &drawable_height);
      pixbuf_width = gdk_pixbuf_get_width (gr->drawbuf);
      pixbuf_height = gdk_pixbuf_get_height (gr->drawbuf);
      width = min (drawable_width, pixbuf_width);
      height = min (drawable_height, pixbuf_height);

      gdk_draw_pixbuf (gr->drawable, NULL, gr->drawbuf,
		       0, 0, 0, 0, 
		       width, height, 
		       GDK_RGB_DITHER_NORMAL, 0, 0);

      if (gr->debug) printf ("copied (%d, %d) pixels from pixbuf to GDK drawable\n",
			     width, height);
    }
  gdk_threads_leave ();
}
コード例 #6
0
ファイル: tab_nav.c プロジェクト: dss91/omgps
static void draw_skymap_fg(GdkDrawable *canvas)
{
	#define DEG_TO_RAD 		(M_PI / 180)
	#define IMG_SIZE 		15
	#define IMG_SIZE_HALF 	7

	int i;
	svinfo_channel_t *sv;
	int r, x, y;
	double deg;
	XPM_ID_T xpm_id;
	int center_x = da_width >> 1;
	int center_y = da_height >> 1;

	for (i=0; i<g_gpsdata.sv_channel_count; i++) {
		sv = &g_gpsdata.sv_channels[i];
		if (sv->elevation >= 0 && sv->azimuth >= 0) {
			r = bg_image_r * (1.0 - sv->elevation / 90.0);
			deg = sv->azimuth * DEG_TO_RAD;
			x = center_x + r * sin(deg);
			y = center_y - r * cos(deg);

			if (sv->flags & 0x01)
				xpm_id = XPM_ID_SV_IN_USE;
			else if (sv->cno > 0)
				xpm_id = XPM_ID_SV_SIGNAL;
			else
				xpm_id = XPM_ID_SV_NO_SIGNAL;

			gdk_draw_pixbuf(canvas, g_context.skymap_gc, g_xpm_images[xpm_id].pixbuf,
				0, 0, x - IMG_SIZE_HALF, y - IMG_SIZE_HALF, IMG_SIZE, IMG_SIZE, GDK_RGB_DITHER_NONE, -1, -1);
		}
	}
}
コード例 #7
0
void backend_gtk_redraw( gpointer _data )
{
   struct backend_data *data = _data;

   if( ( data->format.size.width == data->output_width ) &&
       ( data->format.size.height == data->output_height ) )
   {
      if( data->image_data[ data->current_buffer ] )
      {
	 gdk_draw_rgb_image( data->overlay_window, 
			     data->overlay_gc, 
			     data->crop_x, data->crop_y, 
			     data->crop_w, data->crop_h, 
			     GDK_RGB_DITHER_NONE, 
			     data->image_data[ data->current_buffer ], 
			     data->format.size.width * 3 );      
      }
   }
   else
   {
      if( data->pixbuf )
      {
	 gdk_draw_pixbuf( data->overlay_window, 
			  data->overlay_gc, 
			  data->pixbuf, 
			  0, 0, 
			  0, 0, 
			  -1, -1, 
			  GDK_RGB_DITHER_NONE, 
			  0, 0 );
      }
   }  
}
コード例 #8
0
		void CDisplayCueImage::drawCuePicture(OpenViBE::uint32 uint32CueID)
		{
			gint l_iWindowWidth = m_pDrawingArea->allocation.width;
			gint l_iWindowHeight = m_pDrawingArea->allocation.height;

			if(m_bFullScreen)
			{
				gdk_draw_pixbuf(m_pDrawingArea->window, NULL, m_pScaledPicture[uint32CueID], 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
			}
			else
			{
				gint l_iX = (l_iWindowWidth/2) - gdk_pixbuf_get_width(m_pScaledPicture[uint32CueID])/2;
				gint l_iY = (l_iWindowHeight/2) - gdk_pixbuf_get_height(m_pScaledPicture[uint32CueID])/2;;
				gdk_draw_pixbuf(m_pDrawingArea->window, NULL, m_pScaledPicture[uint32CueID], 0, 0, l_iX, l_iY, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
			}
		}
コード例 #9
0
/**
 * draw_tile_pixmap
 * @tileno: Graphics tile number
 * @pno: Number of graphics set
 * @x: x position in grid squares
 * @y: y position in grid squares
 * @area: Pointer to drawing area widget
 *
 * Description:
 * Draws tile pixmap @tileno from graphics set @pno at (@x, @y) in
 * a widget @area
 **/
void
draw_tile_pixmap (gint tileno, gint x, gint y, GtkWidget * area)
{
  GdkGC *bg;

  if ((x & 1) ^ (y & 1)) {
    bg = dark_bggc;
  } else {
    bg = light_bggc;
  }

  x *= tile_width;
  y *= tile_height;

  gdk_draw_rectangle (area->window, bg, TRUE, x, y, tile_width, tile_height);

  if (rerender_needed)
    render_graphics ();

  if ((tileno < 0) || (tileno >= SCENARIO_PIXMAP_WIDTH)) {
    /* nothing */
  } else {
    gdk_draw_pixbuf (area->window, area->style->black_gc,
		     theme_pixbuf,
		     tileno * tile_width, 0,
		     x, y, tile_width, tile_height,
		     GDK_RGB_DITHER_NORMAL, 0, 0);
  }
}
コード例 #10
0
static void
end_drawing_operation (struct graphics2d * gr)
{
  g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
  if (gr->drawbuf)
    { 
      gint drawable_width, drawable_height;
      gint pixbuf_width, pixbuf_height;
      gint width, height;
      
      gdk_drawable_get_size (gr->drawable, &drawable_width, &drawable_height);
      pixbuf_width = gdk_pixbuf_get_width (gr->drawbuf);
      pixbuf_height = gdk_pixbuf_get_height (gr->drawbuf);
      width = min (drawable_width, pixbuf_width);
      height = min (drawable_height, pixbuf_height);

      gdk_draw_pixbuf (gr->drawable, NULL, gr->drawbuf,
		       0, 0, 0, 0, 
		       width, height, 
		       GDK_RGB_DITHER_NORMAL, 0, 0);

      if (gr->debug) printf ("copied (%d, %d) pixels from pixbuf to GDK drawable\n",
			     width, height);
    }
}
コード例 #11
0
/**
 * gdk_pixbuf_draw_cache_draw:
 * @cache: a #GdkPixbufDrawCache
 * @opts: the #GdkPixbufDrawOpts to use in this draw
 * @drawable: a #GdkDrawable to draw on
 *
 * Redraws the area specified in the pixbuf draw options in an
 * efficient way by using caching.
 **/
void
gdk_pixbuf_draw_cache_draw (GdkPixbufDrawCache *cache,
                            GdkPixbufDrawOpts  *opts,
                            GdkDrawable        *drawable)
{
    GdkRectangle this = opts->zoom_rect;
    GdkPixbufDrawMethod method =
        gdk_pixbuf_draw_cache_get_method (&cache->old, opts);
    int deltax = 0;
    int deltay = 0;
    if (method == GDK_PIXBUF_DRAW_METHOD_CONTAINS)
    {
        deltax = this.x - cache->old.zoom_rect.x;
        deltay = this.y - cache->old.zoom_rect.y;
    }
    else if (method == GDK_PIXBUF_DRAW_METHOD_SCROLL)
    {
        gdk_pixbuf_draw_cache_intersect_draw (cache, opts, drawable);
    }
    else if (method == GDK_PIXBUF_DRAW_METHOD_SCALE)
    {
        int last_width = gdk_pixbuf_get_width (cache->last_pixbuf);
        int last_height = gdk_pixbuf_get_height (cache->last_pixbuf);
        GdkColorspace new_cs = gdk_pixbuf_get_colorspace (opts->pixbuf);
        GdkColorspace last_cs =
            gdk_pixbuf_get_colorspace (cache->last_pixbuf);
        int new_bps = gdk_pixbuf_get_bits_per_sample (opts->pixbuf);
        int last_bps = gdk_pixbuf_get_bits_per_sample (cache->last_pixbuf);
        
        if (this.width > last_width || this.height > last_height ||
            new_cs != last_cs || new_bps != last_bps)
        {
            g_object_unref (cache->last_pixbuf);
            cache->last_pixbuf = gdk_pixbuf_new (new_cs, FALSE, new_bps,
                                                  this.width, this.height);
        }
        
        gdk_pixbuf_scale_blend (opts->pixbuf,
                                cache->last_pixbuf,
                                0, 0,
                                this.width, this.height,
                                (double) -this.x, (double) -this.y,
                                opts->zoom,
                                opts->interp,
                                this.x, this.y,
                                cache->check_size,
                                opts->check_color1,
                                opts->check_color2);
    }
    gdk_draw_pixbuf (drawable,
                     NULL,
                     cache->last_pixbuf,
                     deltax, deltay,
                     opts->widget_x, opts->widget_y,
                     this.width, this.height,
                     GDK_RGB_DITHER_MAX,
                     opts->widget_x, opts->widget_y);
    if (method != GDK_PIXBUF_DRAW_METHOD_CONTAINS)
        cache->old = *opts;
}
コード例 #12
0
ファイル: mapview.c プロジェクト: Fyb3roptik/freeciv-web
/**************************************************************************
...
**************************************************************************/
void pixmap_put_overlay_tile(GdkDrawable *pixmap,
			     int canvas_x, int canvas_y,
			     struct sprite *ssprite)
{
  if (!ssprite) {
    return;
  }

  if (ssprite->pixmap) {
    gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
    gdk_gc_set_clip_mask(civ_gc, ssprite->mask);

    gdk_draw_drawable(pixmap, civ_gc, ssprite->pixmap,
		      0, 0,
		      canvas_x, canvas_y,
		      ssprite->width, ssprite->height);
    gdk_gc_set_clip_mask(civ_gc, NULL);
  } else {
    gdk_draw_pixbuf(pixmap, civ_gc, ssprite->pixbuf,
		    0, 0,
		  canvas_x, canvas_y,
		  ssprite->width, ssprite->height,
		  GDK_RGB_DITHER_NONE, 0, 0);
  }
}
コード例 #13
0
//__________________________________________________________________
void _HYPlatformGraphicPane::_SlidePane  (int dv, int dh)
{
	_HYGraphicPane* theParent = (_HYGraphicPane*)this;
	GdkPixbuf* theImage = gdk_pixbuf_get_from_drawable (NULL, thePane, NULL, 0, 0, 0, 0, -1, -1);
	gdk_draw_pixbuf (thePane, NULL, theImage, 0,0, dh, dv, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
	g_object_unref (theImage);
}
コード例 #14
0
ファイル: mypixmap.c プロジェクト: victorbarna/xfwm4_tiling
gboolean
xfwmPixmapRenderGdkPixbuf (xfwmPixmap * pm, GdkPixbuf *pixbuf)
{
    GdkPixbuf *src;
    GdkPixmap *destw;
    GdkVisual *gvisual;
    GdkColormap *cmap;
    gint width, height;
    gint dest_x, dest_y;

    g_return_val_if_fail (pm != NULL, FALSE);
    g_return_val_if_fail (pm->pixmap != None, FALSE);
    g_return_val_if_fail (pm->mask != None, FALSE);

    destw = gdk_xid_table_lookup (pm->pixmap);
    if (destw)
    {
        g_object_ref (G_OBJECT (destw));
    }
    else
    {
        destw = gdk_pixmap_foreign_new (pm->pixmap);
    }

    if (!destw)
    {
        g_warning ("Cannot get pixmap");
        return FALSE;
    }

    gvisual = gdk_screen_get_system_visual (pm->screen_info->gscr);
    cmap = gdk_x11_colormap_foreign_new (gvisual, pm->screen_info->cmap);

    if (!cmap)
    {
        g_warning ("Cannot create colormap");
        g_object_unref (destw);
        return FALSE;
    }

    width = MIN (gdk_pixbuf_get_width (pixbuf), pm->width);
    height = MIN (gdk_pixbuf_get_height (pixbuf), pm->height);

    /* Add 1 for rounding */
    dest_x = (pm->width - width + 1) / 2;
    dest_y = (pm->height - height + 1) / 2;

    src = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE (destw), cmap,
                                       dest_x, dest_y, 0, 0, width, height);
    gdk_pixbuf_composite (pixbuf, src, 0, 0, width, height,
                          0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, 0xFF);
    gdk_draw_pixbuf (GDK_DRAWABLE (destw), NULL, src, 0, 0, dest_x, dest_y,
                     width, height, GDK_RGB_DITHER_NONE, 0, 0);

    g_object_unref (cmap);
    g_object_unref (src);
    g_object_unref (destw);

    return TRUE;
}
コード例 #15
0
ファイル: yuiviewer.c プロジェクト: GPDP2/yabause
static void yui_viewer_expose(GtkWidget * widget, GdkEventExpose *event, gpointer data) {
    YuiViewer * yv = YUI_VIEWER(widget);

    if (yv->pixbuf != NULL) {
        gdk_draw_pixbuf(widget->window, NULL, yv->pixbuf, 0, 0, 0, 0, yv->w, yv->h, GDK_RGB_DITHER_NONE, 0, 0);
    }
}
コード例 #16
0
ファイル: immerse.c プロジェクト: cbuehler/gwyddion
static gboolean
immerse_view_expose(GtkWidget *view,
                    GdkEventExpose *event,
                    ImmerseControls *controls)
{
    if (event->count > 0)
        return FALSE;

    if (controls->detail) {
        GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
        GdkGC *gc;
        gint w, h, xoff, yoff;

        gwy_data_view_coords_real_to_xy(GWY_DATA_VIEW(view),
                                        controls->args->xpos,
                                        controls->args->ypos,
                                        &xoff, &yoff);
        w = gdk_pixbuf_get_width(controls->detail);
        h = gdk_pixbuf_get_height(controls->detail);
        /* gwy_debug("(%d,%d) %dx%d", xoff, yoff, w, h); */
        gc = gdk_gc_new(view->window);
        gdk_draw_pixbuf(view->window, gc, controls->detail,
                        0, 0, xoff, yoff, w, h,
                        GDK_RGB_DITHER_NORMAL, 0, 0);
        if (controls->args->draw_frame) {
            gdk_gc_set_function(gc, GDK_XOR);
            gdk_gc_set_rgb_fg_color(gc, &white);
            gdk_draw_rectangle(view->window, gc, FALSE, xoff, yoff, w-1, h-1);
        }
        g_object_unref(gc);
    }

    return FALSE;
}
コード例 #17
0
ファイル: mt_gtk2.c プロジェクト: AOSC-Dev/metatheme
static void _mt_draw_image(MT_WINDOW *win, MT_GC *gc, MT_IMAGE *img, int xsrc, int ysrc, int wsrc, int hsrc, int xdest, int ydest, int width, int height)
{
   GdkPixbuf *pixbuf = (GdkPixbuf *)img;
   GdkPixbuf *pixbuf2 = NULL;

   /* scale if needed: */
   if (wsrc != width || hsrc != height) {
      double scale_x = (double)width / (double)wsrc;
      double scale_y = (double)height / (double)hsrc;

      pixbuf2 = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
      gdk_pixbuf_scale(pixbuf, pixbuf2, 0, 0, width, height, -xsrc * scale_x, -ysrc * scale_y, scale_x, scale_y, GDK_INTERP_NEAREST);
      pixbuf = pixbuf2;
      xsrc = 0;
      ysrc = 0;
   }

   _set_clipping(gc);
   gdk_draw_pixbuf((GdkWindow *)win, ((MT_GTK_GC *)gc)->gc, pixbuf, xsrc, ysrc, xdest, ydest, width, height, GDK_RGB_DITHER_NONE, 0, 0);
   _unset_clipping(gc);

   if (pixbuf2) {
      gdk_pixbuf_unref(pixbuf2);
   }
}
コード例 #18
0
ファイル: ctkbanner.c プロジェクト: jethrogb/nvidia-utils
static gboolean ctk_banner_expose_event(
    GtkWidget *widget,
    GdkEventExpose *event
)
{
    CtkBanner *ctk_banner = CTK_BANNER(widget);
    GdkRectangle *rects;
    int n_rects;
    int i;

    /* copy the backing pixbuf into the exposed portion of the window */

    gdk_region_get_rectangles(event->region, &rects, &n_rects);

    for (i = 0; i < n_rects; i++) {
        gdk_draw_pixbuf(widget->window,
                        widget->style->fg_gc[GTK_STATE_NORMAL],
                        ctk_banner->back.pixbuf,
                        rects[i].x, rects[i].y,
                        rects[i].x, rects[i].y,
                        rects[i].width, rects[i].height,
                        GDK_RGB_DITHER_NORMAL, 0, 0);
    }

    g_free(rects);

    return FALSE;
}
コード例 #19
0
ファイル: toolbar.cpp プロジェクト: GuyXY/wxWidgets
image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool)
#endif
{
    const wxBitmap& bitmap = tool->GetDisabledBitmap();
    if (tool->IsEnabled() || !bitmap.IsOk())
        return false;

    // draw disabled bitmap ourselves, GtkImage has no way to specify it
    GtkAllocation alloc;
    gtk_widget_get_allocation(widget, &alloc);
    GtkRequisition req;
    gtk_widget_get_requisition(widget, &req);
#ifdef __WXGTK3__
    const int x = (alloc.width - req.width) / 2;
    const int y = (alloc.height - req.height) / 2;
    bitmap.Draw(cr, x, y);
#else
    const int x = alloc.x + (alloc.width - req.width) / 2;
    const int y = alloc.y + (alloc.height - req.height) / 2;
    gdk_draw_pixbuf(
        gtk_widget_get_window(widget), gtk_widget_get_style(widget)->black_gc, bitmap.GetPixbuf(),
        0, 0, x, y,
        -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0);
#endif
    return true;
}
コード例 #20
0
ファイル: bg.c プロジェクト: BackupTheBerlios/fbpanel-svn
void
fb_bg_composite(GdkDrawable *base, GdkGC *gc, guint32 tintcolor, gint alpha)
{
    GdkPixbuf *ret, *ret2;
    int w, h;
    static GdkColormap *cmap = NULL;
    
    ENTER;
    gdk_drawable_get_size (base, &w, &h);
    if (!cmap) {
        cmap = gdk_colormap_get_system ();
    }
    DBG("here\n");
    ret = gdk_pixbuf_get_from_drawable (NULL, base, cmap, 0, 0, 0, 0, w, h);
    if (!ret)
        RET();
    DBG("here w=%d h=%d\n", w, h);
    ret2 = gdk_pixbuf_composite_color_simple(ret, w, h, 
          GDK_INTERP_HYPER, 255-alpha, MIN(w, h), tintcolor, tintcolor);
    DBG("here\n");
    if (!ret2) {
        g_object_unref(ret);
        RET();
    }
    //gdk_pixbuf_render_to_drawable (ret2, base, gc, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0);
    gdk_draw_pixbuf (base, gc, ret2, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0);
    g_object_unref(ret);
    g_object_unref(ret2);
    RET();
}
コード例 #21
0
ファイル: ui.c プロジェクト: AlexWillisson/metacity-physics
void
meta_image_window_set (MetaImageWindow *iw,
                       GdkPixbuf       *pixbuf,
                       int              x,
                       int              y)
{
  /* We use a back pixmap to avoid having to handle exposes, because
   * it's really too slow for large clients being minimized, etc.
   * and this way flicker is genuinely zero.
   */

  gdk_draw_pixbuf (iw->pixmap,
                   iw->window->style->black_gc,
		   pixbuf,
                   0, 0,
                   0, 0,
                   gdk_pixbuf_get_width (pixbuf),
                   gdk_pixbuf_get_height (pixbuf),
                   GDK_RGB_DITHER_NORMAL,
                   0, 0);

  gdk_window_set_back_pixmap (iw->window->window,
                              iw->pixmap,
                              FALSE);
  
  gdk_window_move_resize (iw->window->window,
                          x, y,
                          gdk_pixbuf_get_width (pixbuf),
                          gdk_pixbuf_get_height (pixbuf));

  gdk_window_clear (iw->window->window);
}
コード例 #22
0
ファイル: mt_gtk2.c プロジェクト: AOSC-Dev/metatheme
static void _mt_cairo_end_pixbuf(MT_TOOLKIT *mt, cairo_t *cr)
{
   guchar *p, *p0;
   int i,j,rowstride,tmp;
   MT_GC *gc;
   MT_COLOR col;

   cairo_destroy(cr);

   p0 = gdk_pixbuf_get_pixels(_cairo_buf);
   rowstride = gdk_pixbuf_get_rowstride(_cairo_buf);

   /* swap R and B, also set proper alpha: */
   for (i=0; i<_cairo_rect.height; i++) {
      p = p0 + i*rowstride;
      for (j=0; j<_cairo_rect.width; j++) {
         tmp = p[0];
         p[0] = p[2];
         p[2] = tmp;
         p[3] = 255;
         p += 4;
      }
   }

   mt_color_set(col, 0, 0, 0);
   gc = _mt_gc_new_with_foreground(&col);
   gdk_draw_pixbuf(_cairo_win, ((MT_GTK_GC *)gc)->gc, _cairo_buf, 0, 0, _cairo_rect.x, _cairo_rect.y, _cairo_rect.width, _cairo_rect.height, GDK_RGB_DITHER_NONE, 0, 0);
   _mt_gc_destroy(gc);

   cairo_surface_destroy(_cairo_surface);
   _mt_image_destroy(_cairo_buf);
}
コード例 #23
0
ファイル: mapview.c プロジェクト: longturn/freeciv-S2_5
/**************************************************************************
Only used for isometric view.
**************************************************************************/
void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
				  int canvas_x, int canvas_y,
				  struct sprite *ssprite,
				  bool fog)
{
  if (!ssprite) {
    return;
  }

  if (fog && gui_gtk2_better_fog
      && ((ssprite->pixmap && !ssprite->pixmap_fogged)
	  || (!ssprite->pixmap && !ssprite->pixbuf_fogged))) {
    fog_sprite(ssprite);
    if ((ssprite->pixmap && !ssprite->pixmap_fogged)
        || (!ssprite->pixmap && !ssprite->pixbuf_fogged)) {
      log_normal(_("Better fog will only work in truecolor. Disabling it"));
      gui_gtk2_better_fog = FALSE;
    }
  }

  if (fog && gui_gtk2_better_fog) {
    if (ssprite->pixmap) {
      if (ssprite->mask) {
	gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
	gdk_gc_set_clip_mask(civ_gc, ssprite->mask);
      }
      gdk_draw_drawable(pixmap, civ_gc,
			ssprite->pixmap_fogged,
			0, 0,
			canvas_x, canvas_y,
			ssprite->width, ssprite->height);
      gdk_gc_set_clip_mask(civ_gc, NULL);
    } else {
      gdk_draw_pixbuf(pixmap, civ_gc, ssprite->pixbuf_fogged,
		      0, 0, canvas_x, canvas_y, 
		      ssprite->width, ssprite->height,
		      GDK_RGB_DITHER_NONE, 0, 0);
    }
    return;
  }

  pixmap_put_sprite(pixmap, canvas_x, canvas_y, ssprite,
		    0, 0, ssprite->width, ssprite->height);

  /* I imagine this could be done more efficiently. Some pixels We first
     draw from the sprite, and then draw black afterwards. It would be much
     faster to just draw every second pixel black in the first place. */
  if (fog) {
    gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
    gdk_gc_set_clip_mask(fill_tile_gc, sprite_get_mask(ssprite));
    gdk_gc_set_foreground(fill_tile_gc,
			  &get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color);
    gdk_gc_set_ts_origin(fill_tile_gc, canvas_x, canvas_y);
    gdk_gc_set_stipple(fill_tile_gc, black50);

    gdk_draw_rectangle(pixmap, fill_tile_gc, TRUE,
		       canvas_x, canvas_y, ssprite->width, ssprite->height);
    gdk_gc_set_clip_mask(fill_tile_gc, NULL);
  }
}
コード例 #24
0
ファイル: gdkpixbuf-render.c プロジェクト: Aridna/gtk2
/**
 * gdk_pixbuf_render_pixmap_and_mask_for_colormap:
 * @pixbuf: A pixbuf.
 * @colormap: A #GdkColormap
 * @pixmap_return: Location to store a pointer to the created pixmap,
 *   or %NULL if the pixmap is not needed.
 * @mask_return: Location to store a pointer to the created mask,
 *   or %NULL if the mask is not needed.
 * @alpha_threshold: Threshold value for opacity values.
 *
 * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return
 * and @mask_return arguments, respectively, and renders a pixbuf and its
 * corresponding tresholded alpha mask to them.  This is merely a convenience
 * function; applications that need to render pixbufs with dither offsets or to
 * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha().
 *
 * The pixmap that is created uses the #GdkColormap specified by @colormap.
 * This colormap must match the colormap of the window where the pixmap
 * will eventually be used or an error will result.
 *
 * If the pixbuf does not have an alpha channel, then *@mask_return will be set
 * to %NULL.
 **/
void
gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf   *pixbuf,
						GdkColormap *colormap,
						GdkPixmap  **pixmap_return,
						GdkBitmap  **mask_return,
						int          alpha_threshold)
{
  GdkScreen *screen;

  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
  g_return_if_fail (GDK_IS_COLORMAP (colormap));

  screen = gdk_colormap_get_screen (colormap);
  
  if (pixmap_return)
    {
      GdkGC *gc;
      *pixmap_return = gdk_pixmap_new (gdk_screen_get_root_window (screen),
				       gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
				       gdk_colormap_get_visual (colormap)->depth);

      gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap);
      gc = _gdk_drawable_get_scratch_gc (*pixmap_return, FALSE);

      /* If the pixbuf has an alpha channel, using gdk_pixbuf_draw would give
       * random pixel values in the area that are within the mask, but semi-
       * transparent. So we treat the pixbuf like a pixbuf without alpha channel;
       * see bug #487865.
       */
      if (gdk_pixbuf_get_has_alpha (pixbuf))
        gdk_draw_rgb_32_image (*pixmap_return, gc,
                               0, 0,
                               gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
                               GDK_RGB_DITHER_NORMAL,
                               gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_rowstride (pixbuf));
      else
        gdk_draw_pixbuf (*pixmap_return, gc, pixbuf, 
                         0, 0, 0, 0,
                         gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
                         GDK_RGB_DITHER_NORMAL,
                         0, 0);
    }
  
  if (mask_return)
    {
      if (gdk_pixbuf_get_has_alpha (pixbuf))
	{
	  *mask_return = gdk_pixmap_new (gdk_screen_get_root_window (screen),
					 gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), 1);

	  gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return,
					     0, 0, 0, 0,
					     gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
					     alpha_threshold);
	}
      else
	*mask_return = NULL;
    }
}
コード例 #25
0
ファイル: graphics_opengl.c プロジェクト: justinzane/navit
static void
draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
{
#if 0
	gdk_draw_pixbuf(gr->drawable, fg->gc, img->pixbuf, 0, 0, p->x, p->y,
		    img->w, img->h, GDK_RGB_DITHER_NONE, 0, 0);
#endif
}
コード例 #26
0
ファイル: HYPlatformWindow.cpp プロジェクト: mdsmith/OCLHYPHY
//__________________________________________________________________
void		_PaintTheCircle (GdkPixbuf * theIcon, GtkWidget * theWindow)
{
    if (GTK_WIDGET_MAPPED (theWindow) && GDK_IS_PIXBUF (theIcon))
        gdk_draw_pixbuf (theWindow->window, nil, theIcon, 0,0,
                         theWindow->allocation.x + 3,
                         theWindow->allocation.y+theWindow->allocation.height - 13,
                         -1,-1, GDK_RGB_DITHER_NONE, 0, 0);
}
コード例 #27
0
static void redraw_viewer(void)
{
  gdk_draw_pixbuf(drawing_area->window,
                  drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
                  map_buffer, 0, 0, 0, 0,
                  drawing_area->allocation.width,
                  drawing_area->allocation.height,
                  GDK_RGB_DITHER_NONE, 0, 0);
}
コード例 #28
0
//__________________________________________________________________
void _HYPlatformGraphicPane::_InvertRect (_HYRect& rct)
{
	GdkRectangle clip_rect = HYRect2GDKRect (rct);
	GdkPixbuf* theImage = gdk_pixbuf_get_from_drawable (NULL, thePane, NULL, rct.left, rct.top, 0, 0, clip_rect.width, clip_rect.height);
	gdk_gc_set_function (theContext,GDK_INVERT);
	gdk_draw_pixbuf (thePane, theContext, theImage, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
	gdk_gc_set_function (theContext,GDK_COPY);
	g_object_unref (theImage);
}
コード例 #29
0
ファイル: vikviewport.c プロジェクト: gdt/viking
void vik_viewport_draw_pixbuf ( VikViewport *vvp, GdkPixbuf *pixbuf, gint src_x, gint src_y,
                              gint dest_x, gint dest_y, gint w, gint h )
{
  gdk_draw_pixbuf ( vvp->scr_buffer,
                    NULL,
                    pixbuf,
                    src_x, src_y, dest_x, dest_y, w, h,
                    GDK_RGB_DITHER_NONE, 0, 0 );
}
コード例 #30
0
ファイル: main.cpp プロジェクト: Varhoo/Fingerpaint
   /* draw to video canvas */
   static void video (
         GtkWidget      *widget,
         GdkEventExpose *eev){

      //gtk_widget_queue_draw(GTK_WIDGET(widget));

      if(!start) return;

      if(cv_image!=NULL){

        double t =  microtime();

        /* vypsání ladícího textu */
        CvFont font;
        double hScale=0.5;
        double vScale=0.5;
        int lineWidth=1;
        char buffer[125];

        cvFlip(cv_image, cv_image, 1);

         cvInitFont(&font,CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC, hScale, vScale, 0, lineWidth);
         sprintf(buffer,"Treshold %d/255 [key m,n]", treshold);
         cvPutText (cv_image, buffer, cvPoint(10, 20), &font, cvScalar(0, 255, 0));
         cvLine(cv_image, cvPoint(260,15), cvPoint(260 + treshold,15), cvScalar(0, 255, 0), 10, 4);

         sprintf(buffer,"Timer: %f | %f | %f | %f", timer[0], timer[1], timer[2], timer[3]);
         cvPutText (cv_image,buffer,cvPoint(10,40), &font, cvScalar(255, 0, 0));
         sprintf(buffer,"Fps: %d ", fps);
         cvPutText (cv_image,buffer,cvPoint(10,60), &font, cvScalar(255, 0, 0));

         //převedení opencv do gtk
         GdkPixbuf * pix = gdk_pixbuf_new_from_data(
               (guchar*)cv_image->imageData,
               GDK_COLORSPACE_RGB,
               FALSE,
               cv_image->depth,
               cv_image->width,
               cv_image->height,
               cv_image->widthStep,
               NULL,
               NULL);
          //gtkImg = gtk_image_new_from_pixbuf (pix);
         gdk_draw_pixbuf (widget->window,
                      widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                      pix,
                      0, 0, 0, 0, 640, 480, GDK_RGB_DITHER_NONE, 0, 0 );
         //gtk_widget_queue_draw(widget);
         gdk_pixbuf_unref (pix);
         
         timer[2] =  microtime() - t;
      } else {
         //printf("ERROR: Video nebylo načteno.\n");
      }

      currently_framing = 0;
   }