RGBSurface.Transform

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

RGBSurface.Transform(map() As Integer)

Supported for all project types and targets.


Method

RGBSurface.Transform(redMap() As Integer, greenMap() As Integer, blueMap() As Integer)

Supported for all project types and targets.

Applies a one-to-one pixel transformation to all pixels of an RGBSurface.

Notes

Transform is overloaded. You can specify the transformation via either of three lookup tables, redMap, greenMap, and blueMap, or one lookup table to apply to all three channels.

Each map parameter is an 256 element array of integers. The transformation works as follows: For each pixel, the pixel's RGB value is used as an index into the map arrays and the value found becomes the new R, G, or B value for the pixel.

For example, if you set up a map such that map(i)=255-i, then calling Transform(Map) will invert the image.

Example

The following example uses the Transform method to invert an image:

Const kMaxMapOffset = 255
Var map(kMaxMapOffset) As Integer
For i As Integer = 0 To kMaxMapOffset
map(i) = kMaxMapOffset - i
Next
somePicture.RGBSurface.Transform(map)