Meet us at PRINT 19. Chicago, IL. Oct. 3 - 5.
This documentation is for the old version. Go to the latest Graphics Mill docs

Combine Modes

Blending two bitmaps can be done in several different ways. How exactly the bitmaps will be combined depends on the selected CombineMode. This topic will breifly discuss these modes providing some examples.

Possible combine modes are:

In this section the following terms will be used:

  • Source refers to the overlaying bitmap.
  • Destination refers to the base bitmap.

The following two images will be blended in the examples below.

Destination bitmap
Figure 1. Destination bitmap

Source bitmap
Figure 2. Source bitmap

All examples use the 0.8F opacity value (80%).

Copy

Copy mode
Figure 3. Bitmaps blended using the Copy mode.

Each source pixel replaces the corresponding destination pixel. The opacity value is ignored.

Alpha, AlphaOverlapped

Alpha mode
Figure 10. Bitmaps blended using the Alpha mode.

In the Alpha mode, each source pixels is drawn over the corresponding destination pixel. The transparency of the source pixels is preserved, so this mode is useful only when the source bitmap has an alpha channel. On Figure 10 you can see destination bitmap showing through the source bitmap even in the area where the source bitmap is opaque. That happens because for blending the opacity value of the source bitmap was made less than 100%.

AlphaOverlapped mode
Figure 11. Bitmaps blended using the AlphaOverlapped mode.

The AlphaOverlapped mode is almost the same as the Alpha mode, but the resulting alpha channel is calculated as the maximum between the source and destination alpha channels. Figure 11 shows the result of blending images in the AlphaOverlapped mode. Note that it uses a modified version of the destination bitmap. This destination bitmap contains an alpha channel.

Behind

Behind mode
Figure 4. Bitmaps blended using the Behind mode.

Colors are blended only in the transparent areas of the source bitmap.

Add, Subtract, Multiply, Divide, Difference

Add mode
Figure 5. Bitmaps blended using the Add mode.

In the Add mode, the source and destination colors are added.

Subtract mode
Figure 6. Bitmaps blended using the Subtract mode.

In the Subtract mode, the source and destination colors are added, and then the maximum luminosity value is subtracted from the resulting value. The maximum luminosity value is 255 for common pixel formats and 65535 for extended ones.

Multiply mode
Figure 7. Bitmaps blended using the Multiply mode.

In the Multiply mode, the source color is multuplied by the destination one. The resulting value is normalized to the maximum luminosity value. The maximum luminosity value is 255 for common pixel formats and 65535 for extended ones. The resulting color is always a darker color. Multiplying any color with black produces black. Multiplying any color with white leaves the color unchanged.

Divide mode
Figure 8. Bitmaps blended using the Divide mode.

In the Divide mode, the destination color is divided by the source one.

Difference mode
Figure 9. Bitmaps blended using the Difference mode.

In the Difference mode, the resulting value is the difference between the destination and source colors, whichever has the greater luminosity. Blending any color with white in this mode inverts the color. Blending any color with black in this mode leaves the color unchanged.

Hue, Saturation, Luminosity, Color

Hue mode
Figure 12. Bitmaps blended using the Hue mode.

In the Hue mode, hue of the resulting color is taken from the source color, and other components—saturation and luminosity—are taken from the destination color.

Saturation mode
Figure 13. Bitmaps blended using the Saturation mode.

In the Saturation mode, saturation of the resulting color is taken from the source color, and other components are taken from the destination color. If the source color has saturation equal to zero (the source color is gray), the destination color remains unchanged.

Luminosity mode
Figure 14. Bitmaps blended using the Luminosity mode.

In the Luminosity mode, luminosity of the resulting color is taken from the source color, and other components are taken from the destination color. Blending in this mode produces an effect reverse to the effect of the Color mode.

Color mode
Figure 15. Bitmaps blended using the Color mode.

In the Color mode, hue and saturation of the resulting color are taken from the source color, and luminosity is taken from the destination color. This mode is useful for tinting images.

Screen, Overlay

Screen mode
Figure 16. Bitmaps blended using the Screen mode.

In the Screen mode, the source color is inverted and multuplied by the destination one. The resulting value is normalized to the maximum luminosity value. The maximum luminosity value is 255 for common pixel formats and 65535 for extended ones. The resulting color is always a lighter color. Blending any color with black in this mode leaves the color unchanged. Blending any color with white in this mode produces white.

Overlay mode
Figure 17. Bitmaps blended using the Overlay mode.

In the Overlay mode, either the Screen (lightening) or Multiply (darkening) mode is used. For each pixel the choice depends on the destination pixel color luminosity. This mode preserves highlights and shadows.

And, Or, Xor

And mode
Figure 18. Bitmaps blended using the And mode.

In the And mode, bitwise AND operation is applied to the source and destination colors.

Or mode
Figure 19. Bitmaps blended using the Or mode.

In the Or mode, bitwise OR operation is applied to the source and destination colors.

Xor mode
Figure 20. Bitmaps blended using the Xor mode.

In the Xor mode, bitwise XOR operation is applied to the source and destination colors.

IfDarker, IfLighter

IfDarker mode
Figure 21. Bitmaps blended using the IfDarker mode.

In the IfDarker mode, the resulting color is defined as the darkest between the source and destination colors. Destination pixels lighter than the corresponding source pixels are replaced. Destination pixels darker than the corresponding source pixels do not change.

IfLighter mode
Figure 22. Bitmaps blended using the IfLighter mode.

In the IfLighter mode, the resulting color is defined as the lightest between the source and destination colors. Destination pixels darker than the corresponding source pixels are replaced. Destination pixels lighter than the corresponding source pixels do not change.

Invert, Texturize

Invert mode
Figure 23. Bitmaps blended using the Invert mode.

In the Invert mode, the source color is inverted and blended with the destination one in the same way as in the Alpha mode.

Texturize mode
Figure 24. Bitmaps blended using the Texturize mode.

In the Texturize mode, the source color is converted to grayscale and blended with the destination one in the same way as in the Alpha mode.

See Also

Reference

Manual