TBitmap

Fuente: source/classes/bitmap.prg

Inherits from: TControl

TBitmap is a control that displays a bitmap image from a file, resource, or handle. It supports zoom, transparency, alpha blending, stretch modes, and scrollable large images. The control can display BMP files embedded as resources or loaded from disk.

Key DATA Members

DATATypeDescription
hBitmapHandleHandle to the bitmap GDI object
hPaletteHandleHandle to the bitmap color palette
cBmpFileCharacterBitmap file path on disk
cResNameCharacterBitmap resource name embedded in the EXE
nZoomNumericZoom factor (1 = original size)
lTransparentLogicalEnable transparent background drawing
lStretchLogicalStretch bitmap to fit the control dimensions
nImgWidthNumericOriginal bitmap width in pixels
nImgHeightNumericOriginal bitmap height in pixels
lHasAlphaLogicalWhether the bitmap has an alpha channel
aHotAreasArrayArray of clickable hot areas on the bitmap

Methods

MethodDescription
New( nTop, nLeft, nW, nH, cRes, cFile, lNoBorder, oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor, cMsg, lUpdate, bWhen, lPixel, bValid, lDesign )Create a new bitmap control
ReDefine( nId, cRes, cFile, oWnd, ... )Redefine from a dialog resource placeholder
LoadImage( cResName, cBmpFile )Load bitmap from resource name or disk file
LoadBMP( cBmpFile )Load a bitmap from disk by filename
SetBMP( cResName )Load a bitmap from a resource name
Zoom( nZoom )Set zoom level (1=100%, 2=200%, etc.)
SaveToBmp( cFile )Save the current bitmap to a file on disk
Paint()Draw the bitmap onto the control surface
Center()Center the bitmap within the control area
CopyToClipboard()Copy bitmap image to the clipboard
HasAlpha()Check if the bitmap has an alpha channel

Example: Load and Display a Bitmap

#include "FiveWin.ch"

function Main()

   local oWnd, oBmp

   DEFINE WINDOW oWnd TITLE "TBitmap Demo" SIZE 600, 450

   @ 10, 10 BITMAP oBmp OF oWnd ;
      FILE "c:\fwh\bitmaps\olga1.bmp" ;
      SIZE 300, 200

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También