# copying

The following routines can be used to copy (selected regions of) bitmaps:

clipToSource(integer x1, integer y1, integer x2, integer y2, integer width, integer height)
  Sets a clipping region for subsequent operations
copyToDib(a32Dib dib, integer control, integer dX, integer dY, integer cX1, integer cY1, integer cX2, integer cY2)
  Draws a portion {cX1, cY1 -> {cX2, cY2} of a control or window to the bitmap at position {dX, dY}.
drawDibToDib(a32Dib destdib, a32Dib srcdib, integer dX, integer dY, integer sX1, integer sY1, integer sX2, integer sY2, sequence trans_color, integer alpha)
  Draws portion {sX1, sY1} -> {sX2, sY2} of dib_src to the bitmap dib_dest at position {dX, dY}.
copyDibToDib(a32Dib destdib, a32Dib srcdib)
  Copies bitmap dib_source to dib_dest.
tileDibToDib(a32Dib destdib, a32Dib srcdib, integer dX, integer dY, integer sX1, integer sY1, integer sX2, integer sY2, sequence trans_color, integer alpha)
  Tiles (a part of) bitmap src to bitmap dest.
copyDibToClipboard(a32Dib dib)
  Copies the bitmap to the Windows clipboard.
a32Dib0 dib = getDibFromClipboard()
  Gets a bitmap from the clipboard and returns it.

See also: drawDibTransformedPolygon
Example: you can use a bitmap to save a screenshot to a bitmap:

        sequence dib
        integer result

        dib = newDib(screen_width, screen_height)   -- create the bitmap

        copyToDib(dib, Screen, 0, 0, 0, 0, screen_width - 1, screen_height - 1)
                                                    -- copy the screen to the bitmap

        result = saveDib(dib, "screen.bmp", 0, 0, screen_width - 1, screen_height - 1)
                                                    -- save the bitmap to a file

        killDib(dib)                                -- delete the bitmap