// 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; using System.Runtime.InteropServices; namespace SharpDX.WIC { public partial class Bitmap { /// /// Initializes a new instance of the class. /// /// The factory. /// The width. /// The height. /// The pixel format. for a list of valid formats. /// The option. /// ee690282 /// HRESULT IWICImagingFactory::CreateBitmap([In] unsigned int uiWidth,[In] unsigned int uiHeight,[In] const GUID& pixelFormat,[In] WICBitmapCreateCacheOption option,[Out, Fast] IWICBitmap** ppIBitmap) /// IWICImagingFactory::CreateBitmap public Bitmap(ImagingFactory factory, int width, int height, System.Guid pixelFormat, SharpDX.WIC.BitmapCreateCacheOption option) : base(IntPtr.Zero) { factory.CreateBitmap(width, height, pixelFormat, option, this); } /// /// Initializes a new instance of the class from a memory location using . /// /// The factory. /// The width. /// The height. /// The pixel format. /// The data rectangle. /// Size of the buffer in . If == 0, calculate the size automatically based on the height and row pitch. /// ee690291 /// HRESULT IWICImagingFactory::CreateBitmapFromMemory([In] unsigned int uiWidth,[In] unsigned int uiHeight,[In] const GUID& pixelFormat,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer,[Out, Fast] IWICBitmap** ppIBitmap) /// IWICImagingFactory::CreateBitmapFromMemory public Bitmap(ImagingFactory factory, int width, int height, System.Guid pixelFormat, DataRectangle dataRectangle, int totalSizeInBytes = 0) : base(IntPtr.Zero) { if (totalSizeInBytes == 0) totalSizeInBytes = height*dataRectangle.Pitch; factory.CreateBitmapFromMemory(width, height, pixelFormat, dataRectangle.Pitch, totalSizeInBytes, dataRectangle.DataPointer, this); } /// /// Initializes a new instance of the class from a /// /// The factory. /// The bitmap source ref. /// The option. /// ee690293 /// HRESULT IWICImagingFactory::CreateBitmapFromSource([In, Optional] IWICBitmapSource* pIBitmapSource,[In] WICBitmapCreateCacheOption option,[Out, Fast] IWICBitmap** ppIBitmap) /// IWICImagingFactory::CreateBitmapFromSource public Bitmap(ImagingFactory factory, SharpDX.WIC.BitmapSource bitmapSource, SharpDX.WIC.BitmapCreateCacheOption option) : base(IntPtr.Zero) { factory.CreateBitmapFromSource(bitmapSource, option, this); } /// /// Initializes a new instance of the class from a . /// /// The factory. /// The bitmap source. /// The rectangle. /// ee690294 /// HRESULT IWICImagingFactory::CreateBitmapFromSourceRect([In, Optional] IWICBitmapSource* pIBitmapSource,[In] unsigned int x,[In] unsigned int y,[In] unsigned int width,[In] unsigned int height,[Out, Fast] IWICBitmap** ppIBitmap) /// IWICImagingFactory::CreateBitmapFromSourceRect public Bitmap(ImagingFactory factory, SharpDX.WIC.BitmapSource bitmapSource, RawBox rectangle) : base(IntPtr.Zero) { factory.CreateBitmapFromSourceRect(bitmapSource, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, this); } /// /// Initializes a new instance of the class from an array of pixel data. /// /// The factory. /// The width. /// The height. /// The pixel format. /// The pixel data. /// Stride of a row of pixels (number of bytes per row). By default the stride is == 0, and calculated by taking the sizeof(T) * width. /// ee690291 /// HRESULT IWICImagingFactory::CreateBitmapFromMemory([In] unsigned int uiWidth,[In] unsigned int uiHeight,[In] const GUID& pixelFormat,[In] unsigned int cbStride,[In] unsigned int cbBufferSize,[In] void* pbBuffer,[Out, Fast] IWICBitmap** ppIBitmap) /// IWICImagingFactory::CreateBitmapFromMemory public unsafe static Bitmap New(ImagingFactory factory, int width, int height, System.Guid pixelFormat, T[] pixelDatas, int stride = 0) where T : struct { if (stride == 0) stride = width * Utilities.SizeOf(); return new Bitmap(factory, width, height, pixelFormat, new DataRectangle((IntPtr)Interop.Fixed(pixelDatas), stride)); } /// ///

Provides access to a rectangular area of the bitmap.

///
///

The access mode you wish to obtain for the lock. This is a bitwise combination of for read, write, or read and write access.

ValueMeaning

The read access lock.

The write access lock.

?

///

A reference that receives the locked memory location.

/// ///

Locks are exclusive for writing but can be shared for reading. You cannot call CopyPixels while the is locked for writing. Doing so will return an error, since locks are exclusive.

///
/// ee690187 /// HRESULT IWICBitmap::Lock([In, Optional] const WICRect* prcLock,[In] WICBitmapLockFlags flags,[Out] IWICBitmapLock** ppILock) /// IWICBitmap::Lock public SharpDX.WIC.BitmapLock Lock(SharpDX.WIC.BitmapLockFlags flags) { return Lock(IntPtr.Zero, flags); } /// ///

Provides access to a rectangular area of the bitmap.

///
///

The rectangle to be accessed.

///

The access mode you wish to obtain for the lock. This is a bitwise combination of for read, write, or read and write access.

ValueMeaning

The read access lock.

The write access lock.

?

///

A reference that receives the locked memory location.

/// ///

Locks are exclusive for writing but can be shared for reading. You cannot call CopyPixels while the is locked for writing. Doing so will return an error, since locks are exclusive.

///
/// ee690187 /// HRESULT IWICBitmap::Lock([In, Optional] const WICRect* prcLock,[In] WICBitmapLockFlags flags,[Out] IWICBitmapLock** ppILock) /// IWICBitmap::Lock public unsafe SharpDX.WIC.BitmapLock Lock(RawBox rcLockRef, SharpDX.WIC.BitmapLockFlags flags) { return this.Lock(new IntPtr(&rcLockRef), flags); } } }