BoxBitmap

Displays a bitmap in a WinBatch box.

 

Syntax:

BoxBitmap(box ID, coordinates, filename, stretch-mode)

Parameters:

(i) box ID the ID number of the desired WinBatch box..

(s) coordinates dimensions of button, in virtual units (upper-x upper-y lower-x lower-y).

(s) filename specifies the name of a BMP file..

(i) stretch-mode specifies the mode to use when resizing the bitmap. See below.

Returns:

(i) @TRUE on success; @FALSE on failure.

 

'stretch-mode' specifies the mode to use when resizing the bitmap. The bitmap will be stretched within the specified 'coordinates'. It can be one of the following:

 

Value

Meaning

1

BLACKONWHITE: Performs a Boolean AND operation using the color
values for the eliminated and existing pixels. If the bitmap is a monochrome
bitmap, this mode preserves black pixels at the expense of white pixels.

 

2

WHITEONBLACK: Performs a Boolean OR operation using the color values
for the eliminated and existing pixels. If the bitmap is a monochrome bitmap,
this mode preserves white pixels at the expense of black pixels.

 

3

COLORONCOLOR: Deletes the pixels. This mode deletes all eliminated lines
of pixels without trying to preserve their information.

 

4

HALFTONE: Maps pixels from the source rectangle into blocks of pixels in
the destination rectangle. The average color over the destination block of pixels
approximates the color of the source pixels. Supported on Windows NT/2000/XP
only.

 

 

The stretching mode defines how the system combines rows or columns of a bitmap with existing pixels. The BLACKONWHITE and WHITEONBLACK modes are typically used to preserve foreground pixels in monochrome bitmaps. The COLORONCOLOR mode is typically used to preserve color in color bitmaps. The HALFTONE mode is slower and requires more processing of the source image than the other three modes, but produces higher quality images.

 

Note:

In order for bitmaps to display properly in a WinBatch box, the rectangle into which the bitmap is to be placed should have the same aspect ratio (the relationship between the height and width) of the source bmp file.

However, the 1000x1000 coordinate system for WinBatch boxes, is not straightforwardly compatible with the pixel count of the bitmap. Therefore to figure out what size of bitmap box to use, the bitmap aspect ratio must be converted to the WinBatch coordinate system.

Usually you can just experiment with different WinBatch coordinates until you find one that looks reasonable in your box. But for those who wish to work out the coordinate transformations, here is some additional information.

On most standard monitors, say an 800x600 monitor, the pixels on the monitor are square. The WinBatch virtual pixels are not square. In full screen mode, where the WinBatch window approximates the shape of the monitor, the WinBatch virtual pixels are wider than they are tall.

On the monitor a 600x600 block of pixels would be square. In WinBatch coordinates this would be 750x1000. A WinBatch virtual pixel is 75% as tall as it is wide. For every 3 horizontal pixels you need 4 vertical pixels to make a square.

 

Example:

   ;For example, if  you have a bmp file of, say, 100x200 pixels and want To determine what size box you need In WinBatch...

realWidth=100 realHeight=200 ;Set scaling constant to any number you wish to adjust ;final size. In general stay within the range of 0.10 to 10.0 scalingconstant=1.0 virtualWidth=realWidth * 0.75 * scalingconstant virtualHeight=realHeight * scalingconstant ;So if you wish the upper left corner of the bit map ;to start at virtual point 20,30 the co-ordinates ;could be generated as in ulX=20 ulY=30 lrX=Int(ulX+virtualWidth) lrY=Int(ulY+virtualHeight) coordinates=StrCat(ulX, ",", ulY, ",", lrX, ",", lrY) ;Or you could figure out what they are and hard code them. Example 1: bmp = FileLocate("Coffee Bean.bmp") If bmp == "" Message("???", "BitMap not found") Else boxID = 1 coordinates = "100,100,900,900" stretchmode = 3 BoxesUp("200,200,800,800", @NORMAL) BoxCaption(boxID, "WinBatch BoxBitmap Example") BoxBitMap(boxID, coordinates, bmp, stretchmode) TimeDelay(5) EndIf Exit

  
   ;For a slightly more fully fleshed out example, we'll take the BoxBitMap example and convert the coordinates so that the Coffee Bean BMP file will Display as a square, as originally intended.
   bmp = FileLocate("Coffee Bean.bmp")
   If bmp == ""
         Message("???", "BitMap not found")
   Else
         boxID = 1
         ;Coffee Bean.bmp is a 128x128 square bmp file
         realWidth=128
         realHeight=128
         ;Set scaling constant to any number you wish to adjust
         ;final size. In general stay within the range of 0.10 to 10.0
         scalingconstant=6.0
         virtualWidth=realWidth * 0.75 * scalingconstant
         virtualHeight=realHeight * scalingconstant
         ;So if you wish the upper left corner of the bit map
         ;to start at virtual point 20,30 the co-ordinates
         ;could be generated as in
         ulX=100
         ulY=100
         lrX=Int(ulX+virtualWidth)
         lrY=Int(ulY+virtualHeight)
         coordinates=StrCat(ulX, ",", ulY, ",", lrX, ",", lrY)
         stretchmode = 3
         BoxesUp("200,200,800,800", @NORMAL) ; Maintain monitor aspect ratio
         BoxCaption(boxID, "WinBatch BoxBitmap Example")
         BoxBitMap(boxID, coordinates, bmp, stretchmode)
         TimeDelay(5)
   EndIf
   Exit
See Also:

BoxesUp, BoxNew