rotatePal
Top  Previous  Next

rotatePal ( integer Input, integer Output, integer Mode [, integer All =1, integer& Shift ] )

Use this function to modify an image palette by "rotating" its entries in the interactive or automatic mode.

Parameters
 
Input  
 
An integer between 0 and 116 specifying the input image frame number. A value of 0 represents the DMA memory buffer of the video device. Values in the range of 100-116 correspond to hidden frames. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), only visible frames (1-99) can be used.  
 
Output  
 
An integer between 1 and 116 specifying the output frame number where an image with the rotated palette will be created. Values in the range of 100-116 correspond to hidden frames.  
 
Mode  
 
An enumerated integer that describes the mode to use. Must be one of the following values:  
 
M_PRESET=0 – immediately applies the function to the image shifting its palette by the value of Shift.  
M_DIALOG=1 – opens the Rotate Palette dialog that lets the user rotate palette by moving a slider on the dialog and watching the changes in real time.  
M_MOUSE=2 – activates the mouse mode that lets the user interactively change the settings with a mouse. Moving the mouse leftward or rightward makes the palette entries shift downward and upward respectively. To apply the changes and exit the function, press the left mouse button. To exit the function without applying the changes to the image, press the right mouse button.  
M_AUTO=3 – activates the automatic mode of palette rotation. To apply the changes and exit the function, press ENTER. To exit the function without applying the changes to the image, press ESC.  
 
All  
 
An optional boolean integer that specifies if all palette entries should be included in the rotation. Must be one of the following values:  
 
FALSE=0 – do not include the zero index of the palette in the rotation. Typically the zero index represents the black color or background, which in this case will remain unchanged.  
TRUE=1 – include all palette indexes in the rotation.  
Default value: TRUE  
 
Shift  
 
An integer between 0 and 255 specifying the number of entries in the image palette at which the original palette will be shifted. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), the variable will return a selected value of the palette shift.  
 
Error flags

ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
ERR_CANCEL=-2  
 
The flag set if the function cancelled in the interactive mode.  

Example

This set of statements loads the "hex" palette into a sample image and activates the Mouse mode for interactive palette rotation.  
 
setCurDir ("samples")  
loadIm (1,"sample13.iwd")  
loadpal (1,"..\PALETTES\HEX.PAL",0)  
print  ("Move the mouse to rotate palette")  
print ("Press the right button to finish")  
rotatePal (1, 2, M_MOUSE, 0)  
 
Remark

This function cannot be applied to a true color image.