Documentation for Win32lib v0.60.6
Table of Contents

Graphics

These are routines that allow you to draw on controls.


Usually used with a Window, Pixmap or Printer.

The predefined colors are:

  Black, NavyBlue, Blue, BrightBlue
  ForestGreen, Green, Cyan, SkyBlue
  BrightGreen, BrightCyan, DarkGray, Eggplant
  Red, Magenta, DarkBrown, Olive
  Gray, Brown, LightGray, Purple
  White, BrightRed, BrightMagenta, Violet
  Orange, Pink, Yellow, Parchment, BrightWhite

  • proc bitBlt( dst, dstX, dstY, src, srcX, srcY, wide, high, rop )   Copy image (or partial image) from source to destination.
  • func colorValue(object Color)   Converts the parameter into the equivalent 24-bit color value.
  • proc copyBlt( dst, dstX, dstY, src )   Copy full image from source to destination.
  • func copyToBitmapFile( window, fileName, x1, y1, x2, y2 )    Copies image from window to file fileName.
  • func copyToTrueColorBitmapFile( window, fileName, x1, y1, x2, y2 )    Copies image from window to file fileName.
  • func createDIB( data )   Converts a Euphoria bitmap format into a Win32 bitmap.
  • proc drawArc( window, filled, x1, y1, x2, y2, xStart, yStart, xEnd, yEnd )   Draw an arc.
  • proc drawBitmap( window, DIB handle, x, y )    Draws DIB (device independant bitmap) in window at { x, y }.
  • proc drawChord( window, filled, x1, y1, x2, y2, xStart, yStart, xEnd, yEnd )   Draw a chord.
  • proc drawEllipse( window, filled, x1, y1, x2, y2 )   Draw an ellipse.
  • proc drawLine( window, pStartX, pStartY, pEndX, pEndY )   Draw a line.
  • proc drawLines( integer id, sequence coords )   Draws zero or more lines.
  • proc drawPie( window, filled, x1, y1, x2, y2, xStart, yStart, xEnd, yEnd )   Draw a pie slice.
  • proc drawPolygon( integer id, integer filled, sequence points )   Draw a polygon.
  • proc drawRectangle( window, filled, x1, y1, x2, y2 )   Draw a rectangle.
  • proc drawRoundRect( window, filled, x1, y1, x2, y2, xc, yc )   Draw a rounded rectangle.
  • func extractIcon( sequence Filename )   Gets the an icon from the file (DLL, EXE or ICO) specified.
  • func floodFill( atom pControl, integer pXStart, integer pYStart, object pColor, integer pFillType)   Performs a 'flood fill' operation.
  • func getPixel( window, x, y )    Get a pixel value from window's client area.
  • func loadBitmapFromFile( file name )   Loads a bitmap file.
  • proc repaintFG( window )    Force window to be repainted but without clearing it first.
  • proc repaintRect( window, x1, y1, x2, y2 )    Force window to be partially repainted.
  • proc repaintWindow( window )    Force window to be entirely repainted.
  • func rgb( integer red, integer green, integer blue )   Convert a {red, green, blue} tuple into a 24-bit color value.
  • proc setBackColor( integer id, object color )    Set the color for used for the pen fill color in id.
  • proc setPenBkColor( window, color )   Determines the background color for text.
  • proc setPenBkMode( window, mode )   Determines if the background color for lines and text.
  • proc setPenBrushColor( window, color )   Determines the solid brush color for filled shapes.
  • proc setPenColor( window, color )    Set the the pen color used in window.
  • proc setPenMode( integer id, integer mode )   Determines what mode graphics are drawn in.
  • proc setPenStyle( window, style )   Set the style that lines are drawn in.
  • proc setPenWidth( window, pixel width )    Set the the pen width used in window.
  • proc setPixel( window, x, y, rgb color )    Set a pixel value in window's client area.
  • func split_rgb( object pColor)   Convert a color into a {red, green, blue}.
  • proc stretchBlt( dst, dstX, dstY, dstWide, dstHigh, src, srcX, srcY, srcWide, srcHigh, rop )   Copy image (or partial image) from source to destination, changing its size as you go.
  • func textToBitmap( text )   Converts a sequence of text into a monochrome bitmap.
  • proc transBlt( dst, dstX, dstY, src )   Copy full image from source to destination, with transparency.

    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    bitBlt
    ( dst, dstX, dstY, src, srcX, srcY, wide, high, rop )

    Copy image (or partial image) from source to destination.

    Category: Graphics

    The bitBlt function can be used to rapidly copy images, or portions of images.

    If you want to copy the entire source image with the SRCCOPY ROP code, copyBlt does the same thing, but requires less arguments.

    To copy images with transparency, use transBlt.

    The arguments are:

  • dst: Image destination
  • dstX: X position in destination
  • dstY: Y position in destination
  • src: Image source
  • srcX: X position in source
  • srcY: Y position in source
  • wide: Width of image to copy
  • high: Height of image to copy
  • rop: Raster opeartion (ROP) code to apply

    The ROP (raster operation) specifies how to combine the source with the destination. The codes are:

  • SrcCopy dest = source
  • SrcPaint dest = source OR dest
  • SrcAnd dest = source AND dest
  • SrcInvert dest = source XOR dest
  • SrcErase dest = source AND (NOT dest)
  • NotSrcCopy dest = (NOT source)
  • NotSrcErase dest = (NOT src) AND (NOT dest)
  • MergeCopy dest = (source AND pattern)
  • MergePaint dest = (NOT source) OR dest
  • PatCopy dest = pattern
  • PatPaint dest = dest OR (pattern OR (NOT source))
  • PatInvert dest = pattern XOR dest
  • DstInvert dest = (NOT dest)
  • Blackness dest = BLACK
  • Whiteness dest = WHITE

    Note: The coordinates are relative to zero.

    Note: The destination and source can be the same control.

    Example:

              -- draw a bitmap in a window
              atom hDIB
    

    -- load the bitmap hDib = loadBitmapFromFile( "lizard.bmp" )

    -- copy 40x40 portion of source image to destination bitBlt( TheWindow, -- copy to TheWindow 10, 10, -- put at {10,10} in TheWindow hDIB, -- copy from loaded bitmap 0, 0 -- upper left hand corner is {0,0} 40, 40, -- copy a 40x40 pixel portion SRCCOPY ) -- replace destination with image

    See Also: colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    colorValue
    (object Color)

    Converts the parameter into the equivalent 24-bit color value.

    Returns: ATOM: 24-bit color value.

    Category: Graphics

    The Color parameter can take one of the following forms ...

  • A atom expression that results in an integer from 0 to #FFFFFF
  • One of the predefined Win32Lib color names, eg. Cyan, BrightMagenta, ...
  • One of the system symbolic color names, eg. COLOR_BUTTONFACE
  • One of the predefined Win32Lib color names as a negative string, eg. -"cyan", -"red", ...
  • One of the predefined Win32Lib color names as a string, except for "red" eg. "cyan", "blue", ...
  • A 3-element sequence in the form { red, green, blue } where each element is an integer in the range 0 to 255.

    Example:

          atom theColor
          theColor = colorValue( -"Parchment" )
          theColor = colorValue( {45,82,191} )
          theColor = colorValue( Magenta )
          theColor = colorValue( COLOR_ACTIVEBORDER )
          theColor = colorValue( #C0C0C0 )
    

    See Also: bitBlt, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    copyBlt
    ( dst, dstX, dstY, src )

    Copy full image from source to destination.

    Category: Graphics

    If you only want to copy a portion of the source or need to combine the source and destination, use bitBlt.

    To copy images with transparency, use transBlt.

    The arguments are:

  • dst: Image destination
  • dstX: X position in destination
  • dstY: Y position in destination
  • src: Image source

    Note: At the moment, the coordinates are zero relative; this will be changed in later releases. Example:

              -- draw a bitmap in a window
              atom hDIB
    

    -- load the bitmap hDib = loadBitmapFromFile( "shuttle.bmp" )

    -- copy the entire image to TheWindow copyBlt( TheWindow, 10, 10, hDib )

    See Also: bitBlt, colorValue, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    copyToBitmapFile
    ( window, fileName, x1, y1, x2, y2 )

    Copies image from window to file fileName.

    Returns: Returns 0 if succeeds.

    Category: Graphics

    x1 and y1 refer to the top left pixel corner of the image, and x2 and y2 refer to the bottom right corner of the image.

    There are a number of caveats:

  • It uses getPixel , so it's slow.
  • It uses save_bitmap, so it's currently limited to 256 colors. The error codes are the also the same as those returned by save_bitmap.

    Example:

              -- save {0,0} {100,100} on the screen to a file
               copyToBitmapFile( Screen, "screen.bmp", 0, 0, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    copyToTrueColorBitmapFile
    ( window, fileName, x1, y1, x2, y2 )

    Copies image from window to file fileName.

    Returns: Returns 0 if succeeds.

    Category: Graphics

    x1 and y1 refer to the top left pixel corner of the image, and x2 and y2 refer to the bottom right corner of the image.

    Note 1: It uses getPixel , so it's slow.
    Note 2: It uses the full 24-bit color range (16+ million colors).

    Example:

              -- save {0,0} {100,100} on the screen to a file
               copyToTrueColorBitmapFile( Screen, "screen.bmp", 0, 0, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    createDIB
    ( data )

    Converts a Euphoria bitmap format into a Win32 bitmap.

    Returns: Handle to Win32 bitmap, or Null on an error.

    Category: Graphics

    The data is in the form { pal, data }.

    You only need to supply as many palette entries that are actually used by the image. Pixel indexes into the palette start at 0 (to be compatible with how Euphoria uses bitmaps)

    Palette entries are color tuples in the form { r, g, b }, with each color value ranging from 0 to 255.

    Example:

              -- create a bitmap, and display it
              atom hBitmap
              sequence pixels, pal
    

    -- the pixels data pixels = { { 0,0,0,0 }, -- scan line 1 { 0,1,1,0 }, -- scan line 2 { 0,1,1,0 }, -- scan line 3 { 0,0,0,0 } } -- scan line 4

    -- the pal data (color tuples) pal = { { 255, 0, 0 }, -- color 0 is bright red { 0, 0, 255 } } -- color 1 is bright blue

    -- create the DIB hBitmap = createDIB( {Pal, Pixels} )

    -- display the bitmap in TheWindow at {1,1} drawBitmap( theWindow, hBitmap, 1, 1 )

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawArc
    ( window, filled, x1, y1, x2, y2, xStart, yStart, xEnd, yEnd )

    Draw an arc.

    Category: Graphics

    Draws the arc in the current pen color. The arc's bounding rectangle is defined as { x1, y1 } to { x2, y2 }. If filled is true, the ellipse is filled in the current pen color.

    The arc is defined by the intersection between the radial start point and radial end point. The radial start point is a line running from the center of the bounding rectangle to { xStart, yStart }, and radial end point by a line running from the center of the bounding rectangle to { xEnd, yEnd }.

    If filled is true, the arc will be filled.

    Example:

          -- draw a bright cyan filled arc in TheWindow
           setPenColor( TheWindow, BrightCyan )
           drawArc( TheWindow,
                      w32True,           -- filled
                      1, 1,           -- upper left boundary
                      100, 100,       -- lower right boundary
                      49, 1,          -- top center of rectangle
                      100, 49 )       -- right center of rectangle
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawBitmap
    ( window, DIB handle, x, y )

    Draws DIB (device independant bitmap) in window at { x, y }.

    Category: Graphics

    Note: The term bitmap is inconsistant; I expect to be renaming these routines in the future.

    Example:

              -- load a bitmap, and display in window
              atom hBitmap
    

    -- load the bitmap hBitmap = loadBitmapFromFile( "graphic.bmp" )

    -- display the bitmap in TheWindow at {1,1} drawBitmap( theWindow, hBitmap, 1, 1 )

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawChord
    ( window, filled, x1, y1, x2, y2, xStart, yStart, xEnd, yEnd )

    Draw a chord.

    Category: Graphics

    Draws the chord in the current pen color.

    A chord is a region bounded by the intersection of an ellipse and a line segment. The ellipse is bounding rectangle is defined { x1, y1 } to { x2, y2 }. If filled is true, the chord is filled in the current pen color.

    The chord is defined by the intersection between the radial start point and radial end point. The radial start point is a line running from the center of the bounding rectangle to { xStart, yStart }, and radial end point by a line running from the center of the bounding rectangle to { xEnd, yEnd }.

    If filled is true, the chord will be filled.

    Example:

          -- draw a yellow chord in TheWindow
           setPenColor( TheWindow, Yellow )
           drawChord( TheWindow,
                      w32True,           -- filled
                      1, 1,           -- upper left boundary
                      100, 100,       -- lower right boundary
                      49, 1,          -- top center of rectangle
                      100, 49 )       -- right center of rectangle
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawEllipse
    ( window, filled, x1, y1, x2, y2 )

    Draw an ellipse.

    Category: Graphics

    Draws the ellipse in the current pen color within the rectangle bounded by { x1, y1 } and { x2, y2 }. If filled is true, the ellipse is filled in the current pen color.

    Example:

          -- draw a black ellipse in TheWindow
           setPenColor( TheWindow, Black )
           drawEllipse( TheWindow, w32True, 10, 10, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawLine
    ( window, pStartX, pStartY, pEndX, pEndY )

    Draw a line.

    Category: Graphics

    The line is drawn in the current pen color between { pStartX, pStartY } and { pEndX, pEndY }.

    Example:

          -- draw a line in TheWindow from {10,10} to {100,100}
           drawLine( TheWindow, 10, 10, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawLines
    ( integer id, sequence coords )

    Draws zero or more lines.

    Category: Graphics

    The lines are drawn between the sets of coordinates in coords.
    This sequence can contain Colors, Points, Lines, or Rects.

  • A Color is a single atom that is a 24-bit color value. Subsequent lines use this color.
  • A Point is a 2-element sequence {X,Y} that gives the X,Y position of the end-point of a line. The line is drawn to this position from the last end-point supplied, or if this is the first Point specified, the current pen position for the control. See setPenPos().
  • A Line is a 4-element sequence {X1,Y1,X2,Y2} that specifies the X,Y position of a line's starting point and the X,Y position of its end point. The line is drawn from X1,Y1 to X2,Y2.
  • A Rect is a 5-element sequence {Fill, X1,Y1,X2,Y2} that specifies a rectangle. The first element is w32True for a filled rectangle and w32False for an outline only. The X1,Y1 is the X,Y position of the top-left corner and X2,Y2 is the X,Y position of the bottom-right corner.

    If no color parameters are supplied, the current pen color for the control is used.

    Example:

          -- draw a shape in TheWindow
           drawLines( TheWindow, {White,{40,0,0,80},{80,80},{40,0},
                                  Blue,{40,5,0,85},{80,85},{40,5}
                                 } )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawPie
    ( window, filled, x1, y1, x2, y2, xStart, yStart, xEnd, yEnd )

    Draw a pie slice.

    Category: Graphics

    Draws the pie slice in the current pen color. The bounding rectangle is defined as { x1, y1 } to { x2, y2 }. If filled is true, the slice is filled in the current pen color.

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawPolygon
    ( integer id, integer filled, sequence points )

    Draw a polygon.

    Category: Graphics

    Draws the polygon in id in the current pen color using points. If i/ filled is true, the polygon will be filled.

    points is either a set of two-element co-ordinates or a list of alternating x,y coordinates.

    Example:

          -- draw a blue filled triangle in TheWindow
          sequence points
    

    -- define the points points = { { 10, 10 }, { 80, 40 }, { 40, 80 } }

    -- alternative method to define the points points = { 10, 10, 80, 40, 40, 80 } -- set pen color setPenColor( TheWindow, Blue )

    -- draw a filled polygon using the points drawPolygon( TheWindow, w32True, points )

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawRectangle
    ( window, filled, x1, y1, x2, y2 )

    Draw a rectangle.

    Category: Graphics

    Draws the rectangle in the current pen color from { x1, y1 } to { x2, y2 }. If filled is true, the rectangle is filled in the current pen color.

    Example:

          -- draw a filled green rectangle in TheWindow
           setPenColor( TheWindow, Green )
           drawRectangle( TheWindow, w32True, 10, 10, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    drawRoundRect
    ( window, filled, x1, y1, x2, y2, xc, yc )

    Draw a rounded rectangle.

    Category: Graphics

    Draws the rounded rectangle in the current pen color from { x1, y1 } to { x2, y2 }. The ellipse corner width and height are specified in xc and yc. If filled is true, the rectangle is filled in the current pen color.

    Example:

          -- draw a filled blue round rectangle in TheWindow
           setPenColor( TheWindow, Green )
           drawRoundRect( TheWindow, w32True, 10, 10, 100, 100, 5, 5 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    extractIcon
    ( sequence Filename )

    Gets the an icon from the file (DLL, EXE or ICO) specified.

    Returns: ATOM: Handle to the icon or NULL if none found.

    Category: Graphics

    Filename is either ...
    ** the name of a file
    ** a 2-element sequence containing a filename and a 1-based index of which icon to extract. ** a 3-element sequence containing a filename, a 1-based index of which icon to extract, and a code indicating which size icon to return: 0 --> small, 1 --> large, 2 --> both. When you ask to return both, a 2-element sequence is returned that contains {small, large}.

    Example:

          atom hIcon
          sequence lIcons
          -- Get the first icon
          hIcon = extractIcon( "C:\\WINDOWS\\WINFILE.EXE")
          -- Get the second icon
          hIcon = extractIcon( {"C:\\WINDOWS\\WINFILE.EXE", 2} )
          -- Get the fourth icon, large size
          hIcon = extractIcon( {"C:\\WINDOWS\\WINFILE.EXE", 4, 1} )
          -- Get the fifth icon, both sizes
          lIcons = extractIcon( {"C:\\WINDOWS\\SYSTEM32\SHELL32.DLL", 5, 2} )
          lBig = lIcons[2]
          lSmall = lIcons[1]
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    floodFill
    ( atom pControl, integer pXStart, integer pYStart, object pColor, integer pFillType)

    Performs a 'flood fill' operation.

    Returns: ATOM: 0 if failed, !0 if success

    Category: Graphics

    This routine will fill an area of adjacent pixels with the same color. It works by searching for a specific color, the Search Color, and changing pixels to the Flood Color as it goes. There are two types of searching. One searches for a border and all pixels inside the border are changed to the flood color. The other type searches for a specific color and only changes adjacent pixels with that color to the flood color.

    pControl is either a valid control ID, or a Device Context returned by getDC. If pControl is a control Id, then the default flood color is the current pen color ( setPenColor ) otherwise you need to create your own brush before calling this ( createBrush ).

    pXStart and pYStart are the pixel coordinates of the flood starting position.

    pFillType is one of either FLOODFILLBORDER or FLOODFILLSURFACE. A border fill changes each pixel until the border is encountered. A surface fill changes each adjacent pixel that is the same color as the pColor value.

    pColor is used to supply the search color or both colors. To supply just the search color then pColor is a single value. To supply both search and flood colors, then pColor is a two-element sequence in the form { SearchColor, FloodColor }.
    Either color can be a single atom color value, a 3-element {R,G,B} value or the name of one of the predefined color names, eg. "Black", "BrightCyan", etc...

    The Search Color's usage depends on the flood type. If doing a border fill, then the search color is the border's color. If a surface fill, this is the color of the pixels to change from.
    There is a special value for Search Color. If you supply a value of -1, then Search Color is taken from the pixel currently at pXStart, pYStart. This means that for a border fill, nothing happens. For a surface fill, the pixel at the start position and all adjacent pixels will be changed to the flood color.
    Note that if no Flood Color is supplied the current pen color is used when pControl is a control ID, or the current brush if pControl is a device context.
    If the Flood Color is supplied, and it has the value -1, then the current pen color for the control is used.

    Examples:

          -- Using the current pen, set all pixels inside the black border.
          VOID = floodFill( myPixmap, x, y, Black, FLOODFILLBORDER)
          -- Set the start pixel and all adjacent pixels of the same color to Pink
          VOID = floodFill( myPixmap, x, y, {-1, Pink}, FLOODFILLSURFACE)
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getPixel
    ( window, x, y )

    Get a pixel value from window's client area.

    Returns: rgb value of point.

    Category: Graphics

    Example:

          -- get a pixel color from {10,10} in TheWindow
          atom rgb
           rgb = getPixel( TheWindow, 10, 10 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    loadBitmapFromFile
    ( file name )

    Loads a bitmap file.

    Returns: Win32 handle of bitmap, or Null if an error occured.

    Category: Graphics

    Note: The name bitmap is a bit confusing; it should be more properly called loadDIBFromFile. At some point, the graphic routines need to be renamed in a more consistant manner.

    Example:

              -- load a bitmap, and display in window
              atom hBitmap
    

    -- load the bitmap hBitmap = loadBitmapFromFile( "graphic.bmp" )

    -- display the bitmap in TheWindow at {1,1} drawBitmap( theWindow, hBitmap, 1, 1 )

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    repaintFG
    ( window )

    Force window to be repainted but without clearing it first.

    Category: Graphics

    This triggers an onPaint event for that window, requesting that the entire window be repainted.

    It is different to repaintWindow() in that the window is not cleared to its background color first.

    Example:

          -- force MyWindow to be repainted
           repaintFG( myWindow )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    repaintRect
    ( window, x1, y1, x2, y2 )

    Force window to be partially repainted.

    Category: Graphics

    This sends repaints at the specified portion of the window with the background color, erasing that portion of it. It then triggers an onPaint event for that window, passing the erased area as parameters.

    Example:

          -- repaint only a portion of MyWindow
           repaintRect( myWindow, 1, 1, 10, 10 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    repaintWindow
    ( window )

    Force window to be entirely repainted.

    Category: Graphics

    This repaints the entire window in it's background color, effectively erasing everything in it. It then triggers an onPaint event for that window, requesting that the entire window be repainted.

    Example:

          -- force MyWindow to be repainted
           repaintWindow( myWindow )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    rgb
    ( integer red, integer green, integer blue )

    Convert a {red, green, blue} tuple into a 24-bit color value.

    Returns: Atom: representing the color tuple.

    Category: Graphics

    Converts the red, green and blue values (ranging from 0-255) into an atom representing that color tuple. Each value represents the relative brightness of each primary color element.

    Example:

    -- set the pen color to a random blue
     setPenColor( MyControl, rgb( 0, 0, rand( 255 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setBackColor
    ( integer id, object color )

    Set the color for used for the pen fill color in id.

    Category: Graphics

    When the pen mode is set to OPAQUE, this specifies the color used to fill the 'gaps'.

    When used on a MonthCalendar control, it changes the background color imediately.

    When used on a Pixmap control, it clears the entire Pixmap to the specified color.

    Example:

          -- set pen opaque color
          setPenBkMode( TheWindow, OPAQUE)
          setBackColor( TheWindow, Red )
           wPuts( TheWindow, "This text is on red" )
    

    -- Clear a pixmap setBackColor( pixmap1, BrightWhite)

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenBkColor
    ( window, color )

    Determines the background color for text.

    Category: Graphics

    Example:

      setPenBkColor( Fld1, BrightCyan )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenBkMode
    ( window, mode )

    Determines if the background color for lines and text.

    Category: Graphics

    Modes are:

  • OPAQUE: Draws using background color.
  • TRANSPARENT: Draws without background color.

    If mode is OPAQUE, the color set in setBackColor is used. The default mode is TRANSPARENT.

    Example:

              -- draw an XOR line in TheWindow
               setPenBkMode( TheWindow, OPAQUE )
               drawLine( TheWindow, 10, 10, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenBrushColor
    ( window, color )

    Determines the solid brush color for filled shapes.

    Category: Graphics

    The current pen color is used until this is called for the first time.

    Example:

      setPenBrushColor( MyCanvas, Blue)
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenColor
    ( window, color )

    Set the the pen color used in window.

    Category: Graphics

    This is the color that is used by other graphics routines.

    To set the color of text, use setTextColor.

    Example:

              -- set pen color to red
               setPenColor( TheWindow, Red )
              -- draw a red line
               drawLine( TheWindow, 10, 10, 40, 40 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenMode
    ( integer id, integer mode )

    Determines what mode graphics are drawn in.

    Category: Graphics

    The default value is R2_COPYPEN. The mode codes are:

  • R2_BLACK: Pixel is always 0.
  • R2_NOTMERGEPEN: Pixel is the inverse of the R2_MERGEPEN color.
  • R2_MASKNOTPEN: combination common screen and inverse of pen.
  • R2_NOTCOPYPEN: Pixel is the inverse of the pen color.
  • R2_MASKPENNOT: combination common to pen and inverse of screen.
  • R2_NOT: Pixel is the inverse of the screen color.
  • R2_XORPEN: Pixel is the inverse of the R2_XORPEN color.
  • R2_NOTMASKPEN: Pixel is the inverse of the R2_MASKPEN color.
  • R2_MASKPEN: combination common to pen and the screen.
  • R2_NOTXORPEN: combination of colors in pen and screen, but not in both.
  • R2_NOP: Pixel remains unchanged.
  • R2_MERGENOTPEN: combination of screen and inverse of pen.
  • R2_COPYPEN: Pixel is the pen color.
  • R2_MERGEPENNOT: combination of pen color and inverse of screen color.
  • R2_MERGEPEN: combination of pen color and the screen color.
  • R2_WHITE: Pixel is always 1.

    Example:

              -- draw an XOR line in TheWindow
               setPenMode( TheWindow, R2_XORPEN )
               drawLine( TheWindow, 10, 10, 100, 100 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenStyle
    ( window, style )

    Set the style that lines are drawn in.

    Category: Graphics

    This allows the creation of various dotted line styles. Use setBackColor to define the background fill used on the line.

    The following styles are defined:

  • Solid
  • Dash
  • Dot
  • DashDot
  • DashDotDot

    Note: This routine will probably be dropped in later releases.

    Example:

              -- set pen style
               setPenStyle( TheWindow, Dot )
    

    -- draw a line using that pen style drawLine( TheWindow, 10, 10, 100, 100 )

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPenWidth
    ( window, pixel width )

    Set the the pen width used in window.

    Category: Graphics

    The default thickness of the pen is 1 pixel.

    Example:

              -- set pen thickness of 3
               setPenWidth( TheWindow, 3 )
              -- draw a thick line
               drawLine( TheWindow, 10, 10, 40, 40 )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPixel, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setPixel
    ( window, x, y, rgb color )

    Set a pixel value in window's client area.

    Category: Graphics

    Example:

          -- set pixel at {10,10} to Red
           setPixel( TheWindow, 10, 10, Red )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, split_rgb, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    split_rgb
    ( object pColor)

    Convert a color into a {red, green, blue}.

    Returns: Sequence: 3-element {RED, GREEN, BLUE}

    Category: Graphics

    Converts the color value into its component colors.

    Example:

    -- get the colors got a pixel
    RGB = split_rgb( getPixel(myBMP, 4,7) )
    RGB = split_rgb( "BrightCyan" )
    RGB = split_rgb( COLOR_BUTTONFACE )
    RGB = split_rgb( Magenta )
    

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, stretchBlt, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    stretchBlt
    ( dst, dstX, dstY, dstWide, dstHigh, src, srcX, srcY, srcWide, srcHigh, rop )

    Copy image (or partial image) from source to destination, changing its size as you go.

    Category: Graphics

    This is used to resize an image and/or create mirror images. If the dstWide and dstHigh parameters are negative, the image is also reflected in the X-axis and Y-axis respectively.

    The arguments are:

  • dst: Image destination
  • dstX: X position in destination
  • dstY: Y position in destination
  • dstWide: Width of resulting image
  • dstHigh: Height of resulting image
  • src: Image source
  • srcX: X position in source
  • srcY: Y position in source
  • srcWide: Width of image to copy
  • srcHigh: Height of image to copy
  • rop: Raster opeartion (ROP) code to apply

    The ROP (raster operation) specifies how to combine the source with the destination. The codes are:

  • SrcCopy dest = source
  • SrcPaint dest = source OR dest
  • SrcAnd dest = source AND dest
  • SrcInvert dest = source XOR dest
  • SrcErase dest = source AND (NOT dest)
  • NotSrcCopy dest = (NOT source)
  • NotSrcErase dest = (NOT src) AND (NOT dest)
  • MergeCopy dest = (source AND pattern)
  • MergePaint dest = (NOT source) OR dest
  • PatCopy dest = pattern
  • PatPaint dest = dest OR (pattern OR (NOT source))
  • PatInvert dest = pattern XOR dest
  • DstInvert dest = (NOT dest)
  • Blackness dest = BLACK
  • Whiteness dest = WHITE

    Note: The coordinates are relative to zero.

    Note: The destination and source can be the same control.

    Example:

              -- draw a bitmap in a window
              atom hDIB
    

    -- load the bitmap hDib = loadBitmapFromFile( "lizard.bmp" )

    -- copy 40x40 portion of source image to destination stretchBlt( TheWindow, -- copy to TheWindow 10, 10, -- put at {10,10} in TheWindow 100, 50, -- cause it to be this size hDIB, -- copy from loaded bitmap 0, 0 -- upper left hand corner is {0,0} 40, 40, -- copy a 40x40 pixel portion SRCCOPY ) -- replace destination with image

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, textToBitmap, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    textToBitmap
    ( text )

    Converts a sequence of text into a monochrome bitmap.

    Returns: Handle to Win32 bitmap, or Null on an error.

    Category: Graphics

    Spaces are converted to White pixels; all other characters are converted to Black pixels.

    Note: This routine should probably be deprecated, or at least renames.

    Example:

              -- create a bitmap, and display it
              atom hBitmap
              sequence image
    

    -- the image image = { " xxxxxx ", "x x", "x x x x", "x x", "x x x x", "x x x x", "x xxxx x", " xxxxxx ",

    -- create the bitmap hBitmap = textToBitmap( image )

    -- display the bitmap in TheWindow at {1,1} drawBitmap( theWindow, hBitmap, 1, 1 )

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, transBlt


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    transBlt
    ( dst, dstX, dstY, src )

    Copy full image from source to destination, with transparency.

    Category: Graphics

    TransBlt is typically used for displaying non-rectangular bitmaps - sprites. It is a computationally expensive operation; if there is no transparency in your image, you should use copyBlt or bitBlt instead.

    By default, transBlt assumes that the color {255,0,255} is to be treated as transparent. To change the transparent color, use setTransparentColor.

    The arguments are:

  • dst: Image destination
  • dstX: X position in destination
  • dstY: Y position in destination
  • src: Image source

    Note: At the moment, the coordinates are zero relative; this will be changed in later releases. Example:

              -- draw a bitmap using transparency
              atom hDIB
              sequence size
    

    -- get the size of TheWindow size = getCtlSize( TheWindow )

    -- load the bitmap hDib = loadBitmapFromFile( "shuttle.bmp" )

    -- treat the color BrightWhite as transparent setTransparentColor( BrightWhite )

    -- copy multiple images to TheWindow for i = 1 to 20 do transBlt( TheWindow, -- destination rand( size[1] ), -- x position rand( size[2] ), -- y position hDib ) -- image to copy end for

    See Also: bitBlt, colorValue, copyBlt, copyToBitmapFile, copyToTrueColorBitmapFile, createDIB, drawArc, drawBitmap, drawChord, drawEllipse, drawLine, drawLines, drawPie, drawPolygon, drawRectangle, drawRoundRect, extractIcon, floodFill, getPixel, loadBitmapFromFile, repaintFG, repaintRect, repaintWindow, rgb, setBackColor, setPenBkColor, setPenBkMode, setPenBrushColor, setPenColor, setPenMode, setPenStyle, setPenWidth, setPixel, split_rgb, stretchBlt, textToBitmap