1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
===================================================================
RCS file: /cvs/gnome/f-spot/src/BitConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- src/BitConverter.cs 2005/10/13 19:57:22 1.3
+++ src/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
--- src/Ciff.cs 2005/09/25 08:37:34 1.8
+++ src/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);
|