=================================================================== RCS file: /cvs/gnome/f-spot/src/BitConverter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- BitConverter.cs 2005/10/13 19:57:22 1.3 +++ BitConverter.cs 2005/10/25 17:54:27 1.4 @@ -1,3 +1,6 @@ +using System; +using System.Runtime.InteropServices; + namespace FSpot { public class BitConverter { public static uint Swap (uint val, bool little) @@ -66,6 +69,17 @@ return Swap (val, little); } + public static float ToSingle (byte [] data, int position, bool little) + { + float retval; + unsafe { + uint * ptr; + ptr = (uint *)&retval; + *ptr = ToUInt32 (data, position, little); + } + return retval; + } + public static int ToInt32 (byte [] data, int position, bool little) { return unchecked ((int) ToUInt32 (data, position, little)); =================================================================== RCS file: /cvs/gnome/f-spot/src/Ciff.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Ciff.cs 2005/09/25 08:37:34 1.8 +++ Ciff.cs 2005/10/25 17:54:27 1.9 @@ -1,3 +1,5 @@ +using System; + namespace FSpot.Ciff { public enum Tag { // Byte valuesad @@ -83,6 +85,8 @@ ExifInformation = 0x300b } + + public struct ImageSpec { public uint ImageWidth; // Number of horizontal pixels public uint ImageHeight; // Number of vertical pixels @@ -96,10 +100,8 @@ { ImageWidth = BitConverter.ToUInt32 (data, 0, little); ImageHeight = BitConverter.ToUInt32 (data, 4, little); - unsafe { - float *p = &PixelAspectRatio; - *((uint *)p) = BitConverter.ToUInt32 (data, 8, little); - } + + PixelAspectRatio = BitConverter.ToSingle (data, 8, little); RotationAngle = BitConverter.ToInt32 (data, 12, little); ComponentBitDepth = BitConverter.ToUInt32 (data, 16, little); ColorBitDepth = BitConverter.ToUInt32 (data, 20, little);