473,699 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GDI Drawing Text with outline and shadow

Lou
I need to have a Face,Outline and drop shadow. I am close but can't get my
code to work.
The face and outline work fine but the shadow is not sized correctly???

Dim rec As New Rectangle(Pictu reBox1.Left, PictureBox1.Top ,
PictureBox1.Hei ght, PictureBox1.Hei ght)

Try

'Set the Font

Dim myFont As New Font("Arial", Me.nudFontSize. Value, FontStyle.Regul ar)

'Set the Graphics Buffer

Dim bm As New Bitmap(Me.Clien tSize.Width \ 4, Me.ClientSize.H eight \ 4)

'==== DROP SHADOW =============== =====

Dim g As Graphics = g.FromImage(bm)

g.TextRendering Hint = TextRenderingHi nt.AntiAlias

Dim mx As New Matrix(0.25F, 0, 0, 0.25F, 1, 1)

g.Transform = mx

g.DrawString(tx tShortText.Text , myFont, New SolidBrush(Colo r.FromArgb(128,
Color.Black)), 10, 10, StringFormat.Ge nericTypographi c)

'Clean up

g.Dispose()

e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic

e.Graphics.Text RenderingHint = TextRenderingHi nt.AntiAlias

e.Graphics.Draw Image(bm, Me.ClientRectan gle, 0, 0, bm.Width, bm.Height,
GraphicsUnit.Pi xel)

''==== EDGE/FACE =============== ===========

Dim pth As New GraphicsPath

e.Graphics.Text RenderingHint = TextRenderingHi nt.AntiAlias

e.Graphics.Smoo thingMode = SmoothingMode.A ntiAlias

pth.AddString(t xtShortText.Tex t, myFont.FontFami ly, 0, (myFont.Size), New
Point(10, 10), StringFormat.Ge nericTypographi c)

'pen size is the size of the edge

Dim P As New Pen(Color.Black , 1)

'Draw the face

e.Graphics.Fill Path(Brushes.Wh ite, pth)

'Draw the edge

e.Graphics.Draw Path(P, pth)

pth.Dispose()

'Clean(up)

bm.Dispose()

Catch MyError As Exception

MessageBox.Show (MyError.Messag e)

Finally

End Try
Nov 20 '05 #1
2 13953


Hi,

This code makes the shadow draw 1/4 size. Adjust the size here.
Dim mx As New Matrix(0.25F, 0, 0, 0.25F, 1, 1)

g.Transform = mx
Ken
----------------

"Lou" <lo********@com cast.net> wrote in message
news:jf******** ************@co mcast.com: I need to have a Face,Outline and drop shadow. I am close but can't get my

code to work.
The face and outline work fine but the shadow is not sized correctly???

Dim rec As New Rectangle(Pictu reBox1.Left, PictureBox1.Top ,
PictureBox1.Hei ght, PictureBox1.Hei ght)

Try

'Set the Font

Dim myFont As New Font("Arial", Me.nudFontSize. Value, FontStyle.Regul ar)

'Set the Graphics Buffer

Dim bm As New Bitmap(Me.Clien tSize.Width \ 4, Me.ClientSize.H eight \ 4)

'==== DROP SHADOW =============== =====

Dim g As Graphics = g.FromImage(bm)

g.TextRendering Hint = TextRenderingHi nt.AntiAlias

Dim mx As New Matrix(0.25F, 0, 0, 0.25F, 1, 1)

g.Transform = mx

g.DrawString(tx tShortText.Text , myFont, New SolidBrush(Colo r.FromArgb(128,

Color.Black)), 10, 10, StringFormat.Ge nericTypographi c)

'Clean up

g.Dispose()

e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic

e.Graphics.Text RenderingHint = TextRenderingHi nt.AntiAlias

e.Graphics.Draw Image(bm, Me.ClientRectan gle, 0, 0, bm.Width, bm.Height,
GraphicsUnit.Pi xel)

''==== EDGE/FACE =============== ===========

Dim pth As New GraphicsPath

e.Graphics.Text RenderingHint = TextRenderingHi nt.AntiAlias

e.Graphics.Smoo thingMode = SmoothingMode.A ntiAlias

pth.AddString(t xtShortText.Tex t, myFont.FontFami ly, 0, (myFont.Size), New

Point(10, 10), StringFormat.Ge nericTypographi c)

'pen size is the size of the edge

Dim P As New Pen(Color.Black , 1)

'Draw the face

e.Graphics.Fill Path(Brushes.Wh ite, pth)

'Draw the edge

e.Graphics.Draw Path(P, pth)

pth.Dispose()

'Clean(up)

bm.Dispose()

Catch MyError As Exception

MessageBox.Show (MyError.Messag e)

Finally

End Try


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004
Nov 20 '05 #2
u need to drawstring again but change ur location and some colour too

Lou wrote:
I need to have a Face,Outline and drop shadow. I am close but can't get my
code to work.
The face and outline work fine but the shadow is not sized correctly???

