Board index » cppbuilder » Re: Attending Form finishes to draw...

Re: Attending Form finishes to draw...


2003-07-11 06:50:09 AM
cppbuilder80
In the constructor of your form put this code in there.
DoubleBuffered = true;
"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
In my from there is a TImage with a bitmap loaded, when i move the mouse i
draw some lines on this TImage, and after i redraw the bitmap...
When i move the mouse over the TImage, during the drawing i se the bitmap
to
flash...
How can i evit this bad effect coused by the absence of double buffering?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.493 / Virus Database: 292 - Release Date: 6/26/2003
 
 

Re:Re: Attending Form finishes to draw...

unluckily it doesn't work... : (
i've used this:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Form1->DoubleBuffered = true;
}
but nothing....
"Junk Mail" < XXXX@XXXXX.COM >ha scritto nel messaggio
Quote
In the constructor of your form put this code in there.

DoubleBuffered = true;

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
news: XXXX@XXXXX.COM ...
>In my from there is a TImage with a bitmap loaded, when i move the mouse
i
>draw some lines on this TImage, and after i redraw the bitmap...
>When i move the mouse over the TImage, during the drawing i se the
bitmap
to
>flash...
>How can i evit this bad effect coused by the absence of double
buffering?
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.493 / Virus Database: 292 - Release Date: 6/26/2003


 

Re:Re: Attending Form finishes to draw...

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
In my from there is a TImage with a bitmap loaded,
when i move the mouse i draw some lines on this
TImage, and after i redraw the bitmap... When i
move the mouse over the TImage, during the
drawing i se the bitmap to flash...
What does your actual drawing code look like?
Gambit
 

{smallsort}

Re:Re: Attending Form finishes to draw...

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
Form1->DoubleBuffered = true;
That only has effect when the form itself is being drawn, which is not the
case here.
Gambit
 

Re:Re: Attending Form finishes to draw...

ok so??
what i must use in my case??
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >ha scritto nel messaggio
Quote

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
news:3f0def5a$ XXXX@XXXXX.COM ...

>Form1->DoubleBuffered = true;

That only has effect when the form itself is being drawn, which is not the
case here.


Gambit


 

Re:Re: Attending Form finishes to draw...

When i push a button i draw on Image (a TImage object) the pBitmap...after
when i move the mouse on the Image
i redraw in this way:
void __fastcall TForm1::Source1Move(TObject *Sender, TShiftState Shift,
int X, int Y)
{
X = getX(X); //get a value traformed of X, anyway not imporant
Y = getY(Y);
Image1->Canvas->Draw(0,0, pBitmap);
Image1->Canvas->MoveTo(X, Y);
Image1->Canvas->LineTo(X*2, Y*2);
...
}
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >ha scritto nel messaggio
Quote

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
news: XXXX@XXXXX.COM ...
>In my from there is a TImage with a bitmap loaded,
>when i move the mouse i draw some lines on this
>TImage, and after i redraw the bitmap... When i
>move the mouse over the TImage, during the
>drawing i se the bitmap to flash...

What does your actual drawing code look like?


Gambit


 

Re:Re: Attending Form finishes to draw...

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
Image1->Canvas->Draw(0,0, pBitmap);
You are redrawing the entire image on every single move of the mouse. That
is bound to be the cause of your flickering. You should consider doing your
drawing to a separate offscreen bitmap and then BitBlt() the completed image
to the Timage only when actually needed.
Gambit
 

Re:Re: Attending Form finishes to draw...

So, I don't want change the image, so i draw just only one time it... ok
now i put over the TImage that contains the bitmap another TImage that will
draw the lines...
I want set the TImage2 transparent so i can see the bitmap under this...
how?
setting Image2->transparent = true; doesn't work at my case!
what i must use?
and drawing above the lines also a red Rectangle with fill at 50%
transparent so i can see the bitmap underside?
Tnx
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >ha scritto nel messaggio
Quote

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
news:3f0df56c$ XXXX@XXXXX.COM ...
>Image1->Canvas->Draw(0,0, pBitmap);

You are redrawing the entire image on every single move of the mouse.
That
is bound to be the cause of your flickering. You should consider doing
your
drawing to a separate offscreen bitmap and then BitBlt() the completed
image
to the Timage only when actually needed.


Gambit


 

Re:Re: Attending Form finishes to draw...

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
now i put over the TImage that contains the bitmap
another TImage that will draw the lines...
I didn't say to use a second TImage. I said to use a separate bitmap. That
is not quite the same thing.
Quote
I want set the TImage2 transparent so i can see
the bitmap under this... how?
You're going about it all wrong. That is not what I was implying earlier at
all. I meant for you to have a second standalone TBitmap that you copy your
original image to, then draw your lines onto. The second bitmap only exists
in memory, it is not visual to the user at all. Then once you are done with
all of your drawing, copy the final bitmap to the TImage for the user to
see:
void __fastcall TForm1::Source1Move(TObject *Sender, TShiftState Shift,
int X, int Y)
{
X = getX(X);
Y = getY(Y);
Graphics::TBitmap *pBmpTemp = new Graphics::TBitmap;
try
{
pBmpTemp->Assign(pBitmap);
TCanvas *pCanvas = pBmpTemp->Canvas;
pCanvas->MoveTo(X, Y);
pCanvas->LineTo(X*2, Y*2);
//...
BitBlt(Image1->Canvas->Handle, 0, 0, Image1->Width,
Image1->Height, pCanvas->Handle, 0, 0, SRCCOPY);
}
__finally {
delete pBmpTemp;
}
}
Gambit