I have coded tBlurText overriding "Paint" as below: Still I can see the blurred image clipped...
Any help tweaking the code so that the blur image is completely within the text's bounds. The code is in VB.NET ----------------------------------------------------------------------------- Imports System.Text Imports System.IO Imports System.Drawing.Text Imports System.Drawing.Drawing2D Imports UMD.HCIL.Piccolo Imports UMD.HCIL.Piccolo.Util Imports UMD.HCIL.Piccolo.Nodes Imports UMD.HCIL.Piccolo.Event Imports UMD.HCIL.Piccolo.Activities Imports UMD.HCIL.PiccoloX Imports UMD.HCIL.PiccoloX.Nodes Imports UMD.HCIL.PiccoloX.Events Imports UMD.HCIL.PiccoloX.Util Imports UMD.HCIL.PiccoloX.Handles Imports Microsoft.VisualBasic.FileIO Public Class tBlur Inherits PForm Public Sub New() Dim tT As New tBlurText("My Text to be blurred!") Canvas.Layer.AddChild(tT) End Sub End Class Public Class tBlurText Inherits PText Private Shared grphcs As Graphics = Graphics.FromImage(New Bitmap(1, 1)) Public Sub New() MyBase.New() End Sub Public Sub New(ByVal aText As String) MyBase.New(aText) End Sub Public Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) MyBase.New(info, context) End Sub Protected Overrides Sub Paint(ByVal paintContext As UMD.HCIL.Piccolo.Util.PPaintContext) Dim g As Graphics = paintContext.Graphics If Me.Brush IsNot Nothing Then g.FillRectangle(Me.Brush, Me.Bounds) End If If ((Me.Text IsNot Nothing) And (Me.TextBrush IsNot Nothing) And (Me.Font IsNot Nothing)) Then Dim renderedFontSize As Single = Me.Font.SizeInPoints * paintContext.Scale If (renderedFontSize < PUtil.GreekThreshold) Then g.FillRectangle(Me.TextBrush, Me.Bounds) ElseIf (renderedFontSize < PUtil.MaxFontSize) Then Dim renderFont As Font = Me.Font If (g.DpiY <> grphcs.DpiY) Then Dim fPrintedFontRatio As Single = grphcs.DpiY / 100 renderFont = New Font(Me.Font.Name, Me.Font.Size * fPrintedFontRatio, Me.Font.Style, Me.Font.Unit) End If 'g.DrawString(Me.Text, renderFont, Me.TextBrush, Me.Bounds, StringFormat.GenericTypographic) '********************************************************* Dim k As Integer = 4 Dim dRect As Rectangle = New Rectangle(Me.X, Me.Y, Me.Width, Me.Height) Dim bw, bh As Integer bw = CInt(Me.Bounds.Width / k) If bw < 1 Then bw = 1 End If bh = CInt(Me.Bounds.Height / k) If bh < 1 Then bh = 1 End If Dim bm As Bitmap = New Bitmap(bw, bh) Dim g1 As Graphics = Graphics.FromImage(bm) g1.TextRenderingHint = TextRenderingHint.AntiAlias Dim mx As Matrix = New Matrix(CDbl(1 / k), 0, 0, CDbl(1 / k), 0, 0) g1.Transform = mx 'g1.DrawString(Me.Text, renderFont, Me.TextBrush, Me.Bounds, StringFormat.GenericTypographic) g1.DrawString(Me.Text, renderFont, Me.TextBrush, Me.Bounds, StringFormat.GenericTypographic) g1.Dispose() 'The destination Graphics uses a high quality mode g.InterpolationMode = InterpolationMode.HighQualityBicubic 'and draws antialiased text for accurate fitting g.TextRenderingHint = TextRenderingHint.AntiAlias 'The small image is blown up to fill the main client rectangle g.DrawImage(bm, dRect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel) 'g.DrawImage(bm, dRect, 0, 0, Me.Width, Me.Height, GraphicsUnit.Pixel) 'finally, the text is drawn on top for Text Glow effect 'g.DrawString(Me.Text, renderFont, Me.TextBrush, Me.Bounds, StringFormat.GenericTypographic) bm.Dispose() '********************************************************* End If End If End Sub End Class --~--~---------~--~----~------------~-------~--~----~ Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en -~----------~----~----~----~------~----~------~--~---