# ConformCtrlBitmapToPanel

int ConformCtrlBitmapToPanel (int panel, int ctrl, int itemIndex, int bitmap3DObjectColor, int new3DObjectColor, int bitmapTextColor, int newTextColor);

## Purpose

This function conforms the bitmap of a picture control, picture button, or picture ring to a specified color scheme.

This function is useful for making picture buttons conform to the system colors or for simply replacing one color with another in a control's bitmap.

Usually, when designing bitmaps for use in picture buttons, you choose a color which represents the 3D object color, and another color which represents the text or shadow color. These are often VAL_PANEL_GRAY and VAL_BLACK, respectively. But, if you are using the ATTR_CONFORM_TO_SYSTEM attribute on your panels and a user runs your program on a computer where the system color settings are different, your picture buttons will look wrong because the picture button background color will not match the panel background color.

To solve the problem, you simply call this function and pass it the panel and control you wish to convert, as well as the colors in the bitmap you wish to conform to a new 3D object and text color. For example, the following code will conform all bitmaps in all the controls on the panel to match the current panel colors. This assumes that 3D object pixels in the bitmap are VAL_PANEL_GRAY and text/shadow pixels are VAL_BLACK.

{
ConformCtrlBitmapToPanel (panel, –1, –1, VAL_PANEL_GRAY, –1,
VAL_BLACK, –1);
}

| Note This function returns an error if the bitmap you specify has alpha-channel transparency data.

## Parameters

Input
Name | Type | Description
panel | integer | The specifier for a particular panel that is currently in memory. This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function.
ctrl | integer | The defined constant (located in the UIR header file) which was assigned to the control in the User Interface Editor, or the ID returned by the NewCtrl or DuplicateCtrl function. The control should be a picture control, picture command button, picture toggle button, or picture ring. If you pass –1 for this parameter, all appropriate controls on the panel will be conformed to the specified colors.
itemIndex | integer | If the control is a picture ring, specify the zero–based index of the bitmap to conform. If the control is not a picture ring, this parameter is ignored. If you pass –1 for the index, all bitmaps in the picture ring will be conformed to the desired colors.
bitmap3DObjectColor | integer | Specify the color of the pixels in the bitmap that you wish to conform to the new 3D object color. Typically, bitmaps will use this color anywhere the 3D object color is required, such as for the background of a toolbar button image.
| Note Colors which are "close" to the specified color are also changed to the new color. The definition of "close" is as follows for colors c1 and c2: diff = abs(red val of c1 – red val of c2) + abs(green val of c1 – green val of c2) + abs(blue val of c1 – blue val of c2); If diff is less than MAX_COLOR_DIFF (defined in toolbox.c, the default value is 15), then colors c1 and c2 are considered "close".
new3DObjectColor | integer | Specify the new color for any pixels in the bitmap whose color is the bitmap 3D object color. If you pass –1 for this parameter, the current color of the specified panel is used as the new 3D object color.
bitmapTextColor | integer | Specify the color of the pixels in the bitmap that you wish to conform to the new text color. Typically, this color is used for text or dark shadow areas in the bitmap.
| Note Colors which are "close" to the specified color are also changed to the new color. The definition of "close" is as follows for colors c1 and c2: diff = abs(red val of c1 – red val of c2) + abs(green val of c1 – green val of c2) + abs(blue val of c1 – blue val of c2); If diff is less than MAX_COLOR_DIFF (defined in toolbox.c, the default value is 15), then colors c1 and c2 are considered "close".
newTextColor | integer | Specify the new color for any pixels in the bitmap which are in the bitmap text color. If you pass –1 for this parameter, the current titlebar text color of the specified panel is used as the new text color.

## Return Value

Name | Type | Description
status | integer | Returns 0 if the function succeeded or a negative error code if the function failed. The possible negative error codes are:
–1 to –999 | A User Interface Library error code. (Constants are available in userint.h.)
A description of any of these error codes can be obtained using the GetGeneralErrorString function in the toolbox.fp instrument driver.