Esempio n. 1
0
gboolean
apply_transformation_generic (FileData     *file,
			      GthTransform  transform,
			      GError       **error)
{
	gboolean   success = TRUE;
	GdkPixbuf *original_pixbuf;
	GdkPixbuf *transformed_pixbuf;
	
	if (file == NULL)
		return FALSE;

	if (transform == GTH_TRANSFORM_NONE)
		return TRUE;

	original_pixbuf = gth_pixbuf_new_from_file (file, error, 0, 0, NULL);
	if (original_pixbuf == NULL)
		return FALSE;

	transformed_pixbuf = _gdk_pixbuf_transform (original_pixbuf, transform);
		
	if (is_mime_type_writable (file->mime_type)) {
		const char *image_type = file->mime_type + 6;
		char	   *local_file;
		
		image_type = file->mime_type + 6;
		local_file = get_cache_filename_from_uri (file->path);
		
		success = _gdk_pixbuf_save (transformed_pixbuf,
					    local_file,
					    image_type,
					    error,
					    NULL);
					    
		g_free (local_file);
	} 
	else {
		if (error != NULL)
			*error = g_error_new (GTHUMB_ERROR, 0, _("Image type not supported: %s"), file->mime_type);
		success = FALSE;
	}
	
	g_object_unref (transformed_pixbuf);
	g_object_unref (original_pixbuf);
	
	return success;
}
Esempio n. 2
0
static void
gth_file_tool_mirror_activate (GthFileTool *base)
{
	GtkWidget *window;
	GtkWidget *viewer_page;
	GtkWidget *viewer;
	GdkPixbuf *src_pixbuf;
	GdkPixbuf *dest_pixbuf;

	window = gth_file_tool_get_window (base);
	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
	if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
		return;

	viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
	src_pixbuf = gth_image_viewer_get_current_pixbuf (GTH_IMAGE_VIEWER (viewer));
	if (src_pixbuf == NULL)
		return;

	dest_pixbuf = _gdk_pixbuf_transform (src_pixbuf, GTH_TRANSFORM_FLIP_H);
	gth_image_viewer_page_set_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page), dest_pixbuf, TRUE);

	g_object_unref (dest_pixbuf);
}