[Registered version only]
BuildPalette
The BuildPalette function rebuilds image palette in accordance with real image colors.
BuildPalette
nImportantColors
Parameters
-
nImportantColors
-
Specifies the number of impotant colors in the image. These are first
nImportantColors colors in the image palette. These palette
entries will not be changed.
Remarks
ShotGraph imagespace contains a true color image. However, some image file formats supports
only a number of colors in the image (palette). Making such image, usually you need to degrade
the amount of colors in the imagespace.
If colors of image pixels in
the imagespace don't match the colors declared by SetColor method or if
colors of image pixels are unknown then use this method.
This method reconstructs image palette and changes its entries except
first nImportantColors colors.
Call this method once in your script just before calling GifImage or other function
creating paletted images. This improves
the image quality in case if you used some operations which can add
other colors into imagespace, like the following:
- Drawing texts or lines with antialiasing
- Reading external images
- Importing external objects
See too
CreateImage,
SetColor
Example
<%@ Language=VBScript %>
<%
Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")
size=100
obj.CreateImage size,size,16
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
obj.SetColor 2,255,108,0
obj.SetBgColor 0
obj.FillRect 0,0,size-1,size-1
obj.SetTextAlign "TA_CENTER","TA_BASELINE"
obj.SetBkColor 0
obj.SetTextColor 1
obj.CreateFont "Arial",0,22,0,True,False,False,False
obj.TextOut size/2,24,"Text1"
obj.SetTextColor 2
obj.CreateFont "Arial",0,15,0,True,False,False,False
obj.TextOut size/2,size/2,"Text2"
obj.BuildPalette 3
img=obj.GifImage(-1,1,"")
Response.BinaryWrite(img)
%>
Results:
| Without BuildPalette |
With BuildPalette |
 |
 |