[]
Represents a bitmap that uses the Direct2D system API. Can be used for fast and efficient rendering on Windows systems that support Direct2D.
public class GcD2DBitmap : IImage, IDisposable
Initializes a new instance of the GcD2DBitmap class.
public GcD2DBitmap()
Initializes a new instance of the GcD2DBitmap class and creates the image.
The image content is not initialized and can contain any random data.
public GcD2DBitmap(int pixelWidth, int pixelHeight, float dpiX = 96, float dpiY = 96)
pixelWidth
intThe width of the image, in pixels.
pixelHeight
intThe height of the image, in pixels.
dpiX
floatThe horizontal dpi of the image.
dpiY
floatThe vertical dpi of the image.
Gets an instance of the Device class.
public Device D2DDevice { get; }
Gets an instance of the Factory1 class.
public Factory1 D2DFactory { get; }
Gets an instance of the DeviceContext class.
public DeviceContext DeviceContext { get; }
Gets the x-axis DPI resolution.
public float DpiX { get; }
Gets the y-axis DPI resolution.
public float DpiY { get; }
Gets an instance of the Factory1 class.
The factory becomes available after initializing the font cache (see the SetFontCache(FontCache) method).
public Factory1 DWFactory { get; }
Gets an instance of the GcD2DBitmapGraphics class.
The Graphics becomes available after executing the CreateGraphics(Color?) method.
public GcD2DBitmapGraphics Graphics { get; }
Gets the height of the image, in DIPs.
public float Height { get; }
Gets a value indicating whether the GcD2DBitmap has been disposed of.
public bool IsDisposed { get; }
Gets the pixel height of the image.
public int PixelHeight { get; }
Gets the pixel width of the image.
public int PixelWidth { get; }
Gets the width of the image, in DIPs.
public float Width { get; }
Applies a license key to an instance of GcWicBitmap.
public void ApplyLicenseKey(string key)
key
stringThe license key to set.
Creates an instance of the GcD2DBitmapGraphics class.
public GcD2DBitmapGraphics CreateGraphics(Color? backColor = null)
backColor
System.Drawing.Color?If not null, specifies the color that is used to initialize the image.
The new instance of GcD2DBitmapGraphics.
Creates an image with the given size and resolution.
The content is not initialized by this method and can contain any random data.
public void CreateImage(int pixelWidth, int pixelHeight, float dpiX, float dpiY)
pixelWidth
intThe width of the image, in pixels.
pixelHeight
intThe height of the image, in pixels.
dpiX
floatThe horizontal resolution (DPI) of the image.
dpiY
floatThe vertical resolution (DPI) of the image.
Creates an image with the given size and 96 DPI resolution.
public void CreateImage(int pixelWidth, int pixelHeight)
pixelWidth
intThe width of the image, in pixels.
pixelHeight
intThe height of the image, in pixels.
Discards the internal image and clears all metadata.
public void DiscardImage()
Cleans up the resources that were used.
public void Dispose()
Performs cleanup operations on managed and unmanaged resources.
protected virtual void Dispose(bool disposing)
disposing
boolPerforms cleanup operations on unmanaged resources.
protected ~GcD2DBitmap()
Loads the image from a stream.
public void Load(Stream stream, WicContainerFormat containerFormat = WicContainerFormat.Unknown, int frameIndex = 0)
stream
System.IO.StreamThe input stream.
containerFormat
WicContainerFormatThe image container format; use Unknown to detect the format automatically.
frameIndex
intIndex of an image frame to read; pass 0 for image formats not supporting multiple frames.
Loads the image from a file.
public void Load(string path, WicContainerFormat containerFormat = WicContainerFormat.Unknown, int frameIndex = 0)
path
stringThe file path to the image.
containerFormat
WicContainerFormatThe image container format; use Unknown to detect the format automatically.
frameIndex
intIndex of an image frame to read; pass 0 for image formats not supporting multiple frames.
Saves the image to a stream using the specified format and options.
public void Save(Stream stream, WicContainerFormat format, BaseOptions options = null)
stream
System.IO.StreamThe output stream.
format
WicContainerFormatThe container format that determines the image encoder.
options
BaseOptionsThe options for the specified image encoder.
Saves the image to a file using the specified format and options.
public void Save(string fileName, WicContainerFormat format, BaseOptions options = null)
fileName
stringThe output file name.
format
WicContainerFormatThe container format that determines the image encoder.
options
BaseOptionsThe options for the specified image encoder.
Saves the image to a stream in BMP format.
public void SaveAsBmp(Stream stream, BmpOptions options = null)
stream
System.IO.StreamThe output stream.
options
BmpOptionsThe options for the BMP image encoder.
Saves the image to a file in BMP format.
public void SaveAsBmp(string fileName, BmpOptions options = null)
fileName
stringThe output file name.
options
BmpOptionsThe options for the BMP image encoder.
Saves the image to a stream in GIF format.
public void SaveAsGif(Stream stream, GifOptions options = null)
stream
System.IO.StreamThe output stream.
options
GifOptionsThe options for the GIF image encoder.
Saves the image to a file in GIF format.
public void SaveAsGif(string fileName, GifOptions options = null)
fileName
stringThe output file name.
options
GifOptionsThe options for the GIF image encoder.
Saves the image to a stream in JPEG format.
public void SaveAsJpeg(Stream stream, JpegOptions options = null)
stream
System.IO.StreamThe output stream.
options
JpegOptionsThe options for the JPEG image encoder.
Saves the image to a file in JPEG format.
public void SaveAsJpeg(string fileName, JpegOptions options = null)
fileName
stringThe output file name.
options
JpegOptionsThe options for the JPEG image encoder.
Saves the image to a stream in JPEG XR format.
public void SaveAsJpegXR(Stream stream, JpegXROptions options = null)
stream
System.IO.StreamThe output stream.
options
JpegXROptionsThe options for the JPEG XR image encoder.
Saves the image to a file in JPEG XR format.
public void SaveAsJpegXR(string fileName, JpegXROptions options = null)
fileName
stringThe output file name.
options
JpegXROptionsThe options for the JPEG XR image encoder.
Saves the image to a stream in PNG format.
public void SaveAsPng(Stream stream, PngOptions options = null)
stream
System.IO.StreamThe output stream.
options
PngOptionsThe options for the PNG image encoder.
Saves the image to a file in PNG format.
public void SaveAsPng(string fileName, PngOptions options = null)
fileName
stringThe output file name.
options
PngOptionsThe options for the PNG image encoder.
Saves the image to a stream in TIFF format.
public void SaveAsTiff(Stream stream, TiffOptions options = null)
stream
System.IO.StreamThe output stream.
options
TiffOptionsThe options for the TIFF image encoder.
Saves the image to a file in TIFF format.
public void SaveAsTiff(string fileName, TiffOptions options = null)
fileName
stringThe output file name.
options
TiffOptionsThe options for the TIFF image encoder.
Assigns a shared instance of the GrapeCity.Documents.Imaging.Windows.GcD2DBitmap.FontCache class to be used by this bitmap.
public void SetFontCache(FontCache fontCache)
fontCache
FontCacheSets the license key.
public static void SetLicenseKey(string key)
key
stringThe license key to set.
Copies the image buffer to a new GcBitmap.
public GcBitmap ToGcBitmap()
Copies the image buffer to an existing instance of GcBitmap.
public void ToGcBitmap(GcBitmap bmp)