// 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 System; using SharpDX.Mathematics.Interop; namespace SharpDX.WIC { public partial class BitmapSource { /// ///

Retrieves the pixel width and height of the bitmap.

///
/// HRESULT IWICBitmapSource::GetSize([Out] unsigned int* puiWidth,[Out] unsigned int* puiHeight) /// ee690185 /// HRESULT IWICBitmapSource::GetSize([Out] unsigned int* puiWidth,[Out] unsigned int* puiHeight) /// IWICBitmapSource::GetSize public Size2 Size { get { int width, height; GetSize(out width, out height); return new Size2(width, height); } } /// ///

Instructs the object to produce pixels.

///
///

The rectangle to copy. A null value specifies the entire bitmap.

///

The stride of the bitmap

///

A reference to the buffer.

/// ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

///
/// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels public unsafe void CopyPixels(RawBox rectangle, int stride, DataPointer dataPointer) { CopyPixels(new IntPtr(&rectangle), stride, (int) dataPointer.Size, dataPointer.Pointer); } /// ///

Instructs the object to produce pixels.

///
///

The stride of the bitmap

///

A reference to the buffer.

/// ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

///
/// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels public void CopyPixels(int stride, DataPointer dataPointer) { CopyPixels(IntPtr.Zero, stride, (int)dataPointer.Size, dataPointer.Pointer); } /// ///

Instructs the object to produce pixels.

///
///

The stride of the bitmap

///

A reference to the buffer.

/// Size of the buffer in bytes. /// ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

///
/// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels public void CopyPixels(int stride, IntPtr dataPointer, int size) { CopyPixels(IntPtr.Zero, stride, size, dataPointer); } /// ///

Instructs the object to produce pixels.

///
/// Type of a pixel. This parameter must exactly match a pixel like using for a 32bit RGBA color or for a 64bits for a RGBA 4 floats color. ///

The rectangle to copy. A null value specifies the entire bitmap.

/// The destination array. The size of the array must be sizeof(pixel) * rectangle.Width * rectangle.Height ///

If this method succeeds, it returns . Otherwise, it returns an error code.

/// output.Length must be equal to Width * Height /// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

public unsafe void CopyPixels(RawBox rectangle, T[] output) where T : struct { if ((rectangle.Width * rectangle.Height) != output.Length) throw new ArgumentException("output.Length must be equal to Width * Height"); CopyPixels(new IntPtr(&rectangle), rectangle.Width * Utilities.SizeOf(), (int)output.Length * Utilities.SizeOf(), (IntPtr)Interop.Fixed(output)); } /// ///

Instructs the object to produce pixels.

///
/// Type of a pixel. This parameter must exactly match a pixel like using for a 32bit RGBA color or for a 64bits for a RGBA 4 floats color. /// The destination array. The size of the array must be sizeof(pixel) * Width * Height ///

If this method succeeds, it returns . Otherwise, it returns an error code.

/// ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

///
/// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels public unsafe void CopyPixels(T[] output) where T : struct { var size = Size; if ( (size.Width * size.Height) != output.Length) throw new ArgumentException("output.Length must be equal to Width * Height"); CopyPixels(IntPtr.Zero, Size.Width * Utilities.SizeOf(), (int)output.Length * Utilities.SizeOf(), (IntPtr)Interop.Fixed(output)); } /// ///

Instructs the object to produce pixels.

///
/// The destination array. The size of the array must be sizeof(pixel) * Width * Height /// The stride (number of bytes per row). ///

If this method succeeds, it returns . Otherwise, it returns an error code.

/// output.Length must be equal to Width * Height /// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

public unsafe void CopyPixels(RawRectangle rectangle, byte[] output, int stride) { if (output == null) throw new ArgumentNullException("output"); if (stride <= 0) throw new ArgumentOutOfRangeException("stride", "Must be > 0"); if ((output.Length % stride) != 0) throw new ArgumentException("output.Length must be a modulo of stride"); CopyPixels(new IntPtr(&rectangle), stride, output.Length, (IntPtr)Interop.Fixed(output)); } /// ///

Instructs the object to produce pixels.

///
/// The destination array. The size of the array must be sizeof(pixel) * Width * Height /// The stride (number of bytes per row). ///

If this method succeeds, it returns . Otherwise, it returns an error code.

/// output.Length must be equal to Width * Height /// ee690179 /// HRESULT IWICBitmapSource::CopyPixels([In, Optional] const WICRect* prc,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer) /// IWICBitmapSource::CopyPixels ///

CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.

The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null ROI implies that the whole bitmap should be returned. ///

The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.

If the caller needs to perform numerous copies of an expensive such as a JPEG, it is recommended to create an in-memory first.

Codec Developer Remarks

The callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).

public unsafe void CopyPixels(byte[] output, int stride) { if(output == null) throw new ArgumentNullException("output"); if (stride <= 0) throw new ArgumentOutOfRangeException("stride", "Must be > 0"); if ((output.Length % stride)!= 0) throw new ArgumentException("output.Length must be a modulo of stride"); CopyPixels(IntPtr.Zero, stride, output.Length, (IntPtr)Interop.Fixed(output)); } } }