f-spot r3864 - trunk/src/Imaging
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r3864 - trunk/src/Imaging
- Date: Sun, 4 May 2008 12:51:12 +0100 (BST)
Author: sdelcroix
Date: Sun May 4 11:51:12 2008
New Revision: 3864
URL: http://svn.gnome.org/viewvc/f-spot?rev=3864&view=rev
Log:
3 patches backported from beagle. fixes bgo #531159
Modified:
trunk/src/Imaging/Exif.cs
trunk/src/Imaging/IptcFile.cs
trunk/src/Imaging/JpegHeader.cs
Modified: trunk/src/Imaging/Exif.cs
==============================================================================
--- trunk/src/Imaging/Exif.cs (original)
+++ trunk/src/Imaging/Exif.cs Sun May 4 11:51:12 2008
@@ -247,8 +247,13 @@
string delimiters = " :";
string[] dt_data = dt.Split ( delimiters.ToCharArray(), 6 );
DateTime result;
+ try {
+ // Assume local time
result = new DateTime (Int32.Parse(dt_data[0]), Int32.Parse(dt_data[1]), Int32.Parse(dt_data[2]),
- Int32.Parse(dt_data[3]), Int32.Parse(dt_data[4]), Int32.Parse(dt_data[5]));
+ Int32.Parse(dt_data[3]), Int32.Parse(dt_data[4]), Int32.Parse(dt_data[5]), DateTimeKind.Local);
+ } catch (FormatException) {
+ result = DateTime.MinValue;
+ }
return result;
}
Modified: trunk/src/Imaging/IptcFile.cs
==============================================================================
--- trunk/src/Imaging/IptcFile.cs (original)
+++ trunk/src/Imaging/IptcFile.cs Sun May 4 11:51:12 2008
@@ -346,6 +346,9 @@
public class IptcFile : SemWeb.StatementSource
{
System.Collections.ArrayList sets = new System.Collections.ArrayList ();
+ public System.Collections.ArrayList Sets {
+ get { return sets; }
+ }
// False seems a safe default
public bool Distinct {
Modified: trunk/src/Imaging/JpegHeader.cs
==============================================================================
--- trunk/src/Imaging/JpegHeader.cs (original)
+++ trunk/src/Imaging/JpegHeader.cs Sun May 4 11:51:12 2008
@@ -253,6 +253,7 @@
}
public static Signature JfifSignature = new Signature (JpegMarker.App0, "JFIF\0");
+ public static Signature ComSignature = new Signature (JpegMarker.Com, null);
public static Signature JfxxSignature = new Signature (JpegMarker.App0, "JFXX\0");
public static Signature XmpSignature = new Signature (JpegMarker.App1, "http://ns.adobe.com/xap/1.0/\0");
public static Signature ExifSignature = new Signature (JpegMarker.App1, "Exif\0\0");
@@ -326,6 +327,20 @@
}
}
+ public string GetJFIFComment ()
+ {
+ string name = ComSignature.Name;
+ Marker marker = FindMarker (ComSignature);
+
+ if (marker == null)
+ return null;
+
+ if (marker.Data != null && marker.Data.Length != 0)
+ return System.Text.Encoding.Default.GetString (marker.Data, 0, marker.Data.Length);
+
+ return null;
+ }
+
public XmpFile GetXmp ()
{
string name = XmpSignature.Name;
@@ -365,6 +380,37 @@
}
}
+ public FSpot.Iptc.IptcFile GetIptc ()
+ {
+ string name = PhotoshopSignature.Name;
+ JpegHeader.Marker marker = FindMarker (PhotoshopSignature);
+ if (marker != null) {
+ int len = name.Length;
+ using (System.IO.Stream bimstream = new System.IO.MemoryStream (marker.Data, len,
+ marker.Data.Length - len, false)) {
+
+ FSpot.Bim.BimFile bim;
+ try {
+ bim = new FSpot.Bim.BimFile (bimstream);
+ } catch {
+ // Bim entry with marker "PHUT" is not handled by Bim.cs
+ return null;
+ }
+
+ // FIXME: What about EntryType.XMP ?
+ FSpot.Bim.Entry iptc_entry = bim.FindEntry (FSpot.Bim.EntryType.IPTCNAA);
+ if (iptc_entry == null)
+ return null;
+
+ using (System.IO.Stream iptcstream = new System.IO.MemoryStream (iptc_entry.Data)) {
+ FSpot.Iptc.IptcFile iptc = new FSpot.Iptc.IptcFile (iptcstream);
+ return iptc;
+ }
+ }
+ }
+ return null;
+ }
+
public Exif.ExifData Exif {
get {
Marker m = FindMarker (ExifSignature);
@@ -464,7 +510,7 @@
bool at_image = false;
Marker marker = Marker.Load (stream);
- if (marker.Type != JpegMarker.Soi)
+ if (marker == null || marker.Type != JpegMarker.Soi)
throw new System.Exception ("This doesn't appear to be a jpeg stream");
this.Markers.Add (marker);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]