int ok = hw_Remap(APTR src, UBYTE *dst, struct hwRemapCtrl *ctrl, ULONG flags, struct hwTagList *tags);
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:
Height:
SrcDepth:
src
buffer. This can be either a bit depth value
between 1 and 8 or 32.
DstDepth:
SrcPalette:
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:
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:
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:
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:
HWREMAPFLAGS_MAKEPALETTE:
DstPalette
structure member (see above). Only used when remapping RGB pixels.
Finally, the tag list can contain the following tags:
HWREMAPTAG_ALPHATHRESHOLD:
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.
struct hwRemapCtrl
containing additional parametersTrue
or False
, indicating success or failure