Page 1 of 1

Any tests drawing text with GDIPLUS ?

Posted: Sat Sep 14, 2019 8:19 am
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 :?:

Re: Any tests drawing text with GDIPLUS ?

Posted: Sat Sep 14, 2019 9:02 am
by cnavarro

Re: Any tests drawing text with GDIPLUS ?

Posted: Sat Sep 14, 2019 12:30 pm
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

Re: Any tests drawing text with GDIPLUS ?

Posted: Wed Sep 25, 2019 3:56 pm
by nageswaragunupudi
Please try this code

Code: Select all | Expand

  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

Re: Any tests drawing text with GDIPLUS ?

Posted: Thu Sep 26, 2019 8:35 am
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 :?:

Re: Any tests drawing text with GDIPLUS ?

Posted: Thu Sep 26, 2019 9:21 am
by AntoninoP
why do you continuously destroy and re-create the graphics?

Re: Any tests drawing text with GDIPLUS ?

Posted: Thu Sep 26, 2019 10:48 am
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

Re: Any tests drawing text with GDIPLUS ?

Posted: Mon Sep 30, 2019 1:29 pm
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: