Board index » delphi » CopyRect HUH!

CopyRect HUH!

I have application which draws a TPaintbox by merging two Tbitmaps to a
buffer and then coping to the box.  The problem is that they (The
TBitmaps) redraw at different times with different colours (Only two
colours) and I Do not understand how the TCAnvas.CopyRect works, so I
use trial and error to get the right outcome.  So is there a clear
(CopyRect for Dummies) explanation on how it works.  Thanx.
 

Re:CopyRect HUH!


On Wed, 28 Jul 1999 21:29:16 -0700, Roger & Ann <Roger...@IPrimus.ca>
wrote:

Quote
>I have application which draws a TPaintbox by merging two Tbitmaps to a
>buffer and then coping to the box.  The problem is that they (The
>TBitmaps) redraw at different times with different colours (Only two
>colours) and I Do not understand how the TCAnvas.CopyRect works, so I
>use trial and error to get the right outcome.  So is there a clear
>(CopyRect for Dummies) explanation on how it works.

Can you describe in more detail precisely what happens? Are the two
bitmaps monochrome? That is, are they 1-bit bitmaps? Or are they color
bitmaps that use only two colors? In either case, what are the two
colors involved? Do you change the value of CopyMode? If so, what do
you change it to?

-Steve

Re:CopyRect HUH!


Quote
"Steve Schafer (TeamB)" wrote:

> Can you describe in more detail precisely what happens? Are the two
> bitmaps monochrome? That is, are they 1-bit bitmaps? Or are they color
> bitmaps that use only two colors? In either case, what are the two
> colors involved? Do you change the value of CopyMode? If so, what do
> you change it to?

> -Steve

Sure
    I have two TBitmaps (Background and Needle) which are created at
runtime.  They both have the same two colours (not monochrome).  The colours
are: 1)  clBtnface background with a Black drawing, 2) black background with
red or yellow or something drawing, or 3) two colours which are not known at
design time.
    This seems (?) to give me three choices to merge the drawings and then
to cmSrcCopy them to my Paintbox.  I used trail and error to get the
following code, it works (until I hit my latest problem - see bottom).

{ I have two colours front and back (GFrontColour and GBackcolour).  I have
deleted all the house keeping for the TempBit (TempBit?: TBitmap) objects.

  If GBackColour = clBlack then
     begin
      TempBit2.Canvas.CopyMode := cmMergeCopy;
      TempBit2.Canvas.CopyRect(TRt,BackGround.Canvas,TRt);
      TempBit2.Canvas.CopyMode := cmSrcInvert;
      TempBit2.Canvas.CopyRect(TRt,Needle.Canvas,TRt);
    end
  else
    If GfrontColour = Clblack then
      begin
        TempBit2.Canvas.CopyMode := cmSrcCopy;
        TempBit2.Canvas.CopyRect(TRt,BackGround.Canvas,TRt);
        TempBit2.Canvas.CopyMode := cmSrcAnd;
        TempBit2.Canvas.CopyRect(TRt,Needle.Canvas,TRt);
      end
    else
      begin
        TempBit3.Canvas.CopyMode := cmSrcCopy;
        TempBit3.Canvas.CopyRect(TRt,Needle.Canvas,TRt);
        TempBit3.Mask(GBackColour);

        TempBit4.Canvas.CopyMode := cmsrcCopy;
        TempBit4.Canvas.CopyRect(TRt,TempBit3.Canvas,TRt);

        TempBit4.Canvas.CopyMode := cmSrcErase;
        TempBit4.Canvas.CopyRect(TRt,Needle.Canvas,TRt);

        TempBit2.Canvas.CopyMode := cmSrcCopy;
        TempBit2.Canvas.CopyRect(TRt,BackGround.Canvas,TRt);

        TempBit2.Canvas.CopyMode := cmSrcAnd;
        TempBit2.Canvas.CopyRect(TRt,TempBit3.Canvas,TRt);

        TempBit2.Canvas.CopyMode := cmSrcPaint;
        TempBit2.Canvas.CopyRect(TRt,TempBit4.Canvas,TRt);
       end;

{ This may not be pretty but it works Until...

now the background and the frontground are being drawn on different threads
this seems to cause a problem when the colours are changed in mid stream, so
I need to understand this process better. Thanx. I hope this helps.

  dataflow.vcf
< 1K Download

Re:CopyRect HUH!


On Thu, 29 Jul 1999 10:39:42 -0700, Roger Mackenzie

Quote
<dataf...@sprint.ca> wrote:
>    I have two TBitmaps (Background and Needle) which are created at
>runtime.  They both have the same two colours (not monochrome).  The colours
>are: 1)  clBtnface background with a Black drawing, 2) black background with
>red or yellow or something drawing, or 3) two colours which are not known at
>design time.
>    This seems (?) to give me three choices to merge the drawings and then
>to cmSrcCopy them to my Paintbox.  I used trail and error to get the
>following code, it works (until I hit my latest problem - see bottom).

It would help if you could explain (in words, not code) what you're
actually trying to achieve.

Quote
>now the background and the frontground are being drawn on different threads

What do you mean by that? Nothing in the code you posted has anything
to do with multiple threads of execution.

-Steve

Re:CopyRect HUH!


Quote
"Steve Schafer (TeamB)" wrote:
> On Thu, 29 Jul 1999 10:39:42 -0700, Roger Mackenzie
> <dataf...@sprint.ca> wrote:

> >    I have two TBitmaps (Background and Needle) which are created at
> >runtime.  They both have the same two colours (not monochrome).  The colours
> >are: 1)  clBtnface background with a Black drawing, 2) black background with
> >red or yellow or something drawing, or 3) two colours which are not known at
> >design time.
> >    This seems (?) to give me three choices to merge the drawings and then
> >to cmSrcCopy them to my Paintbox.  I used trail and error to get the
> >following code, it works (until I hit my latest problem - see bottom).

> It would help if you could explain (in words, not code) what you're
> actually trying to achieve.

> >now the background and the frontground are being drawn on different threads

> What do you mean by that? Nothing in the code you posted has anything
> to do with multiple threads of execution.

Sorry it was just a bug I had - fixed now.
I really just need to understand what is happening with CopyRect and CopyMode.  I
got relay confused on when to mergecopy or to srcCopy etc..  It seems that I need
to know whether one of my colours is black - I guess.  The documentation is
unclear about what is happening.  I would just like a clear explanation about
what is happening. Thanx.

- Show quoted text -

Quote

> -Steve

  dataflow.vcf
< 1K Download

Re:CopyRect HUH!


On Fri, 30 Jul 1999 11:21:39 -0700, Roger Mackenzie

Quote
<dataf...@sprint.ca> wrote:
>I really just need to understand what is happening with CopyRect and CopyMode.  I
>got relay confused on when to mergecopy or to srcCopy etc..  It seems that I need
>to know whether one of my colours is black - I guess.  The documentation is
>unclear about what is happening.  I would just like a clear explanation about
>what is happening. Thanx.

MergeCopy: The source image is ANDed with the current brush and then
transferred to the target. (The Delphi online help is incorrect in its
description of this ROP code--use the Win32 online help; look under
BitBlt.)

ScrCopy: The source image is transferred directly to the target
without modifications.

-Steve

Other Threads