Shadow Text Maker

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
21 posts Page 1 of 3
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Shadow Text Maker
CodenStuff
Hello,

Its cold and snowing outside so while im inside keeping warm I decided to catch up on some overdue tutorials that people have been asking me to do for them. So here is a strange little application that turns your text into a nice image.

First start a new project and add the following controls to your main form:

PictureBox
4 Buttons
TextBox
ColorDialog
FontDialog


Now place the controls on your form however you like them and just to give you an idea of what the controls do heres a screenshot from the attached source-code:
sshot-6.png
OK once you have done your controls we need to get the code done so first enter these imports:
Code: Select all
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Drawing.Text
Imports System.Drawing.Drawing2D
Then below "Public Class Form.." add this code:
Code: Select all
 Inherits System.Windows.Forms.Form
    Private ConvertedTextImage As Bitmap
    Private Const ShadowIntense As Integer = 6
    Dim TextColor = Color.Blue, ShadowColor = Color.Gray
    Dim TextFont As New Font("Arial", 20, FontStyle.Bold)
    Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        PictureBox1.Image = ConvertedTextImage
        MyBase.OnPaint(e)
    End Sub
We are going to use Button1 to change the color of our text so in the "Click_event" add this code:
Code: Select all
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextColor = ColorDialog1.Color
         End If
and we are going to use Button2 to change the color of our texts shadow so in the "Click_event" add this code:
Code: Select all
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            ShadowColor = ColorDialog1.Color
         End If
Button3 will be used to change our texts font so again in the "Click_event" add this code:
Code: Select all
 If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextFont = FontDialog1.Font
        End If
now we use Button4 to generate our image from our text so add this code in its "Click_event":
Code: Select all
ConvertedTextImage = DirectCast(TextToShadowImage(TextBox1.Text, TextFont, TextColor, ShadowColor), Bitmap)
Finally we need our actual function that will turn our plain text into an image so add this code block just above "End Class":
Code: Select all
Public Shared Function TextToShadowImage(ByVal InText As String, ByVal TextFontStyle As Font, ByVal TColor As Color, ByVal SColor As Color) As Image
        Dim ShadowTextOutput As Bitmap = Nothing
        Using g As Graphics = Graphics.FromHwnd(IntPtr.Zero)
            Dim STSize As SizeF = g.MeasureString(InText, TextFontStyle)
            Using bmp As New Bitmap(CInt(STSize.Width), CInt(STSize.Height))
                Using gBmp As Graphics = Graphics.FromImage(bmp)
                    Using BrushBackground As New SolidBrush(Color.FromArgb(16, SColor.R, SColor.G, SColor.B))
                        Using BrushForground As New SolidBrush(TColor)
                            gBmp.SmoothingMode = SmoothingMode.HighQuality
                            gBmp.InterpolationMode = InterpolationMode.HighQualityBilinear
                            gBmp.TextRenderingHint = TextRenderingHint.AntiAliasGridFit
                            gBmp.DrawString(InText, TextFontStyle, BrushBackground, 0, 0)
                            ShadowTextOutput = New Bitmap(bmp.Width + ShadowIntense, bmp.Height + ShadowIntense)
                            Using gBmpOut As Graphics = Graphics.FromImage(ShadowTextOutput)
                                gBmpOut.SmoothingMode = SmoothingMode.HighQuality
                                gBmpOut.InterpolationMode = InterpolationMode.HighQualityBilinear
                                gBmpOut.TextRenderingHint = TextRenderingHint.AntiAliasGridFit
                                For x As Integer = 0 To ShadowIntense
                                    For y As Integer = 0 To ShadowIntense
                                        gBmpOut.DrawImageUnscaled(bmp, x, y)
                                    Next
                                Next
                                gBmpOut.DrawString(InText, TextFontStyle, BrushForground, ShadowIntense / 2, ShadowIntense / 2)
                            End Using
                        End Using
                    End Using
                End Using
            End Using
        End Using
        Return ShadowTextOutput
    End Function
Save build and run the application and you should now have a working shadow text maker.

Download Source-Code:
NiceTexteff.zip
Happy coding! cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Shadow Text Maker
hungryhounduk
Hi Codenstuff
Nice cooll; wahooo;

You always seem to amaze me with these Great apps cooll;

Chris
Image
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Shadow Text Maker
Lewis
Love this :D Also im going to combine this with a button express clone i made :P
Image
User avatar
Miutubevids
VIP-Member
VIP-Member
Posts: 293
Joined: Mon Nov 23, 2009 11:39 am

Re: Shadow Text Maker
Miutubevids
Great Job But it Seems More of an Outline
Don't BS the BSer

RePlay V1.0 - Record your Mouse Clicks, Mouse Movments and Keystrokes
AutoClicker v1.0
SnowScreen
Reaction Timer Game V1.0
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Shadow Text Maker
Dummy1912
Great app codenstuff

but so sad its not working with me.
nothing happens.

any idea?

Dummy1912
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Skillful
Skillful Coders
Skillful Coders
Posts: 969
Joined: Tue Nov 16, 2010 10:07 am

Re: Shadow Text Maker
Skillful
Great tutorial Craig!! I'll use this in my Text Editor.
Instead of LOL use this -
LSIBMHBIWFETALOL

Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Shadow Text Maker
M1z23R
When i change the text nothing happens :/ When i click create button, also nothing happens :/
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Shadow Text Maker
M1z23R
I think if it stats working for me i can rewrite your code into creating captcha-s :)
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Shadow Text Maker
MrAksel
Its not hard to create captchas, tommorrow ill post my generator. It would be alot different than others.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

Re: Shadow Text Maker
code it
:D Great great great job!!!!!!!!!!!! cooll; cooll; cooll; cooll; cooll; cooll;
21 posts Page 1 of 3
Return to “Tutorials”