OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / direct3d10 / ImageInformation10.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
6 * of this software and associated documentation files (the "Software"), to deal\r
7 * in the Software without restriction, including without limitation the rights\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
9 * copies of the Software, and to permit persons to whom the Software is\r
10 * furnished to do so, subject to the following conditions:\r
11\r
12 * The above copyright notice and this permission notice shall be included in\r
13 * all copies or substantial portions of the Software.\r
14\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
21 * THE SOFTWARE.\r
22 */\r
23 \r
24 #include <d3d10.h>\r
25 #include <vcclr.h>\r
26 \r
27 #include "Direct3D10Exception.h"\r
28 \r
29 #include "ImageInformation10.h"\r
30 \r
31 using namespace System;\r
32 \r
33 namespace SlimDX\r
34 {\r
35         namespace Direct3D10\r
36         {       \r
37                 ImageInformation::ImageInformation( const D3DX10_IMAGE_INFO& native )\r
38                 {\r
39                         m_Width = native.Width;\r
40                         m_Height = native.Height;\r
41                         m_Depth = native.Depth;\r
42                         m_ArraySize = native.ArraySize;\r
43                         m_MipLevels = native.MipLevels;\r
44                         m_MiscFlags = static_cast<ResourceOptionFlags>( native.MiscFlags );\r
45                         m_Format = static_cast<DXGI::Format>( native.Format );\r
46                         m_Dimension = static_cast<ResourceDimension>( native.ResourceDimension );\r
47                         m_FileFormat = static_cast<ImageFileFormat>( native.ImageFileFormat );\r
48                 }\r
49 \r
50                 D3DX10_IMAGE_INFO ImageInformation::CreateNativeVersion()\r
51                 {\r
52                         D3DX10_IMAGE_INFO native;\r
53                         native.Width = m_Width;\r
54                         native.Height = m_Height;\r
55                         native.Depth = m_Depth;\r
56                         native.ArraySize = m_ArraySize;\r
57                         native.MipLevels = m_MipLevels;\r
58                         native.MiscFlags = static_cast<UINT>( m_MiscFlags );\r
59                         native.Format = static_cast<DXGI_FORMAT>( m_Format );\r
60                         native.ResourceDimension = static_cast<D3D10_RESOURCE_DIMENSION>( m_Dimension );\r
61                         native.ImageFileFormat = static_cast<D3DX10_IMAGE_FILE_FORMAT>( m_FileFormat );\r
62 \r
63                         return native;\r
64                 }\r
65 \r
66                 int ImageInformation::Width::get()\r
67                 {\r
68                         return m_Width;\r
69                 }\r
70 \r
71                 void ImageInformation::Width::set( int value )\r
72                 {\r
73                         m_Width = value;\r
74                 }\r
75                 \r
76                 int ImageInformation::Height::get()\r
77                 {\r
78                         return m_Height;\r
79                 }\r
80 \r
81                 void ImageInformation::Height::set( int value )\r
82                 {\r
83                         m_Height = value;\r
84                 }\r
85                 \r
86                 int ImageInformation::Depth::get()\r
87                 {\r
88                         return m_Depth;\r
89                 }\r
90 \r
91                 void ImageInformation::Depth::set( int value )\r
92                 {\r
93                         m_Depth = value;\r
94                 }\r
95                 \r
96                 int ImageInformation::ArraySize::get()\r
97                 {\r
98                         return m_ArraySize;\r
99                 }\r
100 \r
101                 void ImageInformation::ArraySize::set( int value )\r
102                 {\r
103                         m_ArraySize = value;\r
104                 }\r
105                 \r
106                 int ImageInformation::MipLevels::get()\r
107                 {\r
108                         return m_MipLevels;\r
109                 }\r
110 \r
111                 void ImageInformation::MipLevels::set( int value )\r
112                 {\r
113                         m_MipLevels = value;\r
114                 }\r
115 \r
116                 DXGI::Format ImageInformation::Format::get()\r
117                 {\r
118                         return m_Format;\r
119                 }\r
120 \r
121                 void ImageInformation::Format::set( DXGI::Format value )\r
122                 {\r
123                         m_Format = value;\r
124                 }\r
125 \r
126                 ResourceOptionFlags ImageInformation::OptionFlags::get()\r
127                 {\r
128                         return m_MiscFlags;\r
129                 }\r
130 \r
131                 void ImageInformation::OptionFlags::set( ResourceOptionFlags value )\r
132                 {\r
133                         m_MiscFlags = value;\r
134                 }\r
135                 \r
136                 ResourceDimension ImageInformation::Dimension::get()\r
137                 {\r
138                         return m_Dimension;\r
139                 }\r
140 \r
141                 void ImageInformation::Dimension::set( ResourceDimension value )\r
142                 {\r
143                         m_Dimension = value;\r
144                 }\r
145                 \r
146                 ImageFileFormat ImageInformation::FileFormat::get()\r
147                 {\r
148                         return m_FileFormat;\r
149                 }\r
150 \r
151                 void ImageInformation::FileFormat::set( ImageFileFormat value )\r
152                 {\r
153                         m_FileFormat = value;\r
154                 }\r
155                 \r
156                 Nullable<ImageInformation> ImageInformation::FromFile( String^ fileName )\r
157                 {\r
158                         D3DX10_IMAGE_INFO info;\r
159                         pin_ptr<const wchar_t> pinnedName = PtrToStringChars( fileName );\r
160                         HRESULT hr = D3DX10GetImageInfoFromFile( pinnedName, 0, &info, 0 );\r
161                         if( RECORD_D3D10( hr ).IsFailure )\r
162                                 return Nullable<ImageInformation>();\r
163                         \r
164                         return ImageInformation( info );\r
165                 }\r
166                 \r
167                 Nullable<ImageInformation> ImageInformation::FromMemory( array<Byte>^ memory )\r
168                 {\r
169                         D3DX10_IMAGE_INFO info;\r
170                         pin_ptr<unsigned char> pinnedMemory = &memory[0];\r
171                         HRESULT hr = D3DX10GetImageInfoFromMemory( pinnedMemory, memory->Length, 0, &info, 0 );\r
172                         if( RECORD_D3D10( hr ).IsFailure )\r
173                                 return Nullable<ImageInformation>();\r
174                         \r
175                         return ImageInformation( info );\r
176                 }\r
177 \r
178                 bool ImageInformation::operator == ( ImageInformation left, ImageInformation right )\r
179                 {\r
180                         return ImageInformation::Equals( left, right );\r
181                 }\r
182 \r
183                 bool ImageInformation::operator != ( ImageInformation left, ImageInformation right )\r
184                 {\r
185                         return !ImageInformation::Equals( left, right );\r
186                 }\r
187 \r
188                 int ImageInformation::GetHashCode()\r
189                 {\r
190                         return m_Width.GetHashCode() + m_Height.GetHashCode() + m_Depth.GetHashCode()\r
191                                 + m_ArraySize.GetHashCode() + m_MipLevels.GetHashCode() + m_MiscFlags.GetHashCode()\r
192                                 + m_Format.GetHashCode() + m_Dimension.GetHashCode() + m_FileFormat.GetHashCode();\r
193                 }\r
194 \r
195                 bool ImageInformation::Equals( Object^ value )\r
196                 {\r
197                         if( value == nullptr )\r
198                                 return false;\r
199 \r
200                         if( value->GetType() != GetType() )\r
201                                 return false;\r
202 \r
203                         return Equals( safe_cast<ImageInformation>( value ) );\r
204                 }\r
205 \r
206                 bool ImageInformation::Equals( ImageInformation value )\r
207                 {\r
208                         return (\r
209                                 m_Width == value.m_Width && \r
210                                 m_Height == value.m_Height && \r
211                                 m_Depth == value.m_Depth && \r
212                                 m_ArraySize == value.m_ArraySize && \r
213                                 m_MipLevels == value.m_MipLevels && \r
214                                 m_MiscFlags == value.m_MiscFlags && \r
215                                 m_Format == value.m_Format &&\r
216                                 m_Dimension == value.m_Dimension &&\r
217                                 m_FileFormat == value.m_FileFormat\r
218                         );\r
219                 }\r
220 \r
221                 bool ImageInformation::Equals( ImageInformation% value1, ImageInformation% value2 )\r
222                 {\r
223                         return (\r
224                                 value1.m_Width == value2.m_Width && \r
225                                 value1.m_Height == value2.m_Height && \r
226                                 value1.m_Depth == value2.m_Depth && \r
227                                 value1.m_ArraySize == value2.m_ArraySize && \r
228                                 value1.m_MipLevels == value2.m_MipLevels && \r
229                                 value1.m_MiscFlags == value2.m_MiscFlags && \r
230                                 value1.m_Format == value2.m_Format &&\r
231                                 value1.m_Dimension == value2.m_Dimension &&\r
232                                 value1.m_FileFormat == value2.m_FileFormat\r
233                         );\r
234                 }\r
235         }\r
236 }\r