| ||
SharpPlot Tutorials General Tutorials Chart Samples Style Examples SharpLeaf Tutorials Document Layout Tutorials Text Flow Tutorials Table Tutorials Visual Glossaries SharpPlot Class SharpPlot Properties SharpPlot Structures SharpPlot Enumerations PageMap Class SharpLeaf Reference SharpLeaf Class SharpLeaf Properties SharpLeaf Methods Table Class Table Properties Table Methods SharpLeaf Structures FontType Structure ParagraphStyle Structure BoxStyle Structure SharpLeaf Enumerations DocumentLayout Classes DocumentLayout Class PageLayout Class PageElement Abstract Class Frame : PageElement Class TextBlock : PageElement Class ImageBlock : PageElement Class Box : PageElement Class Rule : PageElement Class Common Reference Document Class VectorMath Class DbUtil Class Download Release Notes Licensing |
SharpPlot Reference > SharpPlot Methods > RenderBitmap Method SharpPlot.RenderBitmap MethodReturn completed chart rendered through raster engine. Examplebitmap cht = sp.RenderBitmap(72); cht.Save("cht.png",System.Drawing.Imaging.ImageFormat.Png); Return ValueThe result of this call is a Bitmap object, rendered by default at 96dpi. Ths is may then be saved to disk in any of the common image formats, typically PNG or JPEG to benefit from image compression. GIF is not recommended for images with gradient fills as it is limited to 256 colours and is likely to show some banding. For images to be used in printed material, you probably should use at least 300dpi to get acceptable quality. The text will be anti-aliased by default, but you may over-ride the text-rendering algorithm by passing in the standard .Net rendering hint as a final option. If your chart has made use of hyperlinks or JavaScript calls, you will need to create an accompanying image map, and include it in the completed webpage. Overloads
ExampleThis script creates a simple chart and renders it for display in a web page: <%@ page language="VB" AutoEventWireup="True"%> <%@ Import Namespace = "System.Drawing" %> <%@ Import Namespace = "System.Drawing.Imaging" %> <%@ Import Namespace = "Causeway" %> <Script Runat="Server"> Sub Page_Load(sender as Object, e as EventArgs) Dim sp As Causeway.SharpPlot = New Causeway.SharpPlot() sp.DrawPieChart(New Integer(){34,23}) Dim bitmap As Bitmap bitmap = sp.RenderBitmap() Dim stream As System.IO.MemoryStream stream = New System.IO.MemoryStream() bitmap.Save(stream, ImageFormat.Png) Response.Clear() Response.ClearHeaders() Response.ContentType = "image/png" Response.BinaryWrite(stream.ToArray()) Response.End() End Sub </Script> Note the lines: Response.ContentType = "image/png" Response.BinaryWrite(stream.ToArray()) which set the correct type for the returned image and then return the rendered chart as a binary stream. To write the completed image to file, you could use: // Create a bitmap and save as PNG ... Bitmap chart = sp.RenderBitmap(72); chart.Save("Simple.png",System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("Image written to Simple.png at 72dpi"); See also ...SharpPlot Members | SharpPlot.RenderImageMap Method | SharpPlot.SaveImage Method |