Dim rec As New Rectangle(Pictu reBox1.Left, PictureBox1.Top ,
PictureBox1.Hei ght, PictureBox1.Hei ght)

Try

'Set the Font

Dim myFont As New Font("Arial", Me.nudFontSize. Value, FontStyle.Regul ar)

'Set the Graphics Buffer

Dim bm As New Bitmap(Me.Clien tSize.Width \ 4, Me.ClientSize.H eight \ 4)

'==== DROP SHADOW =============== =====

Dim g As Graphics = g.FromImage(bm)

g.TextRendering Hint = TextRenderingHi nt.AntiAlias

Dim mx As New Matrix(0.25F, 0, 0, 0.25F, 1, 1)

g.Transform = mx

g.DrawString(tx tShortText.Text , myFont, New SolidBrush(Colo r.FromArgb(128,
Color.Black)), 10, 10, StringFormat.Ge nericTypographi c)

'Clean up

g.Dispose()

e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic

e.Graphics.Text RenderingHint = TextRenderingHi nt.AntiAlias

e.Graphics.Draw Image(bm, Me.ClientRectan gle, 0, 0, bm.Width, bm.Height,
GraphicsUnit.Pi xel)

''==== EDGE/FACE =============== ===========

Dim pth As New GraphicsPath

e.Graphics.Text RenderingHint = TextRenderingHi nt.AntiAlias

e.Graphics.Smoo thingMode = SmoothingMode.A ntiAlias

pth.AddString(t xtShortText.Tex t, myFont.FontFami ly, 0, (myFont.Size), New
Point(10, 10), StringFormat.Ge nericTypographi c)

'pen size is the size of the edge

Dim P As New Pen(Color.Black , 1)

'Draw the face

e.Graphics.Fill Path(Brushes.Wh ite, pth)

'Draw the edge

e.Graphics.Draw Path(P, pth)

pth.Dispose()

'Clean(up)

bm.Dispose()

Catch MyError As Exception

MessageBox.Show (MyError.Messag e)

Finally

End Try


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
33820
by: Chris Bradbury | last post by:
Hi, I'm posting in this forum for the first time so if I break any conventions or protocols I'm sorry. I've attached this style: *:focus { outline: none } to a page but it doesn't remove the dotted lines (surrounding links that
0
2796
by: Ron Adam | last post by:
I want to be able to easily create reusable shapes in Tkinter and be able to use them in mid level dialogs. So after some experimenting I've managed to get something to work. The following does pretty much what I need, but I think it can be improved on. So could anyone take a look and let me know what you think? Some of the things I want to add, but aren't exactly sure how at this time: Nested groups Use tags to be able to change sub...
0
1214
by: Craig | last post by:
hello, I am drawing an image on a Control which has a shadow to it using the DrawImage method (taking the image and x,y co ords) when I place that control on my form the shadow is somewhat distorted and I cannot see the image as I would see it, if it was placed in a pictureBox
1
2501
by: Gary Brizard | last post by:
Any ideas on creating a shadow text control. I created one using the graphic object, but I need something that will allow vertical text alignment in addition to horizonal. Thanks,
6
1985
by: Johnny Holland | last post by:
Hi, I am working on a presentation tool (Powerpoint like) that allows the user to display text over a picture background. One of the best ways to make the text stand out would be to put a black outline around the text if it is white (or white outline if black). I have been looking at the DrawString method but it seems to just allow me to put some text behind other text creating a shadow effect which is not what I want. Anyone got any...
1
3531
by: nick.spacek | last post by:
Hi everyone, I'm wondering if it's possible to add outlining or shadow to text in a RichTextBox? On www.bobpowell.net he has some tutorials on how to do so using GDI+, which I realize isn't available for RTBs. Is there a way to reproduce the RTB control using GDI+ instead of GDI? Or are there any other ways to go about this? Thanks for reading/suggestions! Nick Spacek
2
3076
by: Przemek | last post by:
Hi, I'm trying to parse some text file, which contain blocks of text. First my code: Public Class Parser Public Sub New(ByVal fs As String) Dim sr As StreamReader sr = My.Computer.FileSystem.OpenTextFileReader(fs) Dim strLine As String Dim outLine As String Dim lineCount As Short
5
2275
by: avlee | last post by:
Hello i have a code: /* some code creating picture */ header("Content-type: image/jpeg"); imagepng($new); it draws my picture correctly. But what to do when i want to draw a picture on my page - with other text
4
2705
by: marfola | last post by:
I'm trying to implement bottom-to-top vertical text using CSS attributes in IE : writing-mode: tb-rl; filter: flipv fliph; But I have encountered the following: the text is displayed with a grey shadow (instead of anti-alias). It seems that the problem is caused by the "filter:flip" attribute. Does anyone have a work around? (If I write the same text without the "filter" attribute, the grey shadow disappears but my text...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.