Our batch image processing product, EyeBatch, has a neat text effect that will emboss the text onto an image. The following code demonstrates how to do this with ImgX Controls. Slight modifications need to be made when using ImgXASP and that code is also shown below.
Dim ImgX As ImgX
Dim ImgXEmboss As ImgX
Dim text As String
Dim OffsetX As Long
Dim OffsetY As Long
Dim EmOffset As Long
Dim EmAngle As Double
Dim EmSmoothness As Long
Dim ForeColor As Long
Dim BackColor As Long
Dim antialias As Double
Dim Opacity As Long
Dim HeightInPixels As Long
Dim i As Long
Dim h As Long
Dim w As Long
'set properties
text = "Atalasoft" 'text to draw
EmOffset = 5 'offset of the embossment
EmAngle = 0 'angle of the embossment
ForeColor = vbBlack 'color of the text
Opacity = 50 'the opacity of the shadow effect in percent
antialias = 0 'the amount of antialiasing to apply to the final text
HeightInPixels = 70 'the height of the text
EmSmoothness = 50 'the smoothness of the shadow effect in percent
'load the image to stamp the text on
Set ImgX = New ImgX
ImgX.Import.FromFile "24_rgb.jpg"
'set the emboss font properties
Set ImgXEmboss = New ImgX
ImgXEmboss.Draw.Font.HeightInPixels = HeightInPixels
ImgXEmboss.Draw.ForeColor.Color = ForeColor
ImgXEmboss.Draw.Font.Weight = ixfwBold
'ImgXEmboss.Draw.antialias = 10 'uncomment this to apply a border around the text. you'll want to resize the canvas larger
'calculate size of text
ImgXEmboss.Draw.CalcTextSize text, w, h
'create new transparent image and draw text onto it
ImgXEmboss.Import.FromNew w, h, ImgX.Support.Color(vbWhite, 0), ixitRGBWithAlphaChannel_32
ImgXEmboss.Draw.text 0, 0, text
'reverse alpha using a LUT
Dim Alpha(0 To 255) As Byte
For i = 0 To 255
Alpha(i) = 255 - i
Next i
ImgXEmboss.Channels.ReplaceAlpha Alpha
'calculate the drop shadow offsets
OffsetX = (EmOffset / 100 * HeightInPixels) * Cos(-EmAngle * 3.1415927 / 180)
OffsetY = (EmOffset / 100 * HeightInPixels) * Sin(-EmAngle * 3.1415927 / 180)
'add drop for the emboss
ImgXEmboss.Effects.DropShadow OffsetX, OffsetY, ImgX.Support.Color(ForeColor, Opacity / 100 * 255), EmSmoothness, False
'set the outside opaque part as fully transparent
For i = 0 To 254
Alpha(i) = i
Next i
Alpha(255) = 0
ImgXEmboss.Channels.ReplaceAlpha Alpha()
'Apply Antialias manually
If antialias > 0 Then ImgXEmboss.Filters.Blur antialias
'overlay the final emboss text image onto the bottom image
ImgX.Draw.ImageWithAlpha ImgXEmboss.Image, 50, 0
For ImgXASP, the code should look like the following:
Dim ImgX
Dim ImgXEmboss
Dim text
Dim OffsetX
Dim OffsetY
Dim EmOffset
Dim EmAngle
Dim EmSmoothness
Dim ForeColor
Dim BackColor
Dim antialias
Dim Opacity
Dim HeightInPixels
Dim i
Dim h
Dim w
'set properties
text = "Atalasoft" 'text to draw
EmOffset = 5 'offset of the embossment
EmAngle = 0 'angle of the embossment
ForeColor = vbBlack 'color of the text
Opacity = 50 'the opacity of the shadow effect in percent
antialias = 0 'the amount of antialiasing to apply to the final text
HeightInPixels = 70 'the height of the text
EmSmoothness = 50 'the smoothness of the shadow effect in percent
'load the image to stamp the text on
Set ImgX = Server.CreateObject("ImgXASP6.ImgX")
ImgX.Import.FromFile Server.MapPath("24_rgb.jpg")
'set the emboss font properties
Set ImgXEmboss = Server.CreateObject("ImgXASP6.ImgX")
ImgXEmboss.Draw.Font.HeightInPixels = HeightInPixels
ImgXEmboss.Draw.ForeColor = ForeColor
ImgXEmboss.Draw.Font.Weight = ixfwBold
'ImgXEmboss.Draw.antialias = 10 'uncomment this to apply a border around the text. you'll want to resize the canvas larger
'calculate size of text
ImgXEmboss.Draw.CalcTextSize text, w, h
'create new transparent image and draw text onto it
ImgXEmboss.Import.FromNew w, h, vbWhite, ixitRGBWithAlphaChannel_32, 0
ImgXEmboss.Draw.text 0, 0, text
'reverse alpha using a LUT
Dim Alpha(255)
For i = 0 To 255
Alpha(i) = 255 - i
Next
ImgXEmboss.Channels.ReplaceAlpha ImgX.Support.GetByteArrayFromVariant(Alpha, 1)
'calculate the drop shadow offsets
OffsetX = (EmOffset / 100 * HeightInPixels) * Cos(-EmAngle * 3.1415927 / 180)
OffsetY = (EmOffset / 100 * HeightInPixels) * Sin(-EmAngle * 3.1415927 / 180)
'add drop for the emboss
ImgXEmboss.Effects.DropShadow OffsetX, OffsetY, ForeColor, Opacity / 100 * 255, EmSmoothness, False
'set the outside opaque part as fully transparent
For i = 0 To 254
Alpha(i) = i
Next
Alpha(255) = 0
ImgXEmboss.Channels.ReplaceAlpha ImgX.Support.GetByteArrayFromVariant(Alpha, 1)
'Apply Antialias manually
If antialias > 0 Then ImgXEmboss.Filters.Blur antialias
'overlay the final emboss text image onto the bottom image
ImgX.Draw.ImageWithAlpha ImgXEmboss.Image, 50, 0
Set ImgXEmboss = Nothing
Response.ContentType = "image/jpeg"
Response.BinaryWrite ImgX.Export.ToMemoryFile(1) '1 = ixmfJPG
Set ImgX = Nothing