C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

C1WebChart Image to C1Report Field as Picture

rated by 0 users
This post has 2 Replies | 1 Follower

Not Ranked
Posts 3
MWPPUser Posted: Tue, Jun 09 2009 10:38 AM

I'm having an issue getting a good quality image from the C1WebChart to use on a C1Report.

I am using:

Public Sub GetChartMetaFile(ByRef C1WebChart As C1WebChart, ByRef PictureField As Field)

Dim MyDrawingSize As Drawing.Size = New Drawing.Size(PictureField.Width * 96.0F / 1440.0F, PictureField.Height * 96.0F / 1440.0F)

Dim img As Image = C1WebChart.GetImage(ImageFormat.Png, MyDrawingSize)

PictureField.Picture = Me.GetMF(img, MyDrawingSize)

End Sub

Private Function GetMF(ByVal IMG As Image, ByVal MyDrawingSize As Size) AS MetaFile

Dim hdc As IntPtr = New IntPtr

Dim g As Graphics = Graphics.FromHwnd(hdc)

hdc = g.GetHdc

Dim mf As New Metafile(hdc, New RectangleF(0, 0, MyDrawingSize.Width, MyDrawingSize.Height), MetafileFrameUnit.Pixel, EmfType.EmfOnly)

g.ReleaseHdc(hdc)

g.Dispose()

g = Graphics.FromImage(mf)

g.DrawImage(IMG, 0, 0)

g.Dispose()

IMG.Dispose()

Return mf

End Function

 

This seems to work fine for the C1.Win.C1Chart.C1Chart but not for the webchart. Is there a work around for getting a better image out of the chart?

 

Top 10 Contributor
Posts 1,237
Hi,

Please use ImageFormat.Emf format instead of Png that it generate better
quality image as compare to Png,
like the following:

Dim img As Image = C1WebChart.GetImage(ImageFormat.Emf, MyDrawingSize)

Hope this helps.

Regards,
Patrick


wrote in message news:218755@10.0.1.98...
I'm having an issue getting a good quality image from the C1WebChart to use
on a C1Report.
I am using:
Public Sub GetChartMetaFile(ByRef C1WebChart As C1WebChart, ByRef
PictureField As Field)
Dim MyDrawingSize As Drawing.Size = New Drawing.Size(PictureField.Width *
96.0F / 1440.0F, PictureField.Height * 96.0F / 1440.0F)
Dim img As Image = C1WebChart.GetImage(ImageFormat.Png, MyDrawingSize)
PictureField.Picture = Me.GetMF(img, MyDrawingSize)
End Sub
Private Function GetMF(ByVal IMG As Image, ByVal MyDrawingSize As Size) AS
MetaFile
Dim hdc As IntPtr = New IntPtr
Dim g As Graphics = Graphics.FromHwnd(hdc)
hdc = g.GetHdc
Dim mf As New Metafile(hdc, New RectangleF(0, 0, MyDrawingSize.Width,
MyDrawingSize.Height), MetafileFrameUnit.Pixel, EmfType.EmfOnly)
g.ReleaseHdc(hdc)
g.Dispose()
g = Graphics.FromImage(mf)
g.DrawImage(IMG, 0, 0)
g.Dispose()
IMG.Dispose()
Return mf
End Function

This seems to work fine for the C1.Win.C1Chart.C1Chart but not for the
webchart. Is there a work around for getting a better image out of the
chart?




http://helpcentral.componentone.com/cs/forums/p/79489/218755.aspx#218755
Not Ranked
Posts 3
MWPPUser replied on Mon, Jun 29 2009 7:43 AM

I was actually trying different types of images when I posted this code. I do use EMF but it still doesn't work. The only work around I've found for this problem is by using the Windows Forms version of the chart then creating an ASP version from string to use on the website. Then I store the string in viewstate and use it when a user wants a PDF version. I think the problem is that you can't create a scalable EMF from the web version of the chart.

Page 1 of 1 (3 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2009 ComponentOne LLC All Rights Reserved.