Click here to Skip to main content
15,893,368 members
Articles / Operating Systems / Windows

WPF Chart Control With Pan, Zoom and More

Rate me:
Please Sign up or sign in to vote.
4.92/5 (42 votes)
10 Dec 2012Public Domain10 min read 387.5K   10.9K   174  
Chart Control for Microsoft .NET 3.0/WPF with pan, zoom, and offline rendering to the clipboard for custom sizes.
//Copyright (c) Microsoft Corporation.  All rights reserved.

#pragma once

#include "DirectUnknown.h"
#include "WICStructs.h"
#include "WICEnums.h"
#include "WICBitmapSource.h"

using namespace System;

namespace  Microsoft { namespace WindowsAPICodePack { namespace DirectX { namespace WindowsImagingComponent {

/// <summary>
/// Exposes methods that represent a pixel format converter. This class provides the means 
///    of converting from one pixel format to another, handling dithering and halftoning 
///    to indexed formats, palette translation and alpha thresholding. 
/// <para>(Also see IWICFormatConverter interface)</para>
/// </summary>
public ref class WICFormatConverter :  public DirectUnknown
{
    public:
    /// <summary>
    /// Returns the BitmapSource of a particular FormatConverter.
    /// </summary>
    BitmapSource^ ToBitmapSource();

    /// <summary>
    /// Initializes the format converter.
    /// </summary>
    /// <param name="source">The input bitmap to convert</param>
    /// <param name="destinationFormat">The destination pixel format.</param>
    /// <param name="ditherType">The BitmapDitherType used for conversion.</param>
    /// <param name="paletteType">The palette translation type to use for conversion.</param>
    void Initialize( 
        BitmapSource^ source,
        Guid destinationFormat,
        BitmapDitherType ditherType,
        BitmapPaletteType paletteType);

    /// <summary>
    /// Retrieves the pixel width and height of the bitmap.
    /// </summary>
    property BitmapSize Size
    {
        BitmapSize get();
    }

    /// <summary>
    /// Retrieves the pixel format the pixels are stored in. 
    /// </summary>
    property Guid PixelFormat
    {
        Guid get();
    }
    
    /// <summary>
    /// Retrieves the sampling rate between pixels and physical world measurements.
    /// </summary>
    property BitmapResolution Resolution
    {
        BitmapResolution get(); 
    }

    /// <summary>
    /// Instructs the object to produce pixels.
    /// </summary>
    /// <returns>An array of the pixel data.</returns>
    cli::array<unsigned char>^ CopyPixels( );

    /// <summary>
    /// Instructs the object to produce pixels.
    /// <para>Application is responsible for freeing the memory when the IntPtr is no longer needed by calling Marshal.FreeHGlobal().</para>
    /// </summary>
    /// <returns>A pointer to the pixel data in memory.</returns>
    IntPtr CopyPixelsToMemory( );

internal:
    WICFormatConverter()
    { }

    WICFormatConverter(IWICFormatConverter* formatConverter) : DirectUnknown(formatConverter)
    { }    
};

} } } }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Founder Cheesy Design
Taiwan Taiwan
John graduated from the University of South Australia in 1997 with a Bachelor of Electronic Engineering Degree, and since then he has worked on hardware and software in many fields including Aerospace, Defence, and Medical giving him over 10 of years experience in C++ and C# programming. In 2009 John Started his own contracting company doing business between Taiwan and Australia.

Comments and Discussions