在RDLC报告中反转或翻转文本

时间:2011-06-09 22:15:28

标签: fonts rdlc invert

好的,我已经学到了更多,并重新提出了我的问题。我需要在RDLC报告上翻转或反转180度的文本(因此它看起来是倒置的)。我有一些自定义的VB代码,它接受文本,将其转换为位图,然后将画布旋转180度旋转。这样的效果使文本看起来有点......抖动......或模糊。它不再是一个尖锐的字体了。我遇到的问题是我使用的是特殊的TTF条形码字体,可以创建扫描仪可以读取的内容。当我翻转条形码字体时,由于条形码线非常靠近并且扫描仪无法读取它,因此模糊性不好。这是代码:

Function LoadImage(ByVal sImageText as String, iRotationAngle as Integer, ByVal sFontName as String, iFontSize as Integer)
Dim bmpImage As New Drawing.Bitmap(1, 1)
Dim iWidth As Integer = 0
Dim iHeight As Integer = 0

'// Create the Font object for the image text drawing.
Dim MyFont As New Drawing.Font(sFontName, iFontSize)  ', System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point)

'// Create a graphics object to measure the text's width and height.
Dim MyGraphics As Drawing.Graphics = Drawing.Graphics.FromImage(bmpImage)

'// This is where the bitmap size is determined.
iWidth = MyGraphics.MeasureString(sImageText, MyFont).Width
iHeight = MyGraphics.MeasureString(sImageText, MyFont).Height

'// Create the bmpImage again with the correct size for the text and font.
bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iWidth, iHeight))

'// Add the colors to the new bitmap.
MyGraphics = Drawing.Graphics.FromImage(bmpImage)
MyGraphics.Clear(Drawing.Color.White)
MyGraphics.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
MyGraphics.TranslateTransform(iWidth,iHeight)
MyGraphics.RotateTransform(iRotationAngle)
MyGraphics.DrawString(sImageText, MyFont, New Drawing.SolidBrush(Drawing.Color.Black), 0, 0)
MyGraphics.Flush()

Dim stream As IO.MemoryStream = New IO.MemoryStream
Dim bitmapBytes As Byte()

'Create bitmap 
bmpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp)
bitmapBytes = stream.ToArray
stream.Close()
bmpImage.Dispose()

Return bitmapBytes

End Function

我真的不知道为什么没有内置的方式来翻转文本。它会让我从左到右颠倒它。可笑了。

由于

0 个答案:

没有答案