Board index » delphi » Help with BitBlt needed...

Help with BitBlt needed...

Hi!

I'm trying to use the BitBlt function to copy an image to
an owner drawn listbox. What I have come up with
so far looks like this:

var
   src_handle:hWnd;
   dest_handle:hWnd;
begin
     dest_handle:=listbox3.canvas.handle;
     src_handle:=image2.picture.bitmap.handle;

   BitBlt(GetDeviceContext(dest_handle), 0, index*ListBox3.Itemheight,
64, 64, GetDeviceContext(src_handle), 0, 0, SRCCOPY);

I thought this might do the trick but it doesn't.
Anyone have any ideas of what I'm doing wrong?

TIA
-Tommy

 

Re:Help with BitBlt needed...


On 17 Jul 1997 13:37:18 GMT, to...@fossekall.ii.uib.no (Tommy Nordvik)
wrote:

Quote
>     dest_handle:=listbox3.canvas.handle;
>     src_handle:=image2.picture.bitmap.handle;

This should probably be image2.canvas.handle;

Quote
>I'm trying to use the BitBlt function to copy an image to

Why not use the Canvas.CopyRect method?  It seems to be just as
efficient as a BitBlt (that's what it does internally).  I tend to
prefer using the Delphi way vs the WinAPI stuff.

begin
     With listbox3 do begin
          Canvas.CopyMode := cmSrcCopy;
          Canvas.CopyRect(

Rect(0,index*ItemHeight,64,(index*ItemHeight)+64),
                          image2.canvas,
                         Rect(0,0,64,64) );
     end;
end;

Ok, so it's not much cleaner.  But I'd still prefer it over WinAPI
calls.  You never know, someday they may port Delphi to MacOS or OS/2
or XWindows... but I'm not holding my breath!

Chuck Gadd
Director of Software Development, {*word*104} FX Communications.
e-mail:cgadd-NOS...@{*word*104}-fx.com  http://www.csd.net/~cgadd
Remove the -NOSPAM from my email address to send me e-mail.
*** I boycott businesses that send me unsolicited email adverti{*word*224}ts ***

Re:Help with BitBlt needed...


Try src_handle := image2.picture.bitmap.canvas.handle or
     src_handle := image2.canvas.handle

or perhaps use the draw method

  listbox3.canvas.draw(0,0,image2.picture.bitmap);

In article <5ql76e$c7...@toralf.uib.no>, to...@fossekall.ii.uib.no (Tommy

Quote
Nordvik) wrote:
>Hi!

>I'm trying to use the BitBlt function to copy an image to
>an owner drawn listbox. What I have come up with
>so far looks like this:

>var
>   src_handle:hWnd;
>   dest_handle:hWnd;
>begin
>     dest_handle:=listbox3.canvas.handle;
>     src_handle:=image2.picture.bitmap.handle;

>   BitBlt(GetDeviceContext(dest_handle), 0, index*ListBox3.Itemheight,
>64, 64, GetDeviceContext(src_handle), 0, 0, SRCCOPY);

>I thought this might do the trick but it doesn't.
>Anyone have any ideas of what I'm doing wrong?

>TIA
>-Tommy

Re:Help with BitBlt needed...


This is a multi-part message in MIME format.
--------------5EF3D3990E43AADC4978C0C9
Content-Type: text/plain; charset=iso-8859-7
Content-Type: text/plain; charset=iso-8859-7
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit

Quote
Tommy Nordvik wrote:
> Hi!

> I'm trying to use the BitBlt function to copy an image to
> an owner drawn listbox. What I have come up with
> so far looks like this:

> var
>    src_handle:hWnd;
>    dest_handle:hWnd;
> begin
>      dest_handle:=listbox3.canvas.handle;
>      src_handle:=image2.picture.bitmap.handle;

>    BitBlt(GetDeviceContext(dest_handle), 0, index*ListBox3.Itemheight,

> 64, 64, GetDeviceContext(src_handle), 0, 0, SRCCOPY);

   Not enough arguments ! :-)

Try this, it is tested :

        DC:=GetDC (DestHandle);
        IntersectClipRect(DC, 0, 0, DestRect.right , DestRect.Bottom);

        StretchBlt(DC, 0, 0,DestRect.right  ,DestRect.Bottom,
          {Bitmap.}Canvas.FHandle, SourceRect.Left, SourceRect.Top,
          SourceRect.Right, SourceRect.Bottom, ACanvas.CopyMode);

        ReleaseDC (ParentHandle,DC);

where Bitmap.Canvas.FHandle is the source device-context handle of your
image and
SourceRect the portion of the image you want to copy.

I have put this code into tbitmap.draw() procedure at delphi's
<graphics.pas> unit and now i can zoom my bitmap.

Hope it helps !

Lazikas o Pontios.

--------------5EF3D3990E43AADC4978C0C9
Content-Type: text/x-vcard; charset=iso-8859-7; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Lazaros Sechidis
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Lazaros Sechidis
n:              Sechidis;Lazaros
email;internet: sechi...@hypernet.hyper.gr
title:          Phd Student, Survey Eng.
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
end:            vcard

--------------5EF3D3990E43AADC4978C0C9--

Other Threads