f-spot r4441 - in trunk: . src src/Core src/Utils
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4441 - in trunk: . src src/Core src/Utils
- Date: Tue, 23 Sep 2008 11:38:13 +0000 (UTC)
Author: sdelcroix
Date: Tue Sep 23 11:38:12 2008
New Revision: 4441
URL: http://svn.gnome.org/viewvc/f-spot?rev=4441&view=rev
Log:
2008-09-22 Stephane Delcroix <sdelcroix novell com>
* src/Core/Photo.cs:
* src/TagStore.cs:
* src/Utils/GdkUtils.cs: no longer P/Invoke pixdata.Deserialize, move the
PixbufSerializer methods to GdkUtils.
Modified:
trunk/ChangeLog
trunk/src/Core/Photo.cs
trunk/src/TagStore.cs
trunk/src/Utils/GdkUtils.cs
Modified: trunk/src/Core/Photo.cs
==============================================================================
--- trunk/src/Core/Photo.cs (original)
+++ trunk/src/Core/Photo.cs Tue Sep 23 11:38:12 2008
@@ -645,7 +645,7 @@
using (Gdk.Pixbuf pixbuf = ThumbnailGenerator.Create (uri))
{
- byte[] serialized = PixbufSerializer.Serialize (pixbuf);
+ byte[] serialized = GdkUtils.Serialize (pixbuf);
byte[] md5 = MD5Generator.ComputeHash (serialized);
string md5_string = Convert.ToBase64String (md5);
Modified: trunk/src/TagStore.cs
==============================================================================
--- trunk/src/TagStore.cs (original)
+++ trunk/src/TagStore.cs Tue Sep 23 11:38:12 2008
@@ -13,43 +13,6 @@
using FSpot.Query;
using FSpot.Utils;
-// FIXME: This is to workaround the currently busted GTK# bindings.
-using System.Runtime.InteropServices;
-
-public class PixbufSerializer {
- [DllImport("libgdk_pixbuf-2.0-0.dll")]
- static extern unsafe bool gdk_pixdata_deserialize(ref Gdk.Pixdata raw, uint stream_length, byte [] stream, out IntPtr error);
-
- public static unsafe Pixbuf Deserialize (byte [] data)
- {
- Pixdata pixdata = new Pixdata ();
-
- pixdata.Deserialize ((uint) data.Length, data);
-
- return Pixbuf.FromPixdata (pixdata, true);
- }
-
- [DllImport("libgdk_pixbuf-2.0-0.dll")]
- static extern IntPtr gdk_pixdata_serialize(ref Gdk.Pixdata raw, out uint stream_length_p);
-
- public static byte [] Serialize (Pixbuf pixbuf)
- {
- Pixdata pixdata = new Pixdata ();
- IntPtr raw_pixdata = pixdata.FromPixbuf (pixbuf, false); // FIXME GTK# shouldn't this be a constructor or something?
- // It's probably because we need the IntPtr to free it afterwards
-
- uint data_length;
- IntPtr raw_data = gdk_pixdata_serialize (ref pixdata, out data_length);
-
- byte [] data = new byte [data_length];
- Marshal.Copy (raw_data, data, 0, (int) data_length);
-
- GLib.Marshaller.Free (new IntPtr[] { raw_data, raw_pixdata });
-
- return data;
- }
-}
-
public class InvalidTagOperationException : InvalidOperationException {
public Tag tag;
@@ -105,7 +68,7 @@
else if (icon_string.StartsWith (STOCK_ICON_DB_PREFIX))
tag.ThemeIconName = icon_string.Substring (STOCK_ICON_DB_PREFIX.Length);
else
- tag.Icon = PixbufSerializer.Deserialize (Convert.FromBase64String (icon_string));
+ tag.Icon = GdkUtils.Deserialize (Convert.FromBase64String (icon_string));
}
private Tag hidden;
@@ -361,7 +324,7 @@
if (tag.Icon == null)
return String.Empty;
- byte [] data = PixbufSerializer.Serialize (tag.Icon);
+ byte [] data = GdkUtils.Serialize (tag.Icon);
return Convert.ToBase64String (data);
}
Modified: trunk/src/Utils/GdkUtils.cs
==============================================================================
--- trunk/src/Utils/GdkUtils.cs (original)
+++ trunk/src/Utils/GdkUtils.cs Tue Sep 23 11:38:12 2008
@@ -4,6 +4,30 @@
namespace FSpot.Utils {
public class GdkUtils {
+ public static Pixbuf Deserialize (byte [] data)
+ {
+ Pixdata pixdata = new Pixdata ();
+
+ pixdata.Deserialize ((uint) data.Length, data);
+
+ return Pixbuf.FromPixdata (pixdata, true);
+ }
+
+ public static byte [] Serialize (Pixbuf pixbuf)
+ {
+ Pixdata pixdata = new Pixdata ();
+
+#if true //We should use_rle, but bgo#553374 prevents this
+ pixdata.FromPixbuf (pixbuf, false);
+ return pixdata.Serialize ();
+#else
+ IntPtr raw_pixdata = pixdata.FromPixbuf (pixbuf, true);
+ byte [] data = pixdata.Serialize ();
+ GLib.Marshaller.Free (raw_pixdata);
+
+ return data;
+#endif
+ }
class NativeMethods
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]