in

C1 Community

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

Creating an overview or thumbnail image

Last post 04-09-2008 12:46 PM by C1_GregL. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-26-2008 11:35 AM

    Creating an overview or thumbnail image

    I would like to create a thumbnail image of the plot without the extras (borders, legend, etc). Just a very compact image that shows only the series, which I guess is the PlotArea. There are numerous image related functions but they all seem to be for exporting the entire chart. Is there an easy way to do this, without changing to chart to minimize all margins? I see the PaintPlotArea event, but I don't think that will help.

    --
    Jason D.
    Senior Software Developer
    The Transtec Group, Inc.
  • 04-09-2008 12:46 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 515

    Re: Creating an overview or thumbnail image

    A possible solution is to generate an image of the entire chart, and knowing the location and size of the plot area, use bitmap graphics to crop the image.  Here is code to crop the plot area and display it in a Picturebox.

    Imports System.Drawing
    Imports System.Drawing.Imaging

    1. Dim plotWidth As Integer = C1Chart1.ChartArea.PlotArea.Size.Width
    2. Dim plotHeight As Integer = C1Chart1.ChartArea.PlotArea.Size.Height
    3. Dim offsetX As Integer = C1Chart1.ChartArea.PlotArea.Location.X
    4. Dim offsetY As Integer = C1Chart1.ChartArea.PlotArea.Location.Y
    5. Dim img As Image = C1Chart1.GetImage
    6. Dim bmp As New Bitmap(plotWidth, plotHeight, PixelFormat.Format24bppRgb)
    7. Dim g As Graphics = Graphics.FromImage(bmp)
    8. g.DrawImage(img, New Rectangle(0, 0, plotWidth, plotHeight), offsetX, offsetY, plotWidth, plotHeight, GraphicsUnit.Pixel)
    9. PictureBox1.Image = bmp

    To also scale it you can use the code above but just change two lines

    'Scale to 50x40 thumbnail
    6.  Dim bmp As New Bitmap(50, 40, PixelFormat.Format24bppRgb)
    8.  g.DrawImage(img,
    New Rectangle(0, 0, 50, 40), offsetX, offsetY, plotWidth, plotHeight, GraphicsUnit.Pixel)

    regards,
    Greg L

    Filed under: , ,
Page 1 of 1 (2 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.