Пример #1
0
gboolean
launcher_clicked (GtkWidget *event_box, GdkEventButton *event, t_launcher *launcher)
{
	int size = 1.25 * launcher->quicklauncher->icon_size;
	if (event->button != 1)
		return FALSE;
	if (event->type == GDK_BUTTON_PRESS)
	{
		g_assert(launcher->zoomed_img);
		if(event->x < 0 || event->x > size || event->y < 0 || event->y > size)
			return FALSE;
		if (!launcher->clicked_img)
		{
			launcher->clicked_img = gdk_pixbuf_copy (launcher->zoomed_img);
			gdk_pixbuf_saturate_and_pixelate(launcher->zoomed_img, launcher->clicked_img, 5, TRUE);
		}
		gtk_image_set_from_pixbuf (GTK_IMAGE(launcher->image), launcher->clicked_img);
	}
	else if (event->type == GDK_BUTTON_RELEASE)
	{
		//g_assert(launcher->clicked_img);
		if (event->x > 0 && event->x < size && event->y > 0 && event->y < size)
			xfce_exec(launcher->command, FALSE, FALSE, NULL);
		gtk_image_set_from_pixbuf (GTK_IMAGE(launcher->image), launcher->def_img);
		gtk_container_set_border_width(GTK_CONTAINER (event_box),
										(int)launcher->quicklauncher->icon_size/8);
		//gtk_widget_set_size_request(launcher->image, size, size);
	}
	return TRUE;
}
Пример #2
0
/*! \brief Create and add picture OBJECT to list.
 *  \par Function Description
 *  This function creates a new object representing a picture.
 *
 *  The picture is described by its upper left corner - <B>x1</B>, <B>y1</B> -
 *  and its lower right corner - <B>x2</B>, <B>y2</B>.
 *  The <B>type</B> parameter must be equal to #OBJ_PICTURE. 
 *
 *  The #OBJECT structure is allocated with the #s_basic_init_object()
 *  function. The structure describing the picture is allocated and
 *  initialized with the parameters given to the function.
 *
 *  \param [in]     toplevel      The TOPLEVEL object.
 *  \param [in]     pixbuf        The GdkPixbuf picture to add.
 *                                A copy of this pixbuf is made.
 *  \param [in]     file_content  Raw data of the image file.
 *                                NULL for non embedded loading. The object
 *                                object takes ownership of this buffer, and it
 *                                should not be free'd by the caller.
 *  \param [in]     file_length   Length of raw data buffer
 *  \param [in]     filename      File name backing this picture.
 *                                A copy of this string is made.
 *  \param [in]     ratio         Picture height to width ratio.
 *  \param [in]     type          Must be OBJ_PICTURE.
 *  \param [in]     x1            Upper x coordinate.
 *  \param [in]     y1            Upper y coordinate.
 *  \param [in]     x2            Lower x coordinate.
 *  \param [in]     y2            Lower y coordinate.
 *  \param [in]     angle         Picture rotation angle.
 *  \param [in]     mirrored      Whether the image should be mirrored or not.
 *  \param [in]     embedded      Whether the embedded flag should be set or not.
 *  \return A pointer to the new end of the object list.
 */
