Board index » cppbuilder » Draw in a limited region

Draw in a limited region


2003-11-28 09:24:44 PM
cppbuilder52
Hello,
I am trying to draw an image a in fix region ( X_Start, X_End, Y_Start,
Y_End ).
The method Draw(X_Start, Y_Start, MyImage) does not enable me to do
that with the limitation along X (X_End) and Y (Y_End).
Any help would be appreciated,
Regards,
Claude
 
 

Re:Draw in a limited region

On Fri, 28 Nov 2003 14:24:44 +0100, TADONKI Claude < XXXX@XXXXX.COM >
wrote:
Quote
Hello,
I am trying to draw an image a in fix region ( X_Start, X_End, Y_Start,
Y_End ).
The method Draw(X_Start, Y_Start, MyImage) does not enable me to do
that with the limitation along X (X_End) and Y (Y_End).
Any help would be appreciated,
Regards,
Hi Claude,
two methods:
a) create a sub bitmap with limited area then draw it onto your canvas.
b) use Windows's regions
msdn.microsoft.com/library/default.asp
Cheers
 

Re:Draw in a limited region

Claude,
Quote
I am trying to draw an image a in fix region ( X_Start, X_End,
Y_Start, Y_End ). [...]
The BitBlt() GDI function allows you to indirectly specify the ending
coordinates via its 4th and 5th parameters which indicate the width and
height of the target (destination) rectangle; for example...
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int const xstart = 10;
int const ystart = 50;
int const xend = 100;
int const yend = 200;
HDC const hDstDC = Canvas->Handle;
HDC const hSrcDC = Image1->Canvas->Handle;
BitBlt(
hDstDC, // target DC
xstart, ystart, // target X, Y
xend - xstart, // target width
yend - ystart, // target height
hSrcDC, // source DC
0, 0, // source X, Y
SRCCOPY // direct copy
);
}
Note that if the target DC (hDstDC) corresponds to a TImage's Canvas, you'll
need to call the TImage::Refresh() method in order to see the results.
HTH,
Damon (TeamB)
 

{smallsort}