// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using SharpDX.Mathematics.Interop;
namespace SharpDX.WIC
{
public partial class DdsFrameDecode
{
///
/// Gets the width and height, in blocks, of the DDS image.
///
///
/// For block compressed textures, the returned width and height values do not completely define the texture size because the image is padded to fit the closest whole block size. For example, three BC1 textures with pixel dimensions of 1x1, 2x2 and 4x4 will all report pWidthInBlocks = 1 and pHeightInBlocks = 1.
If the texture does not use a block-compressed , this method returns the texture size in pixels; for these formats the block size returned by IWICDdsFrameDecoder::GetFormatInfo is 1x1.
///
///
/// dn302089
/// HRESULT IWICDdsFrameDecode::GetSizeInBlocks([Out] unsigned int* pWidthInBlocks,[Out] unsigned int* pHeightInBlocks)
/// IWICDdsFrameDecode::GetSizeInBlocks
public Size2 SizeInBlocks
{
get
{
int width;
int height;
GetSizeInBlocks(out width, out height);
return new Size2(width, height);
}
}
///
/// [This documentation is preliminary and is subject to change.]
Requests pixel data as it is natively stored within the DDS file.
///
///
The rectangle to copy from the source. A null value specifies the entire texture.
If the texture uses a block-compressed , all values of the rectangle are expressed in number of blocks, not pixels.
/// The stride, in bytes, of the destination buffer. This represents the number of bytes from the buffer reference to the next row of data. If the texture uses a block-compressed , a "row of data" is defined as a row of blocks which contains multiple pixel scanlines.
/// A reference to the destination buffer.
/// If this method succeeds, it returns . Otherwise, it returns an error code.
///
/// If the texture does not use a block-compressed , this method behaves similarly to . However, it does not perform any pixel format conversion, and instead produces the raw data from the DDS file.
If the texture uses a block-compressed , this method copies the block data directly into the provided buffer. In this case, the prcBoundsInBlocks parameter is defined in blocks, not pixels. To determine if this is the case, call GetFormatInfo and read the DxgiFormat member of the returned structure.
///
///
///
/// dn302087
/// HRESULT IWICDdsFrameDecode::CopyBlocks([In, Optional] const WICRect* prcBoundsInBlocks,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer)
/// IWICDdsFrameDecode::CopyBlocks
public void CopyBlocks(RawBox? boundsInBlocks, int stride, DataStream destination)
{
CopyBlocks(boundsInBlocks, stride, (int)(destination.Length - destination.Position), destination.PositionPointer);
}
}
}