OBJECT *o_picture_new(TOPLEVEL *toplevel, GdkPixbuf *pixbuf,
                      gchar *file_content, gsize file_length, char *filename,
                      double ratio, char type,
                      int x1, int y1, int x2, int y2, int angle, char mirrored,
                      char embedded)
{
  OBJECT *new_node;
  PICTURE *picture;

  /* create the object */
  new_node = s_basic_new_object(type, "picture");

  picture = (PICTURE *) g_malloc(sizeof(PICTURE));
  new_node->picture = picture;

  /* describe the picture with its upper left and lower right corner */
  picture->upper_x = x1;
  picture->upper_y = y1;
  picture->lower_x = x2;
  picture->lower_y = y2;

  picture->file_content = file_content;
  picture->file_length  = file_length;
  picture->filename = g_strdup (filename);
  picture->ratio = ratio;
  picture->pixbuf = gdk_pixbuf_copy (pixbuf);
  picture->angle = angle;
  picture->mirrored = mirrored;
  picture->embedded = embedded;

  /* compute the bounding picture */
  o_picture_recalc(toplevel, new_node);

  return new_node;
}
Пример #3
0
Sample*
sample_dup(Sample* s)
{
	Sample* r = g_new0(Sample, 1);

	r->id           = s->id;
	r->ref_count    = 0;
	r->sample_rate  = s->sample_rate;
	r->length       = s->length;
	r->frames       = s->frames;
	r->channels     = s->channels;
	r->bit_depth    = s->bit_depth;
	r->bit_rate     = s->bit_rate;
	r->peaklevel    = s->peaklevel;
	r->colour_index = s->colour_index;
	r->online       = s->online;
	r->mtime        = s->mtime;
#define DUPSTR(P) if (s->P) r->P = strdup(s->P);
	DUPSTR(sample_dir)
	DUPSTR(name)
	DUPSTR(full_path)
	DUPSTR(keywords)
	DUPSTR(ebur)
	DUPSTR(notes)
	DUPSTR(mimetype)
	r->meta_data = s->meta_data ? g_ptr_array_ref(s->meta_data) : NULL;

	if (s->overview) r->overview = gdk_pixbuf_copy(s->overview);
	sample_ref(r);
	return r;
}
Пример #4
0
static GdkPixbuf *
gamma_correct (const GdkPixbuf *input_pixbuf)
{
    gint x, y, width, height, rowstride;
    GdkPixbuf *output_pixbuf;
    guchar *pixels;

    output_pixbuf = gdk_pixbuf_copy (input_pixbuf);
    pixels = gdk_pixbuf_get_pixels (output_pixbuf);

    width = gdk_pixbuf_get_width (output_pixbuf);
    height = gdk_pixbuf_get_height (output_pixbuf);
    rowstride = gdk_pixbuf_get_rowstride (output_pixbuf);

    for (y = 0; y < height; y++)
        for (x = 0; x < width; x++)
        {
            guchar *alpha_channel;
            guchar opacity;

            alpha_channel = pixels + y * (rowstride / 4) + x + 3;
            opacity = (guchar) (255 * pow ((*alpha_channel / 255.0), 1.0 / GAMMA));

            *alpha_channel = opacity;
        }

    return output_pixbuf;
}
void stickynotes_applet_update_icon(StickyNotesApplet *applet)
{
	GdkPixbuf *pixbuf1, *pixbuf2;

	gint size = applet->panel_size;

        if (size > 3)
           size = size -3;

	/* Choose appropriate icon and size it */
	if (applet->prelighted)
	    	pixbuf1 = gdk_pixbuf_scale_simple(stickynotes->icon_prelight, size, size, GDK_INTERP_BILINEAR);
	else
	    	pixbuf1 = gdk_pixbuf_scale_simple(stickynotes->icon_normal, size, size, GDK_INTERP_BILINEAR);

	/* Shift the icon if pressed */
	pixbuf2 = gdk_pixbuf_copy(pixbuf1);
	if (applet->pressed)
		gdk_pixbuf_scale(pixbuf1, pixbuf2, 0, 0, size, size, 1, 1, 1, 1, GDK_INTERP_BILINEAR);

	/* Apply the finished pixbuf to the applet image */
	gtk_image_set_from_pixbuf(GTK_IMAGE(applet->w_image), pixbuf2);

	g_object_unref(pixbuf1);
	g_object_unref(pixbuf2);
}
Пример #6
0
static EIF_POINTER inline_F24_251 (EIF_POINTER arg1)
{
	#if GTK_MAJOR_VERSION > 1
	return gdk_pixbuf_copy ((GdkPixbuf*)arg1);
#endif
	;
}
Пример #7
0
static SheetObjectView *
gnm_soi_new_view (SheetObject *so, SheetObjectViewContainer *container)
{
	SheetObjectImage *soi = SHEET_OBJECT_IMAGE (so);
	GocItem *item = NULL;

	item = goc_item_new (
		gnm_pane_object_group (GNM_PANE (container)),
		so_image_goc_view_get_type (),
		NULL);
	if (soi->image) {
		goc_item_hide (goc_item_new (GOC_GROUP (item),
			GOC_TYPE_IMAGE,
			"image", soi->image,
		        "crop-bottom", soi->crop_bottom,
		        "crop-left", soi->crop_left,
		        "crop-right", soi->crop_right,
		        "crop-top", soi->crop_top,
			NULL));

	} else {
		GdkPixbuf *placeholder = go_gdk_pixbuf_load_from_file
			("res:gnm:pixmaps/unknown_image.png");
		GdkPixbuf *pixbuf = gdk_pixbuf_copy (placeholder);

		goc_item_hide (goc_item_new (GOC_GROUP (item),
			GOC_TYPE_PIXBUF,
			"pixbuf", pixbuf,
			NULL));
		g_object_unref (pixbuf);
		g_object_set_data (G_OBJECT (item), "tile", placeholder);
	}

	return gnm_pane_object_register (so, item, TRUE);
}
Пример #8
0
/**
 * gdk_pixbuf_new_from_theme:
 * @name: the icon name
 * @size: the pixel size
 *
 * Creates a new pixbuf image from the icon @name and @size.
 *
 * Returns: a new pixbuf, g_object_unref() when done.
 */
