Any tests drawing text with GDIPLUS ?

Post Reply
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Any tests drawing text with GDIPLUS ?

Post by ukoenig »

Hello,
I tested drawing text with GDIPLUS with

Methods
oGraphics:DrawText( nTop, nLeft, cText, cFont, nFont, oBrush )
oGraphics:DrawTextLFont( nTop, nLeft, cText, oFont, nH, oBrush, hDC, lB, lIt, lUnd, lStr, nOri, nEsc )


NO text displayed :(
There aren't any tests or informations about it.

I can show text a different way but would like to
include it inside my GDIPLUS-paintings

does it work ?

regards
Uwe :?:
Last edited by ukoenig on Thu Sep 26, 2019 8:24 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Any tests drawing text with GDIPLUS ?

Post by cnavarro »

C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Any tests drawing text with GDIPLUS ?

Post by ukoenig »

Christobal,

thank You very much I remember :roll:

I tested using a brushed font but that doesn't work ( just a idea )

aPalBmp := oWnd:ReadImage( c_Path1 + "Blustone.bmp", nil, .t. )
pBrush := GDIP_IMAGEBRUSH( aPalBmp[ 1 ] )

oGraphics:DrawText( nTop + ( nWidth / 2 ) - 15, nLeft + ( nWidth / 2 ) - 50, nPercent, uFont, nFont, pBrush )

with normal text

Image

regards
Uwe :D
Last edited by ukoenig on Thu Sep 26, 2019 8:34 am, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Any tests drawing text with GDIPLUS ?

Post by nageswaragunupudi »

Please try this code

Code: Select all

   local aImage, pBrush, oFont, oWnd

   DEFINE FONT oFont NAME "IMPACT" SIZE 0,-80 BOLD

   DEFINE WINDOW oWnd

   aImage   := oWnd:ReadImage( "c:\fwh\bitmaps\backgrnd\pebbles.bmp",, .t. )
   pBrush   := GDIP_ImageBrush( aImage[ 1 ] )

   oWnd:bPainted := <||
      oWnd:SayText( "SEABMP", { 20,20,200,500}, nil, oFont, pBrush )
      return nil
      >

   ACTIVATE WINDOW oWnd CENTERED

   RELEASE FONT oFont
   GDIP_DeleteBrush()
   PalBmpFree( aImage )
 
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Any tests drawing text with GDIPLUS ?

Post by ukoenig »

What I'm trying to do is different
I want to add the text to a oGraphics-form
not as a window-title

There are 2 methods in GdiPlus I don't know how to use them
maybe it is possible to use them for a solution.

METHOD DrawText( nTop, nLeft, cText, cFont, nFont, oBrush )
METHOD DrawTextLFont( nTop, nLeft, cText, oFont, nH, oBrush, hDC, lB, lIt, lUnd, lStr, nOri, nEsc )


Image

Image

FUNCTION DRAWROUNDRECT(oWnd, oFont1)
LOCAL hdc := oWnd:getdc(), aImage
LOCAL oPen := Pen():New( 255, 0, 0, 255 , 10, .T.)
LOCAL oBrush := Brush():NewSolidBrush( 255, 255, 128, 0 ) // Orange
LOCAL oPath := Path():new()
LOCAL oGraphics := Graphics():New( oWnd:hDC )

// oPen, [oBrush], nLeft, nTop, nWidth, nHight, nRound
oGraphics:DrawRoundRect( oPen, , 250, 50, 200, 200, 50 )
oGraphics:Destroy()

oGraphics := Graphics():New( oWnd:hDC )
oPath:AddRoundRect( 250, 300, 200, 200, 50 )
oGraphics:FillPath( oBrush, oPath)
oGraphics:DrawRoundRect( oPen, , 250, 300, 200, 200, 50 )
oGraphics:Destroy()

oGraphics := Graphics():New( oWnd:hDC )
oPath := Path():new()
// , oBrush, nLeft, nTop, nWidth, nHight
oPath:AddRoundRect( 550, 300, 200, 200, 50 )
oGraphics:FillPath( oBrush, oPath)

oGraphics:Destroy()
oPen:Destroy()

oWnd:releasedc()

RETURN NIL


regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Any tests drawing text with GDIPLUS ?

Post by AntoninoP »

why do you continuously destroy and re-create the graphics?
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Any tests drawing text with GDIPLUS ?

Post by ukoenig »

Antonino,

Yes I agree not needed to be defined for each sample

FUNCTION DRAWROUNDRECT(oWnd, oFont1)
LOCAL hdc := oWnd:getdc(), aImage
LOCAL oPen := Pen():New( 255, 0, 0, 255 , 10, .T.)
LOCAL oBrush1 := Brush():NewSolidBrush( 255, 255, 128, 0 ) // Orange
LOCAL oBrush2 := Brush():NewGradientBrush( 300, 200, 200, 200, 1,;
255, 255, 128, 0,;
255, 255, 255, 255 )
LOCAL oPath := Path():new()
LOCAL oGraphics := Graphics():New( oWnd:hDC )

// sample 1
// oPen, [oBrush], nLeft, nTop, nWidth, nHight, nRound
oGraphics:DrawRoundRect( oPen, , 250, 50, 200, 200, 50 )

// sample 2
oPath:AddRoundRect( 250, 300, 200, 200, 50 )
oGraphics:FillPath( oBrush1, oPath)
oGraphics:DrawRoundRect( oPen, , 250, 300, 200, 200, 50 )

// sample 3
oPath := Path():new()
// , oBrush, nLeft, nTop, nWidth, nHight
oPath:AddRoundRect( 550, 300, 200, 200, 50 )
oGraphics:FillPath( oBrush2, oPath)

oGraphics:Destroy()
oPen:Destroy()

oWnd:releasedc()

RETURN NIL

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Any tests drawing text with GDIPLUS ?

Post by ukoenig »

It is working now

LOCAL oBrush1 := Brush():NewSolidBrush( 255, 255, 128, 0 ) // Orange

DEFINE FONT oFontLarge NAME "Arial" SIZE 0, -30 BOLD ITALIC

// font and size
oGraphics:DrawTextLFont( 50, 125, "mod harbour", oFontLarge, 30, oBrush1, hDC )
oGraphics:DrawTextLFont( 80, 125, "install", oFontLarge, 20, oBrush1, hDC )

The 1. and 3. one works fine

METHOD NewSolidBrush( nTrans, nRed, nGreen, nBlue ) :D
METHOD NewTextureBrush( oGdiBmp ) :(
( wanted to be used for text )
METHOD NewGradientBrush( nTop, nLeft, nWidth, nHeight, nType,; :D
nTrans1, nRed1, nGreen1, nBlue1,;
nTrans2, nRed2, nGreen2, nBlue2 )

regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Post Reply