Options

How to rotate an image in a report

Hi everybody,
I need to rotate an image, in my case is a barcode.
I tried to create the following function in Custom Code section into the report:
Public Sub RotateFlip (
rotateFlipType As System.Drawing.RotateFlipType
)
End Sub

Dim PictureBox As System.Windows.Forms.PictureBox

Public Function RotateImage(ByVal Barcode As System.Drawing.Bitmap)
If Barcode IsNot Nothing Then
Barcode.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipY)
End If
End Function
But it doesn't work.

Best Answer

  • Options
    archer89archer89 Member Posts: 337
    Answer ✓
    assign the barcode image to the picturebox
    add line: PictureBox1.Image = barcode;
    under line: Barcode.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipY)

    PictureBox1 should be an image control in the report.
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/

Answers

  • Options
    archer89archer89 Member Posts: 337
    Answer ✓
    assign the barcode image to the picturebox
    add line: PictureBox1.Image = barcode;
    under line: Barcode.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipY)

    PictureBox1 should be an image control in the report.
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
  • Options
    internship01internship01 Member Posts: 6
    Thanks archer89, I added the line you told me.
    Since I have two barcodes, I added also a pictureBox parameter to the function as you can see below:
    Public Sub RotateFlip (
    rotateFlipType As System.Drawing.RotateFlipType
    )
    End Sub

    Public Function RotateImage(ByVal Barcode As System.Drawing.Bitmap,ByVal PictureBox As System.Windows.Forms.PictureBox)
    If Barcode IsNot Nothing Then
    Barcode.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone)
    PictureBox.Image = Barcode
    End If
    End Function

    Then I call then function in the expression of the image in the following way:

    =Code.RotateImage(Fields!gItem__Blob.Value,ReportItems!Item_BarCode2.Value)

    Where "Item_BarCode2" is the name of the PictureBox into the report's layout.
    But it still appears a red X instead of my rotated barcode.

    Do you know where is the problem?

    Thanks again
    Regards
Sign In or Register to comment.