This class enables you to write PNG images.
Namespace:
Aurigma.GraphicsMill.Codecs
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
Public NotInheritable Class PngWriter _ Inherits FormatWriter
public sealed class PngWriter : FormatWriter
The Portable Network Graphics (PNG) format was designed to replace the older and simpler GIF format and, to some extent, the much more complex TIFF format. Besides of it, PNG was developed to avoid legal problems which was caused by LZW algorithm used in GIF and sometimes in TIFF. For the Web, PNG really has four main advantages over GIF:
PNG supports images of most Graphics Mill for .NET pixel formats (indexed, grayscale, and RGB, including extended versions). Being web-oriented, it does not support CMYK images. Only single bitmap can be stored into single PNG file (i.e. it has no multiple frames support).
Also you can use PngWriter class instead of the Save(String, IEncoderOptions) method of the Bitmap. In particular it enables you to save the image asynchronously.
The PngWriter class usage is demonstrated below:
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg") Dim writer As New Aurigma.GraphicsMill.Codecs.PngWriter("C:\Mountain.png") Dim frame As New Aurigma.GraphicsMill.Codecs.PngFrame frame.Interlaced = True frame.SetBitmap(bitmap) bitmap.Dispose() writer.AddFrame(frame) frame.Dispose() writer.Dispose()
using (Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg")) { using (Aurigma.GraphicsMill.Codecs.PngWriter writer = new Aurigma.GraphicsMill.Codecs.PngWriter(@"C:\Mountain.png")) { using (Aurigma.GraphicsMill.Codecs.PngFrame frame = new Aurigma.GraphicsMill.Codecs.PngFrame()) { frame.Interlaced = true; frame.SetBitmap(bitmap); writer.AddFrame(frame); } } }
This code sample converts the image into the indexed bitmap with 32 palette entries. After that it saves this bitmap into the PNG file.
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg") bitmap.ColorManagement.PaletteEntryCount = 32 bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, _ Nothing) Dim writer As New Aurigma.GraphicsMill.Codecs.PngWriter("C:\Mountain.png") Dim frame As New Aurigma.GraphicsMill.Codecs.PngFrame frame.Interlaced = True frame.SetBitmap(bitmap) bitmap.Dispose() writer.AddFrame(frame) frame.Dispose() writer.Dispose()
using (Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg")) { bitmap.ColorManagement.PaletteEntryCount = 32; bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, null); using (Aurigma.GraphicsMill.Codecs.PngWriter writer = new Aurigma.GraphicsMill.Codecs.PngWriter(@"C:\Mountain.png")) { using (Aurigma.GraphicsMill.Codecs.PngFrame frame = new Aurigma.GraphicsMill.Codecs.PngFrame()) { frame.Interlaced = true; frame.SetBitmap(bitmap); writer.AddFrame(frame); } } }
Member Name | Description |
---|---|
Format1bppIndexed | 1 bit per pixel. Indexed. |
Format4bppIndexed | 4 bits per pixel. Indexed. |
Format8bppIndexed | 8 bits per pixel. Indexed. |
Format8bppGrayScale | 8 bits per pixel. Grayscale. 8 bits are used for luminosity level. |
Format16bppGrayScale | 16 bits per pixel. Grayscale. All 16 bits are used for luminosity level (extended pixel format). |
Format16bppAGrayScale | 16 bits per pixel. Grayscale with alpha channel. 8 bits are used for alpha channel and other 8 bits are used for luminosity level. |
Format32bppAGrayScale | 32 bits per pixel. Grayscale with alpha channel. 16 bits are used for alpha channel and other 16 bits are used for luminosity level (extended pixel format). |
Format24bppRgb | 24 bits per pixel. RGB. 8 bits each are used for the red, green, and blue components. |
Format32bppRgb | 32 bits per pixel. RGB. 8 bits each are used for the red, green, and blue components. The rest 8 bits are unused. |
Format32bppArgb | 32 bits per pixel. RGB with alpha channel. 8 bits each are used for the alpha, red, green, and blue components. |
Format48bppRgb | 48 bits per pixel. RGB. 16 bits each are used for the red, green, and blue components (extended pixel format). |
Format64bppArgb | 64 bits per pixel. RGB with alpha channel. 16 bits each are used for the alpha, red, green, and blue components (extended pixel format). |