3 * Copyright (c) 2007-2010 SlimDX Group
\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
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\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
27 #include "Direct3D10Exception.h"
\r
29 #include "ImageInformation10.h"
\r
31 using namespace System;
\r
35 namespace Direct3D10
\r
37 ImageInformation::ImageInformation( const D3DX10_IMAGE_INFO& native )
\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
50 D3DX10_IMAGE_INFO ImageInformation::CreateNativeVersion()
\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
66 int ImageInformation::Width::get()
\r
71 void ImageInformation::Width::set( int value )
\r
76 int ImageInformation::Height::get()
\r
81 void ImageInformation::Height::set( int value )
\r
86 int ImageInformation::Depth::get()
\r
91 void ImageInformation::Depth::set( int value )
\r
96 int ImageInformation::ArraySize::get()
\r
101 void ImageInformation::ArraySize::set( int value )
\r
103 m_ArraySize = value;
\r
106 int ImageInformation::MipLevels::get()
\r
108 return m_MipLevels;
\r
111 void ImageInformation::MipLevels::set( int value )
\r
113 m_MipLevels = value;
\r
116 DXGI::Format ImageInformation::Format::get()
\r
121 void ImageInformation::Format::set( DXGI::Format value )
\r
126 ResourceOptionFlags ImageInformation::OptionFlags::get()
\r
128 return m_MiscFlags;
\r
131 void ImageInformation::OptionFlags::set( ResourceOptionFlags value )
\r
133 m_MiscFlags = value;
\r
136 ResourceDimension ImageInformation::Dimension::get()
\r
138 return m_Dimension;
\r
141 void ImageInformation::Dimension::set( ResourceDimension value )
\r
143 m_Dimension = value;
\r
146 ImageFileFormat ImageInformation::FileFormat::get()
\r
148 return m_FileFormat;
\r
151 void ImageInformation::FileFormat::set( ImageFileFormat value )
\r
153 m_FileFormat = value;
\r
156 Nullable<ImageInformation> ImageInformation::FromFile( String^ fileName )
\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
164 return ImageInformation( info );
\r
167 Nullable<ImageInformation> ImageInformation::FromMemory( array<Byte>^ memory )
\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
175 return ImageInformation( info );
\r
178 bool ImageInformation::operator == ( ImageInformation left, ImageInformation right )
\r
180 return ImageInformation::Equals( left, right );
\r
183 bool ImageInformation::operator != ( ImageInformation left, ImageInformation right )
\r
185 return !ImageInformation::Equals( left, right );
\r
188 int ImageInformation::GetHashCode()
\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
195 bool ImageInformation::Equals( Object^ value )
\r
197 if( value == nullptr )
\r
200 if( value->GetType() != GetType() )
\r
203 return Equals( safe_cast<ImageInformation>( value ) );
\r
206 bool ImageInformation::Equals( ImageInformation value )
\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
221 bool ImageInformation::Equals( ImageInformation% value1, ImageInformation% value2 )
\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