소스 검색

2007-03-28 Sebastien Pouliot <[email protected]>

	* MetaHeader.cs: Make workaround (#81254) permanent and return correct
	values on big endian architectures.


svn path=/trunk/mcs/; revision=75096
Sebastien Pouliot 19 년 전
부모
커밋
bfcb419bf9
2개의 변경된 파일20개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 0
      mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
  2. 15 5
      mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs

+ 5 - 0
mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog

@@ -1,3 +1,8 @@
+2007-03-28  Sebastien Pouliot  <[email protected]>  
+
+	* MetaHeader.cs: Make workaround (#81254) permanent and return correct
+	values on big endian architectures.
+
 2007-03-28  Sebastien Pouliot  <[email protected]> 
 
 	* MetaHeader.cs: Workaround bug #81254 where the SPARC architecture 

+ 15 - 5
mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs

@@ -41,10 +41,10 @@ namespace System.Drawing.Imaging {
 		public short file_type;
 		public short header_size;
 		public short version;
-		// this is unaligned and fails on the SPARC architecture - http://bugzilla.ximian.com/show_bug.cgi?id=81254
+		// this is unaligned and fails on the SPARC architecture (see bug #81254 for details)
 		// public int file_size;
 		public ushort file_size_low;
-		public short file_size_high;
+		public ushort file_size_high;
 		public short num_of_objects;
 		public int max_record_size;
 		public short num_of_params;
@@ -93,10 +93,20 @@ namespace System.Drawing.Imaging {
 		}
 		
 		public int Size {
-			get { return (wmf.file_size_high << 16) | wmf.file_size_low; }
+			get {
+				if (BitConverter.IsLittleEndian)
+					return (wmf.file_size_high << 16) | wmf.file_size_low;
+				else
+					return (wmf.file_size_low << 16) | wmf.file_size_high;
+			}
 			set {
-				wmf.file_size_high = (short)(value >> 16);
-				wmf.file_size_low = (ushort)value;
+				if (BitConverter.IsLittleEndian) {
+					wmf.file_size_high = (ushort)(value >> 16);
+					wmf.file_size_low = (ushort)value;
+				} else {
+					wmf.file_size_high = (ushort)value;
+					wmf.file_size_low = (ushort)(value >> 16);
+				}
 			}
 		}