GdkPixbuf *
gdk_pixbuf_new_from_theme (const gchar * name, gint size)
{
  GdkPixbuf *pixbuf;
  GError *error = NULL;
  GtkIconTheme *it = gtk_icon_theme_get_default ();

  /* TODO(ensonic): docs recommend to listen to GtkWidget::style-set and update icon or
   * do gdk_pixbuf_copy() to avoid gtk keeping icon-theme loaded if it changes
   */
  if (!(pixbuf =
          gtk_icon_theme_load_icon (it, name, size,
              GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_FORCE_SIZE,
              &error))) {
    GST_WARNING ("Couldn't load %s %dx%d icon: %s", name, size, size,
        error->message);
    g_error_free (error);
    /* TODO(ensonic): machine icons are in 'gnome' theme, how can we use this as a
     * fallback
     * gtk_icon_theme_set_custom_theme(it,"gnome");
     * is a bit brutal
     */
    return gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size);
    //return NULL;
  } else {
    GdkPixbuf *result = gdk_pixbuf_copy (pixbuf);
    g_object_unref (pixbuf);
    return result;
  }
}
Пример #9
0
/* Auxiliary function - look for frame that's currently loading. */
static void
update_currently_loaded_frame (FrameData* frame)
{
    int tmp_count;

    if (gdk_pixbuf_animation_iter_on_currently_loading_frame(frame->iter))
        return; /* frame is currently being loaded */
    /* clear old content of pixbuf */
    if (frame->pixbuf)
        g_object_unref (frame->pixbuf);
    frame->pixbuf = NULL;

    tmp_count = 0;
    do {
        int delay_time;

        if (++tmp_count > MAX_NUMBER_FRAMES) {
            /* protection against frames repeating */
            return;
        }

        delay_time = gdk_pixbuf_animation_iter_get_delay_time (frame->iter);
        if (delay_time < 0) {
            /* this is last frame in the animation */
            return;
        }
        g_time_val_add (&frame->time, delay_time * 1000);
        gdk_pixbuf_animation_iter_advance (frame->iter, &frame->time);
    } while (!gdk_pixbuf_animation_iter_on_currently_loading_frame (frame->iter));
    /* store current content of the frame */
    frame->pixbuf = gdk_pixbuf_copy (gdk_pixbuf_animation_iter_get_pixbuf (frame->iter));
}
Пример #10
0
/**
 * eog_thumbnail_fit_to_size:
 * @thumbnail: a #GdkPixbuf
 * @dimension: the maximum width or height desired
 *
 * Ensures a pixbuf fits a given @dimension
 *
 * Returns: (transfer full): a new #GdkPixbuf
 **/
