473,847 Members | 1,460 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 13971


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
33842
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
2804
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
1223
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
2514
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
1994
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
3550
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
3083
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
2296
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
2728
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
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10995
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9493
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...
1
7888
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7061
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();...
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4130
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3168
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.