Get RGBA from ColorRequester?
Get RGBA from ColorRequester?
Greetings to all,
in order to use VectorFont drawing, 32 bit color is required. However, ColorRequester() only returns 24 bit color. What is the procedure to add transparency to that value?
TIA!
Bruno
in order to use VectorFont drawing, 32 bit color is required. However, ColorRequester() only returns 24 bit color. What is the procedure to add transparency to that value?
TIA!
Bruno
Re: Get RGBA from ColorRequester?
Code: Select all
color24.l = RGB($11,$22,$33) ;11 22 33 00 \
color32.l = RGBA($11,$22,$33,$FF) ;11 22 33 FF / ShowMemory(@colorn,4)
Code: Select all
color32 = color24 | $FF000000 ;FF=opaque - 0=transparent
Re: Get RGBA from ColorRequester?
Thx for the tip, Keya, seems to be working great!Keya wrote:therefore:Code: Select all
color24.l = RGB($11,$22,$33) ;11 22 33 00 \ color32.l = RGBA($11,$22,$33,$FF) ;11 22 33 FF / ShowMemory(@colorn,4)
Code: Select all
color32 = color24 | $FF000000 ;FF=opaque - 0=transparent
BTW, why can't I load this particular font to Vector library? http://www.fontfabric.com/code-free-font-3/ Same thing is for Trajan Pro, Charlemagne Std and many other Windows fonts... Fonts get loaded properly but simply won't be printed at all.
Re: Get RGBA from ColorRequester?
It think that the Vector library maybe currently only supports ttf fonts and not otf fonts.bbanelli wrote:BTW, why can't I load this particular font to Vector library?
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Get RGBA from ColorRequester?
Perhaps. But that doesn't seem to be the case for mistral Regular, Lucida and some other OpenType work well.wilbert wrote:It think that the Vector library maybe currently only supports ttf fonts and not otf fonts.bbanelli wrote:BTW, why can't I load this particular font to Vector library?
Then I thought that maybe the fonts without "Designed for" (language) types cannot be displays. Isn't the case - no pattern there. Font embeddability makes no difference as well - some editable fonts won't display as well.
Can someone confirm that only TTF are supported? Though that would be really really bad... I appreciate any assistance of whatsoever!
With my best,
Bruno
Edit: after converting font to TTF with online converter, it seems to be working properly. Maybe this should be documented?
Re: Get RGBA from ColorRequester?
Yes I agree this needs clearing up. Exactly what type of fonts can we use with the vector lib? I tried the OT font as well and can confirm your results.
Best ask Fred / Freak for clarification I reckon.
Best ask Fred / Freak for clarification I reckon.
I may look like a mule, but I'm not a complete ass.
Re: Get RGBA from ColorRequester?
I have also noticed there is huge difference between drawing quality of VectorText and VectorParagraph functions. You can see examples here. Is this only me or it is a bug of a sort? Sam font, same settings, only difference is that left picture uses DrawVectorText() and right picture uses DrawVectorParagraph(). This seems to happen only on Windows, Linux version looks fine...
Edit: I've also discovered that CODE font (from the link I've posted above) works without a problem on Linux.
So, it it safe to conclude that VectorParagraph and inability to properly load some fonts should be reported as Windows vector library bugs?
Code: Select all
Enumeration
#ImageID
EndEnumeration
UsePNGImageDecoder()
UsePNGImageEncoder()
CreateImage(#ImageID, 640, 640)
If FontRequester("",0,0)
LoadFont(100,SelectedFontName(),SelectedFontSize(),SelectedFontStyle())
Else
End
EndIf
If StartVectorDrawing(ImageVectorOutput((#ImageID)))
VectorFont(FontID(100), SelectedFontSize())
VectorSourceColor(RGBA(255,255,255,255))
MovePathCursor(0, 0)
Text$ = "ABCDEFGH" + #CRLF$ + "IJKLMNOP" + #CRLF$ + "RSTUVZ" + #CRLF$ + "čćžšđČĆŽĐ"
DrawVectorText(Text$)
; DrawVectorParagraph(Text$, 640, 640, #PB_VectorParagraph_Left)
StopVectorDrawing()
SaveImage(#ImageID, "preview.png", #PB_ImagePlugin_PNG, #PB_Ignore, 32)
EndIf
So, it it safe to conclude that VectorParagraph and inability to properly load some fonts should be reported as Windows vector library bugs?
Re: Get RGBA from ColorRequester?
I can't see much difference with your images... but I can when I run your program. DrawVectorParagraph() seems sharper.
I may look like a mule, but I'm not a complete ass.
Re: Get RGBA from ColorRequester?
Zoom in and check the curves. It's like those with DrawVectorParagraph() are not anti-aliased or something...srod wrote:I can't see much difference with your images... but I can when I run your program. DrawVectorParagraph() seems sharper.
Re: Get RGBA from ColorRequester?
Got it yes.
I seem to recall similar issues with alpha blended text with the 2d drawing lib and am not sure that was ever fixed? Might be wrong though.
I seem to recall similar issues with alpha blended text with the 2d drawing lib and am not sure that was ever fixed? Might be wrong though.
I may look like a mule, but I'm not a complete ass.
Re: Get RGBA from ColorRequester?
DrawVectorParagraph() vs DrawVectorText(), Arial Bold 16 @ Win32, zoomed in. Interesting differences! They both beat DrawText() though
Re: Get RGBA from ColorRequester?
The text on the left looks suspiciously like Microsoft® ClearType technology.Keya wrote:DrawVectorParagraph() vs DrawVectorText(), Arial Bold 16 @ Win32, zoomed in. Interesting differences! They both beat DrawText() though
It might prove interesting to check for the differences in Linux, or turn off the functionality in Windows®.
Keep it BASIC.
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: Get RGBA from ColorRequester?
Yes, the colour being added looks like it is cleartype. Doesn't look good if printed as it adds colour to the edges of fonts.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
- Michael Vogel
- Addict
- Posts: 2680
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Get RGBA from ColorRequester?
Okay, drifting a little bit away from the topic - but I wouldn't say, windows is the (only) reason for the color effects above, Purebasic changed it's behaviour to draw text somewhen (I believe it was between version 4.31 and 4.61 or so). Before that, I did never see such issues.
Code: Select all
OpenWindow(0,0,0,480,200,"")
CreateImage(0,480,200,32)
LoadFont(0,"Arial",-60)
StartDrawing(ImageOutput(0))
Box(0,0,240,200,#White)
Title.s="Test Hanburg"
DrawingMode(#PB_2DDrawing_AlphaBlend); : (
;DrawingMode(#PB_2DDrawing_Default); : )
DrawingFont(FontID(0))
DrawText(20,10,Title,$ff000000,$ffffffff)
DrawText(20,100,Title,$ffffffff,$ff000000)
StopDrawing()
ImageGadget(0,0,0,0,0,ImageID(0))
HideWindow(0,0)
Repeat
Event=WaitWindowEvent()
If Event=#WM_LBUTTONDOWN
SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0)
EndIf
Until Event=#PB_Event_CloseWindow Or Event=#WM_CHAR
Re: Get RGBA from ColorRequester?
Good demo. What's up with the -60 point size?Michael Vogel wrote:Okay, drifting a little bit away from the topic - but I wouldn't say, windows is the (only) reason for the color effects above, Purebasic changed it's behaviour to draw text somewhen (I believe it was between version 4.31 and 4.61 or so). Before that, I did never see such issues.
Those color artifacts that you see are 100% the result of Microsoft® ClearType technology.
It's supposed to work best with a white background, but your demo indicates otherwise for larger sized fonts.
Turn off ClearType, and the produced bitmaps are all grayscale.
I'm quite sure that when I reboot to Linux and run your code, the produced bitmaps will be grayscale.
It looks as if the application can have control over the font rendering, whether ClearType is used or not.
"There are many examples where applications decide one way or another to use rendering other than the system default—just as applications that choose to use different fonts, colors, sizes, or other text attributes. The most typical example is in applications that wish to have reproducible layout and flow of documents. By being specific about which way to render text, the applications can be certain of how text will flow across different PCs. Another common example, as mentioned above, is Print Preview where the ability to properly render representations of higher resolution output, particularly for small text sizes, is much improved. We recognize that for some it is counter-intuitive that an aspect viewed as a “display” property is something that applications can choose to “over-ride”. We’ve designed rendering so that the default case is to respect the setting, but applications, including Windows itself, might have elements that require explicit rendering techniques.
Although each application can make the choice on a per-font basis of which rendering to use, the majority of applications choose the default rendering. Therefore, making the decision to change the default for Windows Vista was not taken lightly. The trends in the hardware displays were strongly showing a rapid movement from CRTs to LCD-based displays as we have shown in earlier blog posts based on the Windows XP and Windows Vista real-world telemetry. Even though there were still CRTs in use, feedback from Windows XP customers was positive on the quality of ClearType rendering on CRTs. After we made the choice, the feedback on the decision to enable ClearType as the default for Windows Vista was overwhelmingly positive."
A flag into LoadFont()? DrawText()?
Keep it BASIC.