Board index » delphi » Using windows API BitBlt function in Delphi 2.0

Using windows API BitBlt function in Delphi 2.0

I am using Delphi 2.0 and I am trying to copy a bitmap from one image box to
another on the same form.  The copy must be done quickly.

I know this can be done quickly using Visual Basic and the BitBlt function in
the Windows API.  I of course want to use the BitBlt function in Delphi 2.0.

The big question is how do I get the device context for the source and
destination image boxes?  In VB there is a hook (property) called hDC which is
called like Picture1.hdc, this does not seem to work with Delphi.

What do I pass the BitBlt function when it asks for parameters hdcDest and
hdcSrc?  Is it even possible to use BitBlt with Delphi?  

The syntax for the BitBlt fucnction is: (from Win32 help file)

BOOL BitBlt(

    HDC  hdcDest, // handle of destination device context
    int  nXDest,  // x-coordinate of destination rectangle's upper-left corner
    int  nYDest,  // x-coordinate of destination rectangle's upper-left corner
    int  nWidth,  // width of destination rectangle
    int  nHeight, // height of destination rectangle
    HDC  hdcSrc,  // handle of source device context
    int  nXSrc,   // x-coordinate of source rectangle's upper-left corner  
    int  nYSrc,   // y-coordinate of source rectangle's upper-left corner
    DWORD  dwRop  // raster operation code
   );

Thanks in advance,

Mark Goedert
LAN Administrator
UIC Computer Center

 

Re:Using windows API BitBlt function in Delphi 2.0


x <y...@somehost.somedomain> schrieb im Beitrag
<5oro7j$2s8...@piglet.cc.uic.edu>...

Quote
> I am using Delphi 2.0 and I am trying to copy a bitmap from one image box
to
> another on the same form.  The copy must be done quickly.

> I know this can be done quickly using Visual Basic and the BitBlt
function in
> the Windows API.  I of course want to use the BitBlt function in Delphi
2.0.

> The big question is how do I get the device context for the source and
> destination image boxes?  In VB there is a hook (property) called hDC
which is
> called like Picture1.hdc, this does not seem to work with Delphi.

There's a variable called handle for using api functions. Look at the help
file TImageBox or what component you use.

Heiko

luet...@sunpool.cs.uni-magdeburg.de

How can you I know what I want,
before I hear what I say.

Re:Using windows API BitBlt function in Delphi 2.0


Quote
Heiko Lttge wrote:
> There's a variable called handle for using api functions. Look at the
> help
> file TImageBox or what component you use.

If you have 2 Timage components  in same form  you can use this :

BitBlt ( Image1.Canvas.Handle, ...Image2.Canvas.Handle,...);

this copies the contents of Image2 to image1.

Hope this helps...

Lazikas o Pontios.

Re:Using windows API BitBlt function in Delphi 2.0


Quote
x wrote:

> I am using Delphi 2.0 and I am trying to copy a bitmap from one image box to
> another on the same form.  The copy must be done quickly.

> I know this can be done quickly using Visual Basic and the BitBlt function in
> the Windows API.  I of course want to use the BitBlt function in Delphi 2.0.

> The big question is how do I get the device context for the source and
> destination image boxes?  In VB there is a hook (property) called hDC which is
> called like Picture1.hdc, this does not seem to work with Delphi.

> What do I pass the BitBlt function when it asks for parameters hdcDest and
> hdcSrc?  Is it even possible to use BitBlt with Delphi?

        You can certainly use BitBlt in Delphi. You probably don't want
to - you can use the Delphi CopyRect function to do the same thing (if
you're missing the raster-operation paramater, you set that by setting
the CopyMode property of the destination Canvas.)

        A Delphi Canvas is an encapsulation of a device context -
a Canvas's Handle property is an HDC, so ACanvas.Handle is what
you'd pass to BitBlt if you were using BitBlt directly for
some reason.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Other Threads