xHarbour Reference Documentation > Class Reference (textmode) xHarbour Developers Network  

Win32Bmp()

Creates a new Win32Bmp object.

Syntax

Win32Bmp():new()

Return

The function returns a new Win32Bmp object and method :new() initializes the object.

Description

Objects of class Win32Bmp are used in conjunction with objects of the Win32Prn class for printing bitmap images using the Windows Graphical Device Interface (GDI). For this reason, an application using Win32Bmp objects must be created as GUI application. Text mode applications, or console applications, cannot use the Win32Bmp class.

A Win32Bmp object is capable of loading a bitmap file into memory with its :loadFile() method. After the bitmap image is loaded, it can be printed with the aid of a Win32Prn() object using method :draw().

Instance variables

:rect
Array with X/Y coordinates where to draw the bitmap on the printer.
:bitmap
Character string holding the data of the bitmap image.
:fileName
Character string holding the file name of the bitmap image.

Methods

:draw( <oWin32Prn>, <aRectangle> ) --> lSuccess
Draws the bitmap image to a printer.
:loadFile( <cFileName> ) --> lSuccess
Loads a bitmap image file into memory.

Info

See also:Win32Prn()
Category: Object functions , Printer functions , xHarbour extensions
Source:rtl\win32prn.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example outlines the steps required for printing
// a bitmap image

  PROCEDURE Main
     LOCAL cFileName, oWin32Bmp, oWin32Prn

      oWin32Prn := Win32Prn():new()  // default printer object
      IF .NOT. oWin32Prn:create()    // create device context
         Alert( "Unable to create device context for printer" )
         QUIT
      ENDIF

      cFileName := "TestImage.bmp"

      oWin32Bmp := Win32Bmp():new()  // load bitmap file into memory
      IF .NOT. oWin32Bmp:loadFile( cFileName )
         Alert( "Unable to load bitmap file: " + cFileName )
         QUIT
      ENDIF

      // print bitmap image
      oWin32Bmp:draw( oWin32Prn,  { 200, 400, 2000, 1500 } )

      // release GDI system resources of printer
      oWin32Prn:destroy()
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe