| View previous topic :: View next topic |
| Author |
Message |
bar Guest
|
Posted: Sat May 19, 2007 11:04 pm Post subject: Form Paint |
|
|
Hello all
I have a TImage control.having a .bmp file.
How can i paint this picture to my form so that it will like a tile image.
Thanks
SA |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun May 20, 2007 12:48 am Post subject: Re: Form Paint |
|
|
"bar" <shaikakbar250281 (AT) yahoo (DOT) co.in> wrote in message
news:464f3c30 (AT) newsgroups (DOT) borland.com...
| Quote: | I have a TImage control.having a .bmp file.
How can i paint this picture to my form so that it will like a tile
image. |
TImage does not have any tiling option. You should get rid of the
TImage altogether and draw the .bmp directly onto the TForm's Canvas
in its OnPaint event. Then you can draw it any way you wish. For
example:
private:
Graphics::TBitmap *FBmp;
__fastcall TForm1::TForm1(TComponent *Owner)
{
FBmp = new Graphics::TBitmap;
FBmp->LoadFromFile("myimage.bmp");
}
void __fastcall TForm1::FormPaint(TObject *Sender)
{
for(int y = 0; y < ClientHeight; y += FBmp->Height)
{
for(int x = 0; x < ClientWidth; x += FBmp->Width)
Canvas->Draw(x, y, FBmp);
}
}
Gambit |
|
| Back to top |
|
 |
bar Guest
|
Posted: Sun May 20, 2007 1:30 pm Post subject: Re: Form Paint |
|
|
But how can i paint a jpg image.
Thanks
SA
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:464f54d0$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"bar" <shaikakbar250281 (AT) yahoo (DOT) co.in> wrote in message
news:464f3c30 (AT) newsgroups (DOT) borland.com...
I have a TImage control.having a .bmp file.
How can i paint this picture to my form so that it will like a tile
image.
TImage does not have any tiling option. You should get rid of the
TImage altogether and draw the .bmp directly onto the TForm's Canvas
in its OnPaint event. Then you can draw it any way you wish. For
example:
private:
Graphics::TBitmap *FBmp;
__fastcall TForm1::TForm1(TComponent *Owner)
{
FBmp = new Graphics::TBitmap;
FBmp->LoadFromFile("myimage.bmp");
}
void __fastcall TForm1::FormPaint(TObject *Sender)
{
for(int y = 0; y < ClientHeight; y += FBmp->Height)
{
for(int x = 0; x < ClientWidth; x += FBmp->Width)
Canvas->Draw(x, y, FBmp);
}
}
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon May 21, 2007 5:49 am Post subject: Re: Form Paint |
|
|
"bar" <shaikakbar250281 (AT) yahoo (DOT) co.in> wrote in message
news:46500729 (AT) newsgroups (DOT) borland.com...
| Quote: | But how can i paint a jpg image.
|
The same way as I showed you earlier. Just use a TJPEGImage instead
of a TBitmap. They both derive from TGraphic, which is what
TCanvas::Draw() takes as an input parameter.
Gambit |
|
| Back to top |
|
 |
|