Name
hw_Remap -- remap image colors (V9.0)
Synopsis
int ok = hw_Remap(APTR src, UBYTE *dst, struct hwRemapCtrl *ctrl,
             ULONG flags, struct hwTagList *tags);
Function
This function can be used to remap the colors of the pixel data passed in src. hw_Remap() can be used to remap both RGB and CLUT data. If you want to remap RGB data, you need to pass a 32-bit pixel array in src. For CLUT data, the array needs to use 8-bit pixels. The result will always be CLUT pixel data and it will be copied to the buffer specified in dst.

The third parameter must be a pointer to a struct hwRemapCtrl. This structure looks like this:

 
struct hwRemapCtrl
{
    int Width;
    int Height;
    int SrcDepth;
    int DstDepth;
    ULONG *SrcPalette;
    ULONG *DstPalette;
    ULONG SrcTransPen;
    ULONG DstTransPen;
};

Here's how the individual structure members need to be initialized:

Width:
Must be set to the image width in pixels.

Height:
Must be set to the image height in pixels.

SrcDepth:
The depth of the pixel data in the src buffer. This can be either a bit depth value between 1 and 8 or 32.

DstDepth:
The desired depth of the pixel data after remapping. This must be set to a value between 1 and 8.

SrcPalette:
If SrcDepth is not 32, you must set this member to a ULONG array containing the colors of the source pixels. Colors are stored as raw RGB values inside the array. Note that the ULONG array you specify here must always have 256 entries, even if SrcDepth is less than 8.

DstPalette:
If SrcDepth is between 1 and 8, you must set this member to a ULONG array containing the colors the image should be remapped to. Colors must be stored as raw RGB values inside the array. Note that the ULONG array you specify here must always have 256 entries, even if DstDepth is less than 8.

When the source data is RGB, you can set the HWREMAPFLAGS_MAKEPALETTE flag (see below). In that case, hw_Remap() will copy the palette it has remapped the RGB data to to the buffer in DstPalette. Note that this buffer must have 256 entries, even if DstDepth was set to something less than 8.

SrcTransPen:
If SrcDepth is between 1 and 8, set this to the pen that is transparent in the source data or to HWPEN_NONE for no transparent pen.

DstTransPen:
If SrcDepth is between 1 and 8, this can be set to a pen that shall be made transparent in the resulting pixel data. Set it to HWPEN_NONE if no pen shall be made transparent.

The flags argument can be set to a combination of the following flags:

HWREMAPFLAGS_DITHER:
Set this flag to enable dithering.

HWREMAPFLAGS_MAKEPALETTE:
Set this flag to copy the generated palette to the buffer specified in the DstPalette structure member (see above). Only used when remapping RGB pixels.

Finally, the tag list can contain the following tags:

HWREMAPTAG_ALPHATHRESHOLD:
This tag can be used to specify a threshold value between 0 and 255 that should be used when quantizing alpha transparency to monochrome, i.e. single pen, transparency. For example, when remapping RGB data with alpha transparency to CLUT pixels, hw_Remap() needs to decide which pixels to remap and which pixels to ignore because they are (partly) transparent. All pixels whose alpha value is less than or equal to the threshold value specified in HWREMAPTAG_ALPHATHRESHOLD will be considered transparent. By default, the transparent threshold set using Hollywood's SetTransparentThreshold() will be used.

Designer compatibility
Unsupported

Inputs
src
source pixel data
dst
buffer to store remapped pixels in
ctrl
pointer to a struct hwRemapCtrl containing additional parameters
flags
combination of flags for the operation (see above)
tags
additional options for the operation (see above)
Results
ok
True or False, indicating success or failure

Show TOC