Object Model Reference : Classes : S : StructPaletteOptions : Properties : StructPaletteOptions.Palette |
Property Palette As Variant
Member of StructPaletteOptions
The Palette property specifies the palette when exporting a full-color image to a paletted bitmap.
The following VBA example exports a document with the new custom color palette:
Sub Test() |
Dim d As Document |
Dim e As ExportFilter |
Dim s As Shape |
Dim sp As New StructPaletteOptions |
Dim p As Palette |
Set d = CreateDocument |
Set s = d.ActiveLayer.CreateRectangle(3, 3, 7, 7) |
s.Fill.ApplyFountainFill CreateRGBColor(255, 0, 0), CreateRGBColor(0, 0, 255) |
' Change the palette type to custom. |
sp.PaletteType = cdrPaletteCustom |
' Create a new palette and add some colors. |
Set p = Palettes.Create("Temp") |
p.AddColor CreateRGBColor(255, 0, 0) |
p.AddColor CreateRGBColor(0, 0, 255) |
p.AddColor CreateRGBColor(0, 255, 0) |
' Set the palette to use for the export to the newly created palette. |
sp.Palette = p |
d.Export "C:\Test_ExportPalette_Passing_a_Palette.gif", cdrGIF, , , sp |
End Sub |
The following VBA example exports a document with a custom palette that is identified by its path and filename:
Sub Test() |
Dim d As Document |
Dim e As ExportFilter |
Dim s As Shape |
Dim sp As New StructPaletteOptions |
Set d = CreateDocument |
Set s = d.ActiveLayer.CreateRectangle(3, 3, 7, 7) |
s.Fill.ApplyFountainFill CreateRGBColor(255, 0, 0), CreateRGBColor(0, 0, 255) |
' Change the palette type to custom. |
sp.PaletteType = cdrPaletteCustom |
' Set the palette to use for the export to the filename of the existing palette. |
sp.Palette = SetupPath & "Custom Data\Palettes\CMYK\Nature\cEarthy.xml" |
d.Export "C:\Test_ExportPalette_Passing_a_Filename.gif", cdrGIF, , , sp |
End Sub |
The following VBA example exports a document with a custom palette that is defined by an array of long values (which represent colors):
Sub Test() |
Dim d As Document |
Dim e As ExportFilter |
Dim s As Shape |
Dim sp As New StructPaletteOptions |
Set d = CreateDocument |
Set s = d.ActiveLayer.CreateRectangle(3, 3, 7, 7) |
s.Fill.ApplyFountainFill CreateRGBColor(255, 0, 0), CreateRGBColor(0, 0, 255) |
' Change the palette type to custom. |
sp.PaletteType = cdrPaletteCustom |
' Set the palette to use for the export to an array of longs which represent the colors to use. |
sp.Palette = Array(RGB(255, 0, 0), RGB(0, 0, 255), RGB(125, 0, 0), RGB(0, 0, 125), RGB(155, 0, 0), RGB(0, 0, 155), RGB(175, 32, 175)) |
d.Export "C:\Test_ExportPalette_Passing_an_array_of_longs.gif", cdrGIF, , , sp |
End Sub |
The following VBA example exports a document with a custom palette that is defined by an array of colors:
Sub Test() |
Dim d As Document |
Dim e As ExportFilter |
Dim s As Shape |
Dim sp As New StructPaletteOptions |
Set d = CreateDocument |
Set s = d.ActiveLayer.CreateRectangle(3, 3, 7, 7) |
s.Fill.ApplyFountainFill CreateRGBColor(255, 0, 0), CreateRGBColor(0, 0, 255) |
' Change the palette type to custom |
sp.PaletteType = cdrPaletteCustom |
' Set the palette to use for the export to an array of colors |
sp.Palette = Array(CreateCMYKColor(0, 77, 23, 23), CreateCMYKColor(10, 23, 43, 54), CreateCMYKColor(54, 12, 88, 12)) |
d.Export "C:\Test_ExportPalette_Passing_an_array_of_colors.gif", cdrGIF, , , sp |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.