[f-spot/rubenv-gsoc-2009: 24/86] Change some stuff to the new API, less warning as a result.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/rubenv-gsoc-2009: 24/86] Change some stuff to the new API, less warning as a result.
- Date: Sun, 23 May 2010 12:33:58 +0000 (UTC)
commit 3c33c8dc4f4ecba82ccb3f943f182036c31d9cb3
Author: Ruben Vermeersch <ruben savanne be>
Date: Tue Jul 28 21:16:11 2009 +0200
Change some stuff to the new API, less warning as a result.
.../Exporters/FacebookExport/FacebookExport.cs | 2 +-
extensions/Exporters/FlickrExport/FlickrExport.cs | 2 +-
extensions/Exporters/FolderExport/FolderExport.cs | 4 +-
.../Exporters/GalleryExport/GalleryExport.cs | 2 +-
.../Exporters/PicasaWebExport/PicasaWebExport.cs | 2 +-
.../Exporters/SmugMugExport/SmugMugExport.cs | 2 +-
src/Filters/JpegFilter.cs | 8 ++++-
src/Filters/ResizeFilter.cs | 36 ++++++++++---------
src/SendEmail.cs | 4 +-
9 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/extensions/Exporters/FacebookExport/FacebookExport.cs b/extensions/Exporters/FacebookExport/FacebookExport.cs
index 66225b0..f7d4c9c 100644
--- a/extensions/Exporters/FacebookExport/FacebookExport.cs
+++ b/extensions/Exporters/FacebookExport/FacebookExport.cs
@@ -342,7 +342,7 @@ namespace FSpot.Exporter.Facebook
FilterSet filters = new FilterSet ();
filters.Add (new JpegFilter ());
- filters.Add (new ResizeFilter ((uint) size));
+ filters.Add (new ResizeFilter (size));
for (int i = 0; i < items.Length; i++) {
try {
diff --git a/extensions/Exporters/FlickrExport/FlickrExport.cs b/extensions/Exporters/FlickrExport/FlickrExport.cs
index e82a73e..7ff22c5 100644
--- a/extensions/Exporters/FlickrExport/FlickrExport.cs
+++ b/extensions/Exporters/FlickrExport/FlickrExport.cs
@@ -352,7 +352,7 @@ namespace FSpotFlickrExport {
info = new FileInfo (photo.DefaultVersion.Uri.LocalPath);
FilterSet stack = new FilterSet ();
if (scale)
- stack.Add (new ResizeFilter ((uint)size));
+ stack.Add (new ResizeFilter (size));
string id = fr.Upload (photo, stack, is_public, is_family, is_friend);
ids.Add (id);
diff --git a/extensions/Exporters/FolderExport/FolderExport.cs b/extensions/Exporters/FolderExport/FolderExport.cs
index a965e21..7f069f3 100644
--- a/extensions/Exporters/FolderExport/FolderExport.cs
+++ b/extensions/Exporters/FolderExport/FolderExport.cs
@@ -206,7 +206,7 @@ namespace FSpotFolderExport {
FilterSet filter_set = new FilterSet ();
if (scale)
- filter_set.Add (new ResizeFilter ((uint) size));
+ filter_set.Add (new ResizeFilter (size));
else if (rotate)
filter_set.Add (new OrientationFilter ());
filter_set.Add (new ChmodFilter ());
@@ -481,7 +481,7 @@ namespace FSpotFolderExport {
continue;
FilterSet req_set = new FilterSet ();
- req_set.Add (new ResizeFilter ((uint)Math.Max (req.Width, req.Height)));
+ req_set.Add (new ResizeFilter (Math.Max (req.Width, req.Height)));
bool sharpen;
try {
diff --git a/extensions/Exporters/GalleryExport/GalleryExport.cs b/extensions/Exporters/GalleryExport/GalleryExport.cs
index dab651d..e4c4f8e 100644
--- a/extensions/Exporters/GalleryExport/GalleryExport.cs
+++ b/extensions/Exporters/GalleryExport/GalleryExport.cs
@@ -764,7 +764,7 @@ namespace G2Export {
if (account.Version == GalleryVersion.Version1)
filters.Add (new WhiteListFilter (new string []{".jpg", ".jpeg", ".png", ".gif"}));
if (scale)
- filters.Add (new ResizeFilter ((uint) size));
+ filters.Add (new ResizeFilter (size));
else if (rotate)
filters.Add (new OrientationFilter ());
diff --git a/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs b/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
index ecd8842..ab2a4c7 100644
--- a/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
+++ b/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
@@ -643,7 +643,7 @@ namespace FSpotGoogleExport {
filters.Add (new JpegFilter ());
if (scale)
- filters.Add (new ResizeFilter ((uint)size));
+ filters.Add (new ResizeFilter (size));
if (rotate)
filters.Add (new OrientationFilter ());
diff --git a/extensions/Exporters/SmugMugExport/SmugMugExport.cs b/extensions/Exporters/SmugMugExport/SmugMugExport.cs
index 791057d..fff5e73 100644
--- a/extensions/Exporters/SmugMugExport/SmugMugExport.cs
+++ b/extensions/Exporters/SmugMugExport/SmugMugExport.cs
@@ -550,7 +550,7 @@ namespace FSpotSmugMugExport {
filters.Add (new JpegFilter ());
if (scale)
- filters.Add (new ResizeFilter ((uint)size));
+ filters.Add (new ResizeFilter (size));
if (rotate)
filters.Add (new OrientationFilter ());
diff --git a/src/Filters/JpegFilter.cs b/src/Filters/JpegFilter.cs
index e80ab15..791ed16 100644
--- a/src/Filters/JpegFilter.cs
+++ b/src/Filters/JpegFilter.cs
@@ -7,7 +7,9 @@
* This is free software. See COPYING for details.
*
*/
+using Gdk;
using System;
+using FSpot.Loaders;
namespace FSpot.Filters {
public class JpegFilter : IFilter {
@@ -46,7 +48,11 @@ namespace FSpot.Filters {
exif_data = new Exif.ExifData();
}
- PixbufUtils.SaveJpeg (img.Load(), dest, (int) quality, exif_data);
+ using (IImageLoader loader = ImageLoader.Create (req.Current)) {
+ loader.Load (ImageLoaderItem.Full);
+ using (Pixbuf full = loader.Full)
+ PixbufUtils.SaveJpeg (full, dest, (int) quality, exif_data);
+ }
}
return true;
diff --git a/src/Filters/ResizeFilter.cs b/src/Filters/ResizeFilter.cs
index 55f42e7..aa9574e 100644
--- a/src/Filters/ResizeFilter.cs
+++ b/src/Filters/ResizeFilter.cs
@@ -13,6 +13,7 @@ using System;
using System.IO;
using FSpot;
+using FSpot.Loaders;
using Mono.Unix;
@@ -21,21 +22,16 @@ using Gdk;
namespace FSpot.Filters {
public class ResizeFilter : IFilter
{
- public ResizeFilter ()
+ public ResizeFilter () : this (600)
{
}
- public ResizeFilter (uint size)
+ public ResizeFilter (int size)
{
- this.size = size;
+ Size = size;
}
- private uint size = 600;
-
- public uint Size {
- get { return size; }
- set { size = value; }
- }
+ public int Size { get; set; }
public bool Convert (FilterRequest req)
{
@@ -44,18 +40,24 @@ namespace FSpot.Filters {
string dest = dest_uri.LocalPath;
using (ImageFile img = ImageFile.Create (req.Current)) {
+ Pixbuf scaled;
+ using (IImageLoader loader = ImageLoader.Create (req.Current)) {
+ loader.Load (ImageLoaderItem.Full);
- using (Pixbuf pixbuf = img.Load ()) {
- if (pixbuf.Width < size && pixbuf.Height < size)
- return false;
+ using (Pixbuf pixbuf = loader.Full) {
+ if (pixbuf.Width < Size && pixbuf.Height < Size)
+ return false;
+
+ scaled = PixbufUtils.ScaleToMaxSize (pixbuf, Size, Size, false);
+ }
}
-
- using (Pixbuf pixbuf = img.Load ((int)size, (int)size)) {
+
+ using (scaled) {
string destination_extension = Path.GetExtension (dest);
-
+
if (Path.GetExtension (source).ToLower () == Path.GetExtension (dest).ToLower ()) {
using (Stream output = File.OpenWrite (dest)) {
- img.Save (pixbuf, output);
+ img.Save (scaled, output);
}
} else if (destination_extension == ".jpg") {
// FIXME this is a bit of a nasty hack to work around
@@ -65,7 +67,7 @@ namespace FSpot.Filters {
exif_data = new Exif.ExifData (source);
- PixbufUtils.SaveJpeg (pixbuf, dest, 95, exif_data);
+ PixbufUtils.SaveJpeg (scaled, dest, 95, exif_data);
} else
throw new NotImplementedException (String.Format (Catalog.GetString ("No way to save files of type \"{0}\""), destination_extension));
}
diff --git a/src/SendEmail.cs b/src/SendEmail.cs
index 2dfd203..53f4047 100644
--- a/src/SendEmail.cs
+++ b/src/SendEmail.cs
@@ -106,7 +106,7 @@ namespace FSpot {
long orig_size = FileFactory.NewForUri (scalephoto.DefaultVersion.Uri).QueryInfo ("standard::size", FileQueryInfoFlags.None, null).Size;
FilterSet filters = new FilterSet ();
- filters.Add (new ResizeFilter ((uint)(sizes [3])));
+ filters.Add (new ResizeFilter (sizes [3]));
long new_size;
using (FilterRequest request = new FilterRequest (scalephoto.DefaultVersion.Uri)) {
filters.Convert (request);
@@ -255,7 +255,7 @@ namespace FSpot {
FilterSet filters = new FilterSet ();
if (size != 0)
- filters.Add (new ResizeFilter ((uint) size));
+ filters.Add (new ResizeFilter (size));
else if (rotate)
filters.Add (new OrientationFilter ());
filters.Add (new UniqueNameFilter (tmp_mail_dir));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]