GdkPixbuf *
eog_thumbnail_fit_to_size (GdkPixbuf *thumbnail, gint dimension)
{
	gint width, height;

	width = gdk_pixbuf_get_width (thumbnail);
	height = gdk_pixbuf_get_height (thumbnail);

	if (width > dimension || height > dimension) {
		GdkPixbuf *result_pixbuf;
		gfloat factor;

		if (width > height) {
			factor = (gfloat) dimension / (gfloat) width;
		} else {
			factor = (gfloat) dimension / (gfloat) height;
		}

		width  = MAX (width  * factor, 1);
		height = MAX (height * factor, 1);

		result_pixbuf = gnome_desktop_thumbnail_scale_down_pixbuf (thumbnail, width, height);

		return result_pixbuf;
	}
	return gdk_pixbuf_copy (thumbnail);
}
Пример #11
0
int
main (int argc, char **argv)
{
  static guchar data[99999];
  gint height = 8;
  gint rowstride = 256;

  gdk_init (&argc, &argv);
  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (data,
                                                GDK_COLORSPACE_RGB,
                                                0,
                                                8,
                                                2,height,
                                                rowstride,
                                                NULL,
                                                NULL);
  printf ("%p\n", gdk_pixbuf_get_pixels(pixbuf));

  GdkPixbuf *p2 = gdk_pixbuf_copy (pixbuf);
  printf ("%p\n", gdk_pixbuf_get_pixels(p2));

  printf ("%p\n", gdk_pixbuf_get_pixels(p2) + rowstride*height);

  return 0;
}
Пример #12
0
static void 
draw_eye (EyesApplet *eyes_applet,
	  gint eye_num, 
          gint pupil_x, 
          gint pupil_y)
{
	GdkPixbuf *pixbuf;
	GdkRectangle rect, r1, r2;

	pixbuf = gdk_pixbuf_copy (eyes_applet->eye_image);
	r1.x = pupil_x - eyes_applet->pupil_width / 2;
	r1.y = pupil_y - eyes_applet->pupil_height / 2;
	r1.width = eyes_applet->pupil_width;
	r1.height = eyes_applet->pupil_height;
	r2.x = 0;
	r2.y = 0;
	r2.width = eyes_applet->eye_width;
	r2.height = eyes_applet->eye_height;
	gdk_rectangle_intersect (&r1, &r2, &rect);
	gdk_pixbuf_composite (eyes_applet->pupil_image, pixbuf, 
					   rect.x,
					   rect.y,
					   rect.width,
				      	   rect.height,
				      	   pupil_x - eyes_applet->pupil_width / 2,
					   pupil_y - eyes_applet->pupil_height / 2, 1.0, 1.0,
				      	   GDK_INTERP_BILINEAR,
				           255);
	gtk_image_set_from_pixbuf (GTK_IMAGE (eyes_applet->eyes[eye_num]),
						  pixbuf);
	g_object_unref (pixbuf);

}
Пример #13
0
GdkPixbuf *
gp_image_get_pixbuf ( GpImage *image )
{
	g_return_val_if_fail ( GP_IS_IMAGE (image), NULL);

	return  gdk_pixbuf_copy ( image->priv->pixbuf );
}
Пример #14
0
static GdkPixbuf *
wnck_selector_dimm_icon (GdkPixbuf *pixbuf)
{
  int x, y, pixel_stride, row_stride;
  guchar *row, *pixels;
  int w, h;
  GdkPixbuf *dimmed;

  w = gdk_pixbuf_get_width (pixbuf);
  h = gdk_pixbuf_get_height (pixbuf);

  if (gdk_pixbuf_get_has_alpha (pixbuf))
    dimmed = gdk_pixbuf_copy (pixbuf);
  else
    dimmed = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);

  pixel_stride = 4;

  row = gdk_pixbuf_get_pixels (dimmed);
  row_stride = gdk_pixbuf_get_rowstride (dimmed);

  for (y = 0; y < h; y++)
    {
      pixels = row;
      for (x = 0; x < w; x++)
        {
          pixels[3] /= 2;
          pixels += pixel_stride;
        }
      row += row_stride;
    }

  return dimmed;
}
static void
from_pixbuf (GtkSourcePixbufHelper *helper,
             GtkWidget             *widget,
             gint                   size)
{
	if (helper->pixbuf == NULL)
	{
		return;
	}

	if (gdk_pixbuf_get_width (helper->pixbuf) <= size)
	{
		if (!helper->cached_pixbuf)
		{
			set_cache (helper, gdk_pixbuf_copy (helper->pixbuf));
		}

		return;
	}

	/* Make smaller */
	set_cache (helper, gdk_pixbuf_scale_simple (helper->pixbuf,
	                                            size,
	                                            size,
	                                            GDK_INTERP_BILINEAR));
}
Пример #16
0
/**
 * gdk_pixbuf_scale_simple:
 * @src: a #GdkPixbuf
 * @dest_width: the width of destination image
 * @dest_height: the height of destination image
 * @interp_type: the interpolation type for the transformation.
 *
 * Create a new #GdkPixbuf containing a copy of @src scaled to
 * @dest_width x @dest_height. Leaves @src unaffected.  @interp_type
 * should be #GDK_INTERP_NEAREST if you want maximum speed (but when
 * scaling down #GDK_INTERP_NEAREST is usually unusably ugly).  The
 * default @interp_type should be #GDK_INTERP_BILINEAR which offers
 * reasonable quality and speed.
 *
 * You can scale a sub-portion of @src by creating a sub-pixbuf
 * pointing into @src; see gdk_pixbuf_new_subpixbuf().
 *
 * If @dest_width and @dest_height are equal to the @src width and height, a
 * copy of @src is returned, avoiding any scaling.
 *
 * For more complicated scaling/alpha blending see gdk_pixbuf_scale()
 * and gdk_pixbuf_composite().
 * 
 * Return value: (nullable) (transfer full): the new #GdkPixbuf, or %NULL if not enough memory could be
 * allocated for it.
 **/
