TXImage

Source: source/classes/ximage.prg

Inherits from: TControl

TXImage is an extended image viewer control that supports zoom, rotation, brightness, contrast, gamma correction, alpha blending, grayscale conversion, and blur effects. It provides a built-in popup context menu with options for saving, printing, copying to clipboard, and image navigation.

Key DATA Members

DATATypeDescription
cImageFileCharacterPath or identifier of the loaded image
nZoomNumericZoom percentage (100 = original size)
nRotateNumericRotation angle in degrees
nSizeNumericImage dimension for size-based fitting
cAlignCharacterAlignment string (e.g., "C" for center)
nGammaNumericGamma correction value
nBrightnessNumericBrightness adjustment
nContrastNumericContrast adjustment
nAlphaNumericAlpha transparency level (0-255)
lGrayLogicalDisplay the image in grayscale
nBlurNumericBlur radius

Methods

MethodDescription
New( nTop, nLeft, nW, nH, bImage, oWnd )Create a new TXImage control. bImage can be a file name, bitmap handle, or a code block returning an image.
Center()Center the image within the control area
FitWidth()Scale the image to fit the control width
FitHeight()Scale the image to fit the control height
FitRect()Scale the image to fit entirely within the control
FitOrglSize()Restore the image to its original pixel dimensions
Zoom( n )Set the zoom level to n percent
Rotate( nDeg )Rotate the image by nDeg degrees
SetSource( uNew )Replace the displayed image with a new source
Paste()Paste an image from the clipboard
CopyToClipBoard()Copy the current image to the clipboard
Save( lAsViewed, cFile )Save the image to disk. If lAsViewed is .T., adjustments (zoom, effects) are preserved.

Free Functions

FunctionDescription
XImage( uImage, cTitle )Display an image in a standalone viewer dialog window
XImageArray( aImages, cTitle )Display a navigable array of images in a viewer dialog

Example: Image Viewer with Context Menu

#include "FiveWin.ch"

function Main()

   local oWnd, oImg

   DEFINE WINDOW oWnd TITLE "Image Viewer" SIZE 800, 600

   @ 10, 10 XIMAGE oImg FILE "photo.jpg" ;
      SIZE 760, 540 OF oWnd

   oImg:FitRect()
   oImg:Rotate( 90 )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also