cete.dynamicpdf.rasterizer.userpalette
UserPalette
- Namespace: ceTe.DynamicPDF.Rasterizer
- Assemblies: ceTe.DynamicPDF.Rasterizer.dll
Represents a UserPalette class which can be used to specify a color palette.
public class UserPalette : Palette
Public Class UserPalette
Inherits Palette
Inheritance: Object → Palette → UserPalette
Licensing
This class is a DynamicPDF Rasterizer feature. The following license is required for non-evaluation usage:
- DynamicPDF Rasterizer for .NET
Examples
This example demonstrates how to rasterize a PDF document to PNG image with a user palette.
Imports System
Imports ceTe.DynamicPDF.Rasterizer
Module MyModule
Sub Main()
' Create a PdfRasterizer object.
Dim rasterizer As PdfRasterizer = New PdfRasterizer("InputPdfFile.pdf")
Dim pngIndexedColorFormat As PngIndexedColorFormat = New PngIndexedColorFormat(ImageFormat.DefaultColorPalette,100,DitheringAlgorithm.FloydSteinberg)
Dim color() As System.Drawing.Color = New System.Drawing.Color() {System.Drawing.Color.FromArgb(255, 0, 0, 0), System.Drawing.Color.FromArgb(255, 255, 255, 255), System.Drawing.Color.FromArgb(255, 255, 0, 0), System.Drawing.Color.FromArgb(255, 0, 255, 0), System.Drawing.Color.FromArgb(255, 0, 0, 255), System.Drawing.Color.FromArgb(255, 255, 255, 0), System.Drawing.Color.FromArgb(255, 0, 255, 255)}
Dim userpalette As UserPalette = New UserPalette(color)
' Set a user selected color palette.
pngIndexedColorFormat.ColorPalette = userpalette
Dim pngImageFormat As PngImageFormat = New PngImageFormat(pngIndexedColorFormat)
' Save the image.
rasterizer.Draw("Output.png", pngImageFormat, ImageSize.Dpi72)
End Sub
End Module
using System;
using ceTe.DynamicPDF.Rasterizer;
class MyClass
{
static void Main(string[] args)
{
// Create a PdfRasterizer object.
PdfRasterizer rasterizer = new PdfRasterizer("InputPdfFile.pdf");
PngIndexedColorFormat pngIndexedColorFormat = new PngIndexedColorFormat(ImageFormat.DefaultColorPalette,100,DitheringAlgorithm.FloydSteinberg);
System.Drawing.Color[] color = new System.Drawing.Color[] { System.Drawing.Color.FromArgb(255,0,0,0),System.Drawing.Color.FromArgb(255,255,255,255),System.Drawing.Color.FromArgb(255,255,0,0),System.Drawing.Color.FromArgb(255,0,255,0),System.Drawing.Color.FromArgb(255,0,0,255),System.Drawing.Color.FromArgb(255,255,255,0),System.Drawing.Color.FromArgb(255,0,255,255),System.Drawing.Color.FromArgb(255,255,0,255)};
UserPalette userpalette = new UserPalette(color);
// Set a user selected color palette.
pngIndexedColorFormat.ColorPalette = userpalette;
PngImageFormat pngImageFormat = new PngImageFormat(pngIndexedColorFormat);
// Save the image.
rasterizer.Draw("Output.png", pngImageFormat, ImageSize.Dpi72);
}
}
Constructors
UserPalette(Color[])
Initializes a new instance of the UserPalette class.
public UserPalette(Color[] palette)
Public Sub New (palette As Color[])
Parameters
- palette: Color[]
A color palette.
Properties
Item[Int32]
Gets or sets color at specific index.
public Color this[int index] { get; set; }
Public Property Item(index As Integer) As Color
Property Value
Methods
Equals(Object)
Determines whether the specified Object is equal to the current Object . (Inherited from Object)
public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean
Parameters
- obj: Object
The Object to compare with the current Object .
Returns
true if the specified Object is equal to the current Object ; otherwise, false.
GetHashCode()
Serves as a hash function for a particular type. (Inherited from Object)
public int GetHashCode()
Function GetHashCode() As Integer
Returns
A hash code for the current Object .
GetType()
Gets the Type of the current instance. (Inherited from Object)
public Type GetType()
Function GetType() As Type
Returns
The Type instance that represents the exact runtime type of the current instance.
ToString()
Returns a String that represents the current Object . (Inherited from Object)
public string ToString()
Function ToString() As String
Returns
A String that represents the current Object .