GdkPixbuf *
gdk_pixbuf_scale_simple (const GdkPixbuf *src,
			 int              dest_width,
			 int              dest_height,
			 GdkInterpType    interp_type)
{
  GdkPixbuf *dest;

  g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
  g_return_val_if_fail (dest_width > 0, NULL);
  g_return_val_if_fail (dest_height > 0, NULL);

  /* Fast path. */
  if (dest_width == src->width && dest_height == src->height)
    return gdk_pixbuf_copy (src);

  dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, src->has_alpha, 8, dest_width, dest_height);
  if (!dest)
    return NULL;

  gdk_pixbuf_scale (src, dest,  0, 0, dest_width, dest_height, 0, 0,
		    (double) dest_width / src->width,
		    (double) dest_height / src->height,
		    interp_type);

  return dest;
}
/* Return a new GdkPixbuf enhancing/reducing brightness and contrast according
   to the specified values (from -1.0 to +1.0).  */
GdkPixbuf *
f_pixbuf_copy_apply_brightness_and_contrast (GdkPixbuf *src,
					     float brightness,
					     float contrast)
{
	GdkPixbuf *result_pixbuf;
	char *sp, *dp;
	int width, height;
	int line;
	int result_rowstride, src_rowstride;
	int bytes_per_pixel;

	g_return_val_if_fail ((brightness > -1.0 || F_DOUBLE_EQUAL (brightness, -1.0))
			       && (brightness < 1.0 || F_DOUBLE_EQUAL (brightness, 1.0)),
			      NULL);
	g_return_val_if_fail ((contrast > -1.0 || F_DOUBLE_EQUAL (contrast, -1.0))
			       && (contrast < 1.0 || F_DOUBLE_EQUAL (contrast, 1.0)),
			      NULL);

	if (F_DOUBLE_EQUAL (brightness, 0.0) && F_DOUBLE_EQUAL (contrast, 0.0))
		return gdk_pixbuf_copy (src);

	result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
					gdk_pixbuf_get_has_alpha (src),
					gdk_pixbuf_get_bits_per_sample (src),
					gdk_pixbuf_get_width (src),
					gdk_pixbuf_get_height (src));

	width = gdk_pixbuf_get_width (result_pixbuf);
	height = gdk_pixbuf_get_height (result_pixbuf);

	result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
	src_rowstride = gdk_pixbuf_get_rowstride (src);

	bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;

	sp = gdk_pixbuf_get_pixels (src);
	dp = gdk_pixbuf_get_pixels (result_pixbuf);

	for (line = 0; line < height; line ++) {
		char *sq = sp;
		char *dq = dp;
		int i;

		for (i = 0; i < width; i ++) {
			dq[0] = apply_brightness_and_contrast (sq[0], brightness, contrast);
			dq[1] = apply_brightness_and_contrast (sq[1], brightness, contrast);
			dq[2] = apply_brightness_and_contrast (sq[2], brightness, contrast);

			dq += bytes_per_pixel;
			sq += bytes_per_pixel;
		}

		sp += src_rowstride;
		dp += result_rowstride;
	}

	return result_pixbuf;
}
Пример #18
0
static GdkPixbuf *
task_item_sized_pixbuf_for_window (TaskItem   *item,
                                   WnckWindow *window,
                                   gint size)
{
  GdkPixbuf *pbuf = NULL;
  
  g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
  
  if (wnck_window_has_icon_name (window))
  {
    const gchar *icon_name = wnck_window_get_icon_name (window);
    GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
    
    if (gtk_icon_theme_has_icon (icon_theme, icon_name))
    {
      GdkPixbuf *internal = gtk_icon_theme_load_icon (icon_theme, 
                                                      icon_name,
                                                      size,
                                                      GTK_ICON_LOOKUP_FORCE_SIZE,
                                                      NULL);
      pbuf = gdk_pixbuf_copy (internal);
      g_object_unref (internal);
    }
  }
  
  if (!pbuf)
  {
    pbuf = gdk_pixbuf_copy (wnck_window_get_icon (item->priv->window));
  }
  
  gint width = gdk_pixbuf_get_width (pbuf);
  gint height = gdk_pixbuf_get_height (pbuf);

  if (MAX (width, height) != size)
  {
    gdouble scale = (gdouble) size / (gdouble) MAX (width, height);
  
    GdkPixbuf *tmp = pbuf;
    pbuf = gdk_pixbuf_scale_simple (tmp, (gint) (width * scale), (gint) (height * scale), GDK_INTERP_HYPER);
    
    g_object_unref (tmp);
  }
 
  return pbuf;
}
Пример #19
0
void		
gp_image_set_mask ( GpImage *image, GdkBitmap *mask )
{
	GdkPixbuf *pixbuf;
	GdkPixbuf *m_pixbuf;
	guchar *pixels, *m_pixels;
	guchar *p, *m_p;
	gint w, h;
	gint n_channels, rowstride;

	g_return_if_fail ( GP_IS_IMAGE (image) );
	

	pixbuf		=   image->priv->pixbuf;
	if(!gdk_pixbuf_get_has_alpha ( pixbuf ) )
	{  /*add alpha*/
		GdkPixbuf *tmp ;
		tmp = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0);
		g_object_unref(pixbuf);
		pixbuf = tmp;
	}
	m_pixbuf	=   gdk_pixbuf_copy ( pixbuf );
	
	gdk_pixbuf_get_from_drawable (  m_pixbuf, 
               						mask,
               						gdk_drawable_get_colormap (mask),
               						0,0,
               						0,0,
              						-1,-1);
	n_channels  =   gdk_pixbuf_get_n_channels   ( pixbuf );
	rowstride   =   gdk_pixbuf_get_rowstride	( pixbuf );
	w			=   gdk_pixbuf_get_width		( pixbuf );
	h			=   gdk_pixbuf_get_height		( pixbuf );
	pixels		=   gdk_pixbuf_get_pixels		( pixbuf );
	m_pixels	=   gdk_pixbuf_get_pixels		( m_pixbuf );
	while (h--) 
	{
		guint   i = w;
		p   = pixels;
		m_p = m_pixels;
		while (i--) 
		{
			if(m_p[0] == 0)
			{
				p[0] = 0; 
				p[1] = 0; 
				p[2] = 0; 
				p[3] = 0; 
			}
			p   += n_channels;
			m_p += n_channels;
		}
		pixels		+= rowstride;
		m_pixels	+= rowstride;
	}
	g_object_unref (m_pixbuf);
}
Пример #20
0
/* Erase box by reloading original pixbuf */
void
erase_rubberbox(GtkWidget *drawing_area)
{
  // copy original image
  g_object_unref(pixbuf);
  pixbuf = gdk_pixbuf_copy(skin_infos.img_orig);
  
  // force immediate & full redraw
  gtk_widget_queue_draw(drawing_area);
}
Пример #21
0
Pixbuf::Pixbuf(Inkscape::Pixbuf const &other)
    : _pixbuf(gdk_pixbuf_copy(other._pixbuf))
    , _surface(cairo_image_surface_create_for_data(
        gdk_pixbuf_get_pixels(_pixbuf), CAIRO_FORMAT_ARGB32,
        gdk_pixbuf_get_width(_pixbuf), gdk_pixbuf_get_height(_pixbuf), gdk_pixbuf_get_rowstride(_pixbuf)))
    , _mod_time(other._mod_time)
    , _path(other._path)
    , _pixel_format(other._pixel_format)
    , _cairo_store(false)
{}
Пример #22
0
void FskGtkWindowInvalidDaRect(FskGtkWindow win, FskRectangle area)
{
	FskMutexAcquire(win->bufMutex);
	if(win->pixbufDraw)
		g_object_unref(win->pixbufDraw);

	win->pixbufDraw = gdk_pixbuf_copy(win->pixbuf);
	FskMutexRelease(win->bufMutex);

	g_async_queue_push(win->queue, win);
}
Пример #23
0
static void on_icon_changed(WnckWindow *controlwindow, WindowckPlugin *wckp)
{
    GdkPixbuf *pixbuf = NULL;
    GdkPixbuf *grayscale = NULL;


    if (!controlwindow)
    {
        xfce_panel_image_clear(XFCE_PANEL_IMAGE (wckp->icon->symbol));
    }
    else if (wckp->prefs->show_on_desktop)
    {
        gtk_widget_set_sensitive (wckp->icon->symbol, TRUE);

        if (wnck_window_get_window_type (controlwindow) == WNCK_WINDOW_DESKTOP)
        {
            if (!wnck_window_is_active(controlwindow))
                gtk_widget_set_sensitive (wckp->icon->symbol, FALSE);

            xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (wckp->icon->symbol),GTK_STOCK_HOME);
        }
    }

    if (controlwindow
        && wnck_window_get_window_type (controlwindow) != WNCK_WINDOW_DESKTOP)
    {
        /* This only returns a pointer - it SHOULDN'T be unrefed! */
        if (XFCE_PANEL_IS_SMALL)
            pixbuf = wnck_window_get_mini_icon(controlwindow);
        else
            pixbuf = wnck_window_get_icon(controlwindow);

        /* leave when there is no valid pixbuf */
        if (G_UNLIKELY (pixbuf == NULL))
        {
            xfce_panel_image_clear (XFCE_PANEL_IMAGE (wckp->icon->symbol));
            return;
        }

        if (!wnck_window_is_active(controlwindow))
        {
            /* icon color is set to grayscale */
            grayscale = gdk_pixbuf_copy(pixbuf);
            gdk_pixbuf_saturate_and_pixelate(grayscale, grayscale, 0, FALSE);
            if (G_UNLIKELY (grayscale != NULL))
                pixbuf = grayscale;
        }

        xfce_panel_image_set_from_pixbuf(XFCE_PANEL_IMAGE (wckp->icon->symbol), pixbuf);
    }

    if (grayscale != NULL && grayscale != pixbuf)
        g_object_unref (G_OBJECT (grayscale));
}
Пример #24
0
//Loads an image and launches the detection process
int loadFile(struct main_window *mW, char *path) {
	//Save path
	strcpy(mW->path, path);

	//Store the buffer in memory and make a copy
	mW->processPixbuf = gdk_pixbuf_new_from_file(mW->path, NULL);
	mW->previewPixbuf = gdk_pixbuf_copy(mW->processPixbuf);

	//Display preview
	previewFromPix(mW, mW->previewPixbuf);
	return 0;
}
Пример #25
0
/* prepare copy of pixbuf and connect other callbacks */
static void
callback_area_prepared (GdkPixbufLoader *loader)
{
    GdkPixbuf *pixbuf_copy;

    pixbuf_copy = gdk_pixbuf_copy (gdk_pixbuf_loader_get_pixbuf (loader));
    /* connect callbacks for another signals for not use pointer to pointer in them. */
    g_signal_connect (loader, "area-updated",
                      (GCallback) callback_area_updated, (gpointer) pixbuf_copy);
    g_signal_connect (loader, "closed",
                      (GCallback) callback_closed, (gpointer) pixbuf_copy);
}
Пример #26
0
/* called when the preview button is clicked. */
static void
preview_cb (GtkWidget  *widget,
	    DialogData *data)
{
	GdkPixbuf *preview;

	preview = gdk_pixbuf_copy (data->image);
	apply_changes (data, preview, preview, FALSE, TRUE);
	g_object_unref (preview);

	data->modified = TRUE;
}
Пример #27
0
void hybrid_info_add_pixbuf_pair(HybridNotifyInfo *info, const gchar *name,
        const GdkPixbuf *pixbuf)
{
    HybridInfoItem *item;

    g_return_if_fail(info != NULL);
    g_return_if_fail(name != NULL);

    item = hybrid_info_item_create(name, NULL);
    item->type = HYBRID_INFO_ITEM_TYPE_PIXBUF;
    item->pixbuf = gdk_pixbuf_copy(pixbuf);
    info->item_list = g_slist_append(info->item_list, item);
}
Пример #28
0
static GdkPixbuf * make_small_image(int force, ThumbnailData *tdata,
                                    ImageInfo *ii)
{
    if (!pixbuf_small || force) {
        if (pixbuf_small) {
            g_object_unref(pixbuf_small);
            pixbuf_small = NULL;
        }

        if (!tdata)
            tdata = get_thumbnail_data(ii);

        int tsx = tdata->size_x;
        int tsy = tdata->size_y;

        // Create the pixbuf
        GdkPixbuf *pb =
          gdk_pixbuf_new_from_data(tdata->data, GDK_COLORSPACE_RGB, FALSE,
                                   8, tsx, tsy, tsx*3, destroy_pb_data, NULL);

        if (!pb)
            asfPrintError("Failed to create the small pixbuf.\n");

        // Scale down to the size we actually want, using the built-in Gdk
        // scaling method, much nicer than what we did above

        // Must ensure we scale the same in each direction
        double scale_y = (double)tsy / THUMB_SIZE;
        double scale_x = (double)tsx / THUMB_SIZE;
        double scale = scale_y > scale_x ? scale_y : scale_x;
        small_image_x_dim = tsx / scale;
        small_image_y_dim = tsy / scale;

        //printf("Scaling to %dx%d\n", small_image_x_dim, small_image_y_dim);

        pixbuf_small =
            gdk_pixbuf_scale_simple(pb, small_image_x_dim, small_image_y_dim,
                                    GDK_INTERP_BILINEAR);
        gdk_pixbuf_unref(pb);

        if (!pixbuf_small)
            asfPrintError("Failed to allocate scaled thumbnail pixbuf\n");

        free(tdata);
    }

    GdkPixbuf *pb2 = gdk_pixbuf_copy(pixbuf_small);
    put_bounding_box(pb2, ii);
    return pb2;
}
Пример #29
0
void
draw_rubberbox(GtkWidget *drawing_area, GdkRect rect)
{
  GdkRect c;
  GdkRect oc;
  GdkRect update_rect;
  
  c = rect;
  oc = old_rect;
  
  if ((c.x > skin_infos.width) || (c.y > skin_infos.height) || 
      ((c.x + c.w) > skin_infos.width) || ((c.y + c.h) > skin_infos.height))
    return;
  
  g_object_unref(pixbuf);
  pixbuf = gdk_pixbuf_copy(skin_infos.img_orig);
  
  draw_hline(c.x, c.y, c.w);
  draw_hline(c.x, c.y + c.h, c.w);
  
  draw_vline(c.x, c.y, c.h);
  draw_vline(c.x + c.w, c.y, c.h);
  
  /*
   * 2 calls to SDL_UpdateRect :
   * + erase the old rect
   * + draw the new one
   *
   * We could composite a new rectangle with the new and old ones,
   * but this would consume more resources than these 2 calls.
   * Plus it would complicate the code. *sigh*
   */

  update_rect.x = oc.x;
  update_rect.y = oc.y;
  update_rect.w = ((oc.w + oc.x + 1) <= skin_infos.width) ? (oc.w + 1) : oc.w;  /* add 2 to really erase the lines (right, bottom) ... */
  update_rect.h = ((oc.h + oc.y + 1) <= skin_infos.height) ? (oc.h + 1) : oc.h; /* ... but be careful */
  
  gtk_widget_draw (drawing_area, (GdkRectangle *)(&update_rect));
  
  update_rect.x = c.x;
  update_rect.y = c.y;
  update_rect.w = ((c.w + c.x + 1) <= skin_infos.width) ? (c.w + 1) : c.w;  /* add 2 to really erase the lines (right, bottom) ... */
  update_rect.h = ((c.h + c.y + 1) <= skin_infos.height) ? (c.h + 1) : c.h; /* ... but be careful */
  
  gtk_widget_draw (drawing_area, (GdkRectangle *)&update_rect);

  tmp_rect = rect; /* when called from callbacks.c (for LCD or keys) */
  old_rect = rect; /* save coords */
}
Пример #30
0
GdkPixbuf*
pgpug_static_icon (PgpugPixEnum icon_id, 
		   gint size)
{

     GdkPixbufAnimation *anim;
     GdkPixbuf *result = NULL;
     anim = pgpug_animated_icon (icon_id, size);
     if (anim != NULL) {
	  result = gdk_pixbuf_copy (gdk_pixbuf_animation_get_static_image (anim));
	  g_object_unref (anim);
     }

     return result;
}