Returns information about the image on the canvas.

 

   
Syntax
 
     

[Visual Basic]
Function GetInfo(inType As String) As Object

[C#]
object GetInfo(inType As String);

 

   
Params
 
     
Name   Description
inType The type of information - "SelectionRect" or "Palette".
return The returned information.

 

   
Notes
 
     

This method allows access to a variety of information about a canvas. Currently the method supports two selectors.

  • "SelectionRect"
  • "Palette"

The SelectionRect selector returns the bounds of the current selection. The selection is the portion of the image that is visible using the image opacity held in the alpha channel. The return value is a string containing a rectangle (e.g. "10,10,40,40").

The Palette selector returns a raw palette for the image. This can be saved as a file - generally with the extension 'act' - or used in other calls such as those to ReduceColors. The return value is a raw array of bytes. You can only obtain palettes for canvases with 256 or fewer colors.

 

   
See Also
 
     

None.

 

   
Example
 
     

[Visual Basic]
Dim ca As New Canvas
ca.DrawFile(Server.MapPath("rez/main.jpg"), "")
ca.ReduceColors("adaptive", 8, True)
ca.SaveAs(Server.MapPath("main.gif"), "")

Dim plt As Byte()
plt = ca.GetInfo("palette")

ca.Clear()
ca.DrawFile(Server.MapPath("rez/sub.jpg"), "")
ca.ReduceColors(plt, 0, True)
ca.SaveAs(Server.MapPath("sub.gif"), "")

[C#]
Canvas ca = new Canvas();
ca.DrawFile(Server.MapPath("rez/main.jpg"), "");
ca.ReduceColors("adaptive", 8, true);
ca.SaveAs(Server.MapPath("main.gif"), "");

byte[] plt = (byte[])ca.GetInfo("palette");

ca.Clear();
ca.DrawFile(Server.MapPath("rez/sub.jpg"), "");
ca.ReduceColors(plt, 0, true);
ca.SaveAs(Server.MapPath("sub.gif"), "");

First we draw our main image onto a canvas and reduce the number of colors down to eight. We then save the image as a GIF and extracts the palette from the image using the GetInfo function. To apply the palette to another image we just use the ReduceColors method and pass in the palette we want to use.

The main and sub images are shown below.

main.jpg

sub.jpg

The output GIF images are shown below. Notice that both images use the same colors - chosen from the main image.

main.gif

. sub.gif