Any tests drawing text with GDIPLUS ?

Any tests drawing text with GDIPLUS ?

Postby ukoenig » Sat Sep 14, 2019 8: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 :?:
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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Any tests drawing text with GDIPLUS ?

Postby cnavarro » Sat Sep 14, 2019 9: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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Any tests drawing text with GDIPLUS ?

Postby ukoenig » Sat Sep 14, 2019 12:30 pm

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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Any tests drawing text with GDIPLUS ?

Postby nageswaragunupudi » Wed Sep 25, 2019 3:56 pm

Please try this code
Code: Select all  Expand view
  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
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Any tests drawing text with GDIPLUS ?

Postby ukoenig » Thu Sep 26, 2019 8: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 )


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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Any tests drawing text with GDIPLUS ?

Postby AntoninoP » Thu Sep 26, 2019 9:21 am

why do you continuously destroy and re-create the graphics?
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Any tests drawing text with GDIPLUS ?

Postby ukoenig » 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 :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: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Any tests drawing text with GDIPLUS ?

Postby ukoenig » Mon Sep 30, 2019 1: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 ) :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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 78 guests