BitmapAndColor

Functions for dealing with color values and bitmaps.

ClampColor
Clamps a color to the range 0-255.
DrawCrosshair
Draws a crosshair on a bitmap.
GetCroppedBitmap
Gets a sub-rectangle of a bitmap.
GetHue
Gets a pure RGB value from passed HSV value.
HSVtoRGB
Converts a HSV value to an RGB value.
InvertColor
Inverts a color.
Noise3bmp
Create a bitmap based on Noise3 values.
Noise4bmp
Create a bitmap based on Noise4 values.
OpenBitmapNoGamma
Opens a bitmap with forced linear gamma.

ClampColor (mapped):

Clamps a color passed to the range 0-255.

Returns:

The clamped color (also updates passed value).

Arguments:
%<col>
The color to clamp

Back to top...


DrawCrosshair:

Draws a crosshair on a bitmap.
The crosshair's color is the inverse of the background color. Drawing the crosshair twice in the same location will "erase" the crosshair.

Returns:

The bitmap with the crosshair drawn on it (Note: the original bitmap is modified)

Arguments:
%<bmp>
The bitmap to draw on.
<nCrossPos>
The normalized position where to draw the crosshair on the bitmap.
[0.0,0.0] == upper left, [1.0,1.0] == lower right
[crossSize:10]
The size of the crosshair, in pixels.

Back to top...


GetCroppedBitmap:

Gets a sub-rectangle of a bitmap.

Returns:

A new bitmap the size of the passed in rectangle, or undefined on failure.

Arguments:
<bmp>
The bitmap to copy from.
<UpperLeft>
A Point2 coordinate of the zero-based pixel location of the upper left corner of the crop window.
<LowerRight>
A Point2 coordinate of the zero-based pixel location of the lower right corner of the crop window. Must be below and to the right of UpperLeft.

Back to top...


GetHue:

Gets a pure RGB value from passed HSV hue value.

Returns:

A color value.

Arguments:
<hue>
The hue, in the range of 0-1 in the spectrum.

Back to top...


HSVtoRGB:

Converts an HSV value to an RGB value.
All HSV values should range from 0 to 1

Returns:

A color value.

Arguments:
<hue>
The hue of the color to be converted.
<saturation>
The saturation of the color to be converted.
<value>
The value of the color to be converted.

Back to top...


InvertColor:

Inverts a color.

Returns:

A new color value, with each of its RGB components inverted.

Arguments:
<aColor>
The color to invert.

Back to top...


Noise3bmp:

Create a bitmap based on Noise3 values.

Returns:

Bitmap containing a noise texture.

Arguments:
<xRes>
X resolution of returned bitmap
<yRes>
Y resolution of returned bitmap
<scale>
Scale of the noise in the resulting bitmap

Back to top...


Noise4bmp:

Create a bitmap based on Noise4 values.

Returns:

Bitmap containing a noise texture.

Arguments:
<xRes>
X resolution of returned bitmap
<yRes>
Y resolution of returned bitmap
<scale>
Scale of the noise in the resulting bitmap
<phase>
The phase of the created noise

Back to top...


OpenBitmapNoGamma:

Opens a bitmap with forced linear gamma.

Returns:

Bitmap containing opened bitmap, or undefined on failure.

Arguments:
<fileString>
Full path and filename for the bitmap to be opened.

Back to top...