Posted 26 October 2023, 4:04 am EST
I recently converted from AR12 to AR17. Things are finally working (after many challenges), but I have a problem having images come up in a report. The images are stored in a DB and set at runtime.
When previewed with the viewer I get the following error. The error is trapped by the viewer and not by the error trap in the code.
Exception details:
System.OverflowException: Overflow error.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Single x, Single y, Single width, Single height)
at System.Drawing.Graphics.DrawImage(Image image, RectangleF rect)
at GrapeCity.ActiveReports.Core.Document.Drawing.Gdi.GdiCanvasItemRenderer.Render(CanvasItem item)
at GrapeCity.ActiveReports.Document.Section.PageExtensions.RenderPage(Page page, Graphics graphics, Boolean printing, SmoothingMode controlsSmoothing, GdiCanvasItemRenderer renderer)
at GrapeCity.ActiveReports.Document.Section.PageExtensions.Draw(Page page, Graphics graphics, RectangleF bounds, TextRenderingHint textRenderHint, SizeF scale, Boolean printing, DrawOptions options)
at GrapeCity.ActiveReports.Viewer.Common.Internal..Render(Graphics graphics)
at GrapeCity.ActiveReports.Viewer.Win.Views.MultiPageView.RenderPage(Int32 pageIndex, Graphics graphics)
When the same image is used with AR12, there is no error (so it is not a data problem).
The code changes I made are as follows:
' New AR 17
Dim _ImageBytes() As Byte
If _FrontEntityDocumentID > 0 Then
_ImageBytes = DLookup("Attachment", "tbl_EntityAttachments", "EntityDocumentID = " + _FrontEntityDocumentID.ToString)
Try
Dim _Image As GrapeCity.ActiveReports.Document.Drawing.Image
_Image = GrapeCity.ActiveReports.Document.Drawing.Image.FromStream(New System.IO.MemoryStream(_ImageBytes))
Me.Picture1.Image = _Image
Me.Picture1.Visible = True
Catch ex As Exception
Me.Picture1.Visible = False
End Try
Else
Me.Picture1.Visible = False
End If
' Old AR 12
Dim _ImageBytes() As Byte
If _FrontEntityDocumentID > 0 Then
_ImageBytes = DLookup("Attachment", "tbl_EntityAttachments", "EntityDocumentID = " + _FrontEntityDocumentID.ToString)
Try
Dim _Image As System.Drawing.Image
_Image = System.Drawing.Image.FromStream(New System.IO.MemoryStream(_ImageBytes))
Me.Picture1.Image = _Image
Me.Picture1.Visible = True
Catch ex As Exception
Me.Picture1.Visible = False
End Try
Else
Me.Picture1.Visible = False
End If
From the AR17 designer, the designer code for the Picture control is
'Picture1
'
Me.Picture1.Height = 1.02!
Me.Picture1.ImageBytes = Nothing
Me.Picture1.Left = 1.566!
Me.Picture1.Name = "Picture1"
Me.Picture1.SizeMode = GrapeCity.ActiveReports.SectionReportModel.SizeModes.Zoom
Me.Picture1.Top = 0.243!
Me.Picture1.Width = 2.491!
Any assistance would be appreciated.