(colormap-stamp! colormap bitmap x-position y-position rgb mode)
This procedure “stamps” a bitmap onto a pre-existing colormap at the specified position. For every set (black) pixel of the bitmap, the resulting pixel in the colormap is set to the specified rgb value. If mode is “0”, all background pixels remain unchanged, if it’s “1” the background is darkened by shifing every channel one bit to the right.
This procedure is useful for putting a timestamp onto an image frame but is also useful for many other purposes.
The colormap is modified.
The modified colormap is returned.
This example puts a timestamp on a grabbed frame and display it (Linux only):
> (define fb (framebuffer-create))
fb
> (define cam (grabber-create))
cam
> (define frame (grabber-grab cam))
frame
> (colormap-stamp! frame (string->bitmap (localtime))
0 0 (rgb 255 0 0) 0)
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 w:1280 h:720>
> (framebuffer-display! fb frame)
ok
>
This example creates a PNG file with “Hello!” in red:
> (define cm (colormap-create 200 100))
cm
> (define stamp (bitmap-scale-absolute (string->bitmap "Hello!") 200 100))
stamp
> (colormap-stamp! cm stamp 0 0 (rgb 255 0 0) 0)
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 w:200 h:100>
> (colormap-writepng cm "colormap-stamp.png")
ok
>
The resulting PNG image displays as follows: