(colormap-merge colormap0 colormap1 bitmap)


  • colormap0
  • colormap1
  • bitmap


This procedure combines two equally sized colormaps to a new colormap of the same size. The decision where an individual pixel is taken from is based on a bitmap with also the same dimensions. If a pixel at a specific position is set to 0 (white) in the masking bitmap, the resulting pixel is taken from colormap0, if it is set to 1 (black) it is taken from colormap1.

Side Effects

Return Value

The merged colormap is returned.


(define cm0 (colormap-create 100 30))
(define cm1 (colormap-create 100 30))
(define allblack (bitmap-invert (bitmap-create 100 30)))
(colormap-stamp! cm0 allblack 0 0 (rgb 255 0 0) 0)
(colormap-stamp! cm1  allblack 0 0 (rgb 0 255 0) 0)
(define text (bitmap-scale-absolute (string->bitmap "ABCDEF") 100 30))
(define result (colormap-merge cm0 cm1 text))
(colormap-writepng result "merge-example.png")

The resulting PNG image displays as follows: