Board index » cppbuilder » Can you copy the TLabel->Canvas into a bitmap

Can you copy the TLabel->Canvas into a bitmap

I have a need to be able to take the Caption of a TLabel (as it appears in
the label, not the text of it) and make it into a TBitmap.  I know you can
write a bitmap to a canvas but how would you take a canvas and make a
bitmap.

Or if it would be easier, how would you create a bitmap of font formatted
text?

Thanks in advance.

John

 

Re:Can you copy the TLabel->Canvas into a bitmap


On Fri, 3 Dec 1999 16:02:25 -0800, "John Gatti"

Quote
<jgattiREMOVET...@yahoo.com> wrote:
>I have a need to be able to take the Caption of a TLabel (as it appears in
[snip]
>bitmap.

>Or if it would be easier, how would you create a bitmap of font formatted
>text?

Hi John,

below the code which paints a text into a bitmap.

------------------------------------------------------------------------
    AnsiString Msg = "Quod erat demonstrandum";

    Graphics::TBitmap* B = new Graphics::TBitmap;

    TCanvas* C = B->Canvas;

    C->Font->Name = "Arial";
    C->Font->Size = 20;
    C->Font->Color = clYellow;

    C->Brush->Color = clBlack;

    B->Height = C->TextHeight( Msg );
    B->Width = C->TextWidth( Msg );

    C->TextRect( C->ClipRect, 0, 0, Msg );

    [ use B ]

    delete B;
------------------------------------------------------------------------

HTH

Regards

Giuliano

Re:Can you copy the TLabel->Canvas into a bitmap


try something like this..
mybitmap->Canvas.CopyRect(Mylabel->ClientRect, Mylabel->Canvas,
Mylabel->ClientRect);
Quote
John Gatti wrote:
> I have a need to be able to take the Caption of a TLabel (as it appears in
> the label, not the text of it) and make it into a TBitmap.  I know you can
> write a bitmap to a canvas but how would you take a canvas and make a
> bitmap.

> Or if it would be easier, how would you create a bitmap of font formatted
> text?

> Thanks in advance.

> John

Re:Can you copy the TLabel->Canvas into a bitmap


Worked great!  Thanks.

Quote
"Giuliano" <gcardin...@remove.adhoc.net> wrote in message

news:38485ed1.107261775@forums.borland.com...
Quote
> On Fri, 3 Dec 1999 16:02:25 -0800, "John Gatti"
> <jgattiREMOVET...@yahoo.com> wrote:

> >I have a need to be able to take the Caption of a TLabel (as it appears
in
> [snip]
> >bitmap.

> >Or if it would be easier, how would you create a bitmap of font formatted
> >text?

> Hi John,

> below the code which paints a text into a bitmap.

> ------------------------------------------------------------------------
>     AnsiString Msg = "Quod erat demonstrandum";

>     Graphics::TBitmap* B = new Graphics::TBitmap;

>     TCanvas* C = B->Canvas;

>     C->Font->Name = "Arial";
>     C->Font->Size = 20;
>     C->Font->Color = clYellow;

>     C->Brush->Color = clBlack;

>     B->Height = C->TextHeight( Msg );
>     B->Width = C->TextWidth( Msg );

>     C->TextRect( C->ClipRect, 0, 0, Msg );

>     [ use B ]

>     delete B;
> ------------------------------------------------------------------------

> HTH

> Regards

> Giuliano

Other Threads