
90 Chapter 3
•
•
•
•
Example
#include "sys:color.ms"
.
.
.
var colors = media.getPalette();
if (colors.length >= 1)
{
var rgb = new RGBColor(colors[0]);
print("red is " + rgb.red);
}
getPaletteSize()
Returns the number of colors in the palette or 0 if the image does not have a palette.
Syntax
var nColors = <object name>.getPaletteSize();
Parameters
This function has no parameters.
getPixel()
Returns the color value, omitting any alpha channel. For RGB images, this will be a 24-bit
color value. For CMYK, a 32-bit color value.
Syntax
<object name>.getPixel(
X @ <pixel>
Y @ <pixel>
[layers @ <"layer list">] // (PSD files only)
);
Parameters
X and Y - specify the coordinates of the target pixel. The top-left corner of an image is
represented by the coordinates 0,0.
layers - for PSD files, specifies the layers to be included.The layer numbers begin at 0
(background) and go up. For more information see load() on page 101.
Example
var image = new Media();
image.load(name @ "peppers.psd");
if(image.getPixel(X @ 25, Y @ 100)== rgb(255,0,0))
{...