FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Any tests drawing text with GDIPLUS ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Any tests drawing text with GDIPLUS ?
Posted: Sat Sep 14, 2019 08:19 AM
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 :-)
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.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Any tests drawing text with GDIPLUS ?
Posted: Sat Sep 14, 2019 09:02 AM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Any tests drawing text with GDIPLUS ?
Posted: Sat Sep 14, 2019 12:30 PM
Christobal,

thank You very much I remember :-)

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



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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Any tests drawing text with GDIPLUS ?
Posted: Wed Sep 25, 2019 03:56 PM
Please try this code
Code (fw): Select all Collapse
   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 )


Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Any tests drawing text with GDIPLUS ?
Posted: Thu Sep 26, 2019 08:35 AM
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 )






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.
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Any tests drawing text with GDIPLUS ?
Posted: Thu Sep 26, 2019 09:21 AM

why do you continuously destroy and re-create the graphics?

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Any tests drawing text with GDIPLUS ?
Posted: Thu Sep 26, 2019 10:48 AM
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 :-)
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.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Any tests drawing text with GDIPLUS ?
Posted: Mon Sep 30, 2019 01:29 PM
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 ) :-)
METHOD NewTextureBrush( oGdiBmp ) :-)
( wanted to be used for text )
METHOD NewGradientBrush( nTop, nLeft, nWidth, nHeight, nType,; :-)
nTrans1, nRed1, nGreen1, nBlue1,;
nTrans2, nRed2, nGreen2, nBlue2 )

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.

Continue the discussion