X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libdocument%2Fev-image.c;h=e02831e3ea6498837f553e20080ac1b51c5aa25e;hb=aeadd8e191190c43e94999fef077ebea69e966c9;hp=1fa6bfd6dd34c7515121a1aaa2e2b0be4f370cee;hpb=411b128d9f6b829b1b3f35c89fe0fef595a2b913;p=evince.git diff --git a/libdocument/ev-image.c b/libdocument/ev-image.c index 1fa6bfd6..e02831e3 100644 --- a/libdocument/ev-image.c +++ b/libdocument/ev-image.c @@ -14,11 +14,14 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include + #include +#include + #include "ev-document-misc.h" #include "ev-file-helpers.h" #include "ev-image.h" @@ -132,7 +135,8 @@ ev_image_save_tmp (EvImage *image, GdkPixbuf *pixbuf) { GError *error = NULL; - gchar *filename; + gchar *filename = NULL; + int fd; g_return_val_if_fail (EV_IS_IMAGE (image), NULL); g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); @@ -140,19 +144,28 @@ ev_image_save_tmp (EvImage *image, if (image->priv->tmp_uri) return image->priv->tmp_uri; - filename = ev_tmp_filename ("image"); + if ((fd = ev_mkstemp ("image.XXXXXX", &filename, &error)) == -1) + goto had_error; + gdk_pixbuf_save (pixbuf, filename, "png", &error, "compression", "3", NULL); + close (fd); + if (!error) { - image->priv->tmp_uri = g_filename_to_uri (filename, NULL, NULL); + image->priv->tmp_uri = g_filename_to_uri (filename, NULL, &error); + if (image->priv->tmp_uri == NULL) + goto had_error; + g_free (filename); return image->priv->tmp_uri; } + had_error: + /* Erro saving image */ - g_warning (error->message); + g_warning ("Error saving image: %s", error->message); g_error_free (error); g_free (filename); @@ -166,44 +179,3 @@ ev_image_get_tmp_uri (EvImage *image) return image->priv->tmp_uri; } - -/* EvImageMapping */ -static void -ev_image_mapping_free_foreach (EvImageMapping *mapping) -{ - g_object_unref (mapping->image); - g_free (mapping); -} - -void -ev_image_mapping_free (GList *image_mapping) -{ - if (!image_mapping) - return; - - g_list_foreach (image_mapping, (GFunc) ev_image_mapping_free_foreach, NULL); - g_list_free (image_mapping); -} - -EvImage * -ev_image_mapping_find (GList *image_mapping, - gdouble x, - gdouble y) -{ - GList *list; - - for (list = image_mapping; list; list = list->next) { - EvImageMapping *mapping = list->data; - - if ((x >= mapping->x1) && - (y >= mapping->y1) && - (x <= mapping->x2) && - (y <= mapping->y2)) { - return mapping->image; - } - } - - return NULL; -} - -