Hello!
Just styling some things and I have still the annoying DrawVectorText which draw text not as "clear" as windows does.
In the forum it is said, graphical text cannot be like windows text.
So, only solution is to copy pixels from a text gadget and fill it in a canvas???
Any other idea to let text not be shown like on a 30 year old screen?
Is there a way to catchImage from a window native gadget?
Thanks a lot!
DrawVectorText; catch image from textgadget;
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: DrawVectorText; catch image from textgadget;
Should do for a textgadget:
Code: Select all
Global SnapShot_Active = 0
Procedure WinCallBack(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLORSTATIC
If SnapShot_Active And lparam = GadgetID(0)
SnapShot_Active = 0
hDC_src = wparam
CreateImage(0, GadgetWidth(0), GadgetHeight(0), 24)
hDC_dst = StartDrawing(ImageOutput(0))
BitBlt_(hDC_dst,0,0,ImageWidth(0),ImageHeight(0),hDC_src,0,0,#SRCCOPY)
StopDrawing()
ImageGadget(2,10,50,0,0,ImageID(0))
EndIf
EndSelect
ProcedureReturn result
EndProcedure
Procedure Button_1_Methods()
SnapShot_Active = 1
InvalidateRect_(GadgetID(0),0,1)
EndProcedure
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
SetWindowCallback(@WinCallBack())
LoadFont(0, "Arial", 12, #PB_Font_Bold|#PB_Font_Italic)
TextGadget(0, 10,10,200,25,"Hello World!")
SetGadgetColor(0, #PB_Gadget_FrontColor, #Blue)
SetGadgetFont(0, FontID(0))
ButtonGadget(1, 10,210,300,20,"Take picture of text gadget now...")
BindGadgetEvent(1,@Button_1_Methods())
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
BERESHEIT
Re: DrawVectorText; catch image from textgadget;
Try the DrawText_() API function for better text, see my example here:
http://www.purebasic.fr/english/viewtop ... 85#p474574
http://www.purebasic.fr/english/viewtop ... 85#p474574
Re: DrawVectorText; catch image from textgadget;
Hi HanPBF
Can you post some code ?
I did not see any difference
Next snippet you can play with a special created font of yours
PB 5.42 x86 Windows 10 x64
http://www.purebasic.fr/english/viewtop ... 27&t=62077
Can you post some code ?
I did not see any difference
Next snippet you can play with a special created font of yours
PB 5.42 x86 Windows 10 x64
http://www.purebasic.fr/english/viewtop ... 27&t=62077
Code: Select all
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")
LoadFont(0, "Arial", 32,#PB_Font_Bold)
Fnt.LOGFONT
Fnt\lfHeight = 72
Fnt\lfWeight = 700
Fnt\lfCharSet = #DEFAULT_CHARSET
Fnt\lfOutPrecision = #OUT_STROKE_PRECIS
Fnt\lfClipPrecision = #CLIP_STROKE_PRECIS
Fnt\lfQuality = #NONANTIALIASED_QUALITY
Fnt\lfPitchAndFamily = #DEFAULT_PITCH | #FF_DONTCARE
PokeS(@Fnt\lfFaceName[0], "Arial")
Clearfont = CreateFontIndirect_(Fnt)
If StartVectorDrawing(CanvasVectorOutput(0))
VectorFont(FontID(0), 32)
VectorSourceColor($FF2F33FF)
Text$ = "The quick brown fox jumped"
MovePathCursor(200 - VectorTextWidth(Text$)/2, 10 - VectorTextHeight(Text$)/2)
DrawVectorImage(ImageID(0), 255,400,200)
MovePathCursor(200 - VectorTextWidth(Text$)/2, 50 - VectorTextHeight(Text$)/2)
DrawVectorText(Text$)
VectorFont(Clearfont, 32)
MovePathCursor(200 - VectorTextWidth(Text$)/2, 100 - VectorTextHeight(Text$)/2)
DrawVectorText(Text$)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Egypt my love
Re: DrawVectorText; catch image from textgadget;
Thanks for all the help.
Hello RASHAD!
Maybe because I am using still 5.41.
Hello RASHAD!
Maybe because I am using still 5.41.
Re: DrawVectorText; catch image from textgadget;
got my project at office site running under PB 5.50.
Idea is to "overdraw" some gadgets with Your tips.
Thanks a lot !
Idea is to "overdraw" some gadgets with Your tips.
Thanks a lot !
Re: DrawVectorText; catch image from textgadget;
Hello RASHAD,
I've checked Your example and changed it a little:
Hopefully, even depending on OS, You should see a different rendering of all text lines; while the rendering of text gadget is the clearest from all.
Even the third line of "The quick brown fox" is bold, You shall see missing antialiasing.
Even setting #ANTIALIASED_QUALITY did not change result.
Effect can not be seen for bigger fonts.
I've checked Your example and changed it a little:
Code: Select all
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
textgadget(1, 0, 0, 400, 32, "The quick brown fox")
CanvasGadget(0, 0, 30, 400, 200)
LoadFont(0, "Arial", 12)
setgadgetcolor(1,#PB_Gadget_BackColor,#White)
SetGadgetFont(1, fontid(0))
Fnt.LOGFONT
Fnt\lfHeight = 18
Fnt\lfWeight = 700
Fnt\lfCharSet = #DEFAULT_CHARSET
Fnt\lfOutPrecision = #OUT_STROKE_PRECIS
Fnt\lfClipPrecision = #CLIP_STROKE_PRECIS
Fnt\lfQuality = #NONANTIALIASED_QUALITY
Fnt\lfPitchAndFamily = #DEFAULT_PITCH | #FF_DONTCARE
PokeS(@Fnt\lfFaceName[0], "Arial")
Clearfont = CreateFontIndirect_(Fnt)
If StartVectorDrawing(CanvasVectorOutput(0))
VectorFont(FontID(0))
VectorSourceColor(RGBA(0,0,0,255))
Text$ = "The quick brown fox"
MovePathCursor(200 - VectorTextWidth(Text$)/2, 10 - VectorTextHeight(Text$)/2)
MovePathCursor(200 - VectorTextWidth(Text$)/2, 50 - VectorTextHeight(Text$)/2)
DrawVectorText(Text$)
VectorFont(Clearfont)
MovePathCursor(200 - VectorTextWidth(Text$)/2, 100 - VectorTextHeight(Text$)/2)
DrawVectorText(Text$)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Even the third line of "The quick brown fox" is bold, You shall see missing antialiasing.
Even setting #ANTIALIASED_QUALITY did not change result.
Effect can not be seen for bigger fonts.