旋轉圖像,我使用,我的使用下面的代碼轉換成條碼圖像,該代碼是從here採取SQL建設SSRS的報告。我不是VB.Net
開發者,但是這段代碼對我來說非常合適。 問題是我的報告佈局是垂直條形碼圖像而不是水平的,而且我沒有看到任何可以旋轉圖像OOB的選項。任何人都可以幫助我在這裏使用下面的代碼旋轉圖像。如何在SSRS
Public Shared Function GenerateImage(ByVal fontName As String, ByVal stringText As String) As Byte()
Dim oGraphics As System.Drawing.Graphics
Dim barcodeSize As System.Drawing.SizeF
Dim ms As System.IO.MemoryStream
Dim i As System.Drawing.Image
Using font As New System.Drawing.Font(New System.Drawing.FontFamily(fontName), 36)
Using tmpBitmap As New System.Drawing.Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
oGraphics = System.Drawing.Graphics.FromImage(tmpBitmap)
oGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
barcodeSize = oGraphics.MeasureString(stringText, font)
oGraphics.Dispose()
End Using
Using newBitmap As New System.Drawing.Bitmap(barcodeSize.Width, barcodeSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
oGraphics = System.Drawing.Graphics.FromImage(newBitmap)
oGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
Using oSolidBrushWhite As New System.Drawing.SolidBrush(System.Drawing.Color.White)
Using oSolidBrushBlack As New System.Drawing.SolidBrush(System.Drawing.Color.Black)
oGraphics.FillRectangle(oSolidBrushWhite, New System.Drawing.Rectangle(0, 0, barcodeSize.Width, barcodeSize.Height))
oGraphics.DrawString(stringText, font, oSolidBrushBlack, 0, 0)
End Using
End Using
ms = New System.IO.MemoryStream()
newBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
End Using
End Using
Return ms.ToArray()
End Function
我絕對是VB.Net中的NOOB。
你可能只需要'bmp.RotateFlip(RotateFlipType.Rotate270FlipNone)'或類似取決於哪個方向翻轉。 – Plutonix
@Plutonix - [似乎爲我工作(http://i.stack.imgur.com/rAtUp.png) –
更改示例項目是在加入'newBitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone)'在'newBitmap.Save(ms,System.Drawing.Imaging.ImageFormat.Png)'之前,並在報告中將ImageProperties設置爲「原始大小」而非「剪輯」。 –