2 // System.Drawing.Imaging.MetaHeader.cs
5 // Everaldo Canuto (everaldo.canuto@bol.com.br)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 // Dennis Hayes (dennish@raytek.com)
8 // Sebastien Pouliot <sebastien@ximian.com>
10 // (C) 2002 Ximian, Inc. http://www.ximian.com
11 // Copyright (C) 2004, 2006-2007 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Runtime.InteropServices;
35 namespace System.Drawing.Imaging {
37 [StructLayout (LayoutKind.Sequential, Pack=2)]
38 internal struct WmfMetaHeader {
39 // field order match: http://wvware.sourceforge.net/caolan/ora-wmf.html
40 // for WMFHEAD structure
41 public short file_type;
42 public short header_size;
44 // this is unaligned and fails on the SPARC architecture (see bug #81254 for details)
45 // public int file_size;
46 public ushort file_size_low;
47 public ushort file_size_high;
48 public short num_of_objects;
49 public int max_record_size;
50 public short num_of_params;
53 [StructLayout (LayoutKind.Sequential)]
54 public sealed class MetaHeader {
56 private WmfMetaHeader wmf;
62 internal MetaHeader (WmfMetaHeader header)
64 wmf.file_type = header.file_type;
65 wmf.header_size = header.header_size;
66 wmf.version = header.version;
67 wmf.file_size_low = header.file_size_low;
68 wmf.file_size_high = header.file_size_high;
69 wmf.num_of_objects = header.num_of_objects;
70 wmf.max_record_size = header.max_record_size;
71 wmf.num_of_params = header.num_of_params;
75 public short HeaderSize {
76 get { return wmf.header_size; }
77 set { wmf.header_size = value; }
80 public int MaxRecord {
81 get { return wmf.max_record_size; }
82 set { wmf.max_record_size = value; }
85 public short NoObjects {
86 get { return wmf.num_of_objects; }
87 set { wmf.num_of_objects = value; }
90 public short NoParameters {
91 get { return wmf.num_of_params; }
92 set { wmf.num_of_params = value; }
97 if (BitConverter.IsLittleEndian)
98 return (wmf.file_size_high << 16) | wmf.file_size_low;
100 return (wmf.file_size_low << 16) | wmf.file_size_high;
103 if (BitConverter.IsLittleEndian) {
104 wmf.file_size_high = (ushort)(value >> 16);
105 wmf.file_size_low = (ushort)value;
107 wmf.file_size_high = (ushort)value;
108 wmf.file_size_low = (ushort)(value >> 16);
114 get { return wmf.file_type; }
115 set { wmf.file_type = value; }
118 public short Version {
119 get { return wmf.version; }
120 set { wmf.version = value; }