Developer Tools

    .NET Color Quantization

    Describes how to quantize dynamically generated images for use with ASP.NET
    • Version:


      File Name:

      DotNET Color Quantization Code.exe

      Date Published:


      File Size:

      143 KB

        Most web sites include some form of graphics, such as the banner heading on the MSDN web site, and the thumbnail images available for the list of recent headlines. All of these images are static – they are generated by a member of the web team, recolored to suit the requirements of the web site, and stored on disk to be used as appropriate.
        With ASP.Net it is also possible to create dynamic images – images which are created during the processing of the current web request. Some uses for this would be personalization of a site, or generation of images which conform to a particular visual style, without requiring the services of a web designer.
        The generation of images is relatively simple – create a surface to draw on, render the appropriate image, and save this to the ASP.Net response stream to be returned to the user.
        The only problem with this scenario is the resulting image – GDI+ will by default utilize a web safe palette when converting a bitmap to an image suitable for a web page (such as GIF/Jpeg), and so the resulting image will be of poor quality and may contain various stray colors from the color reduction algorithm used. This conversion to a web safe palette occurs before the image is converted to the output type (such as GIF/Jpeg), so even though the output type may support many colors, the image will be generated to use colors from the web safe palette.

        The attached download provides two examples of how quantization can be used to recolor an image.
    • Supported Operating System

      Windows 2000, Windows Server 2003, Windows XP

        .NET Framework version 1.0 or 1.1
        Visual Studio.NET
      • To setup this example on your PC, please do the following.

        (1) Copy all files onto your hard drive. The attached .exe is a self extracting .zip which includes all files necessary for this example.
        (2) Publish the 'Quantize' directory from your web server. It should be published as http://localhost/quantize.

        Then open the solution file, rebuild and run.

    Popular downloads

      • 01

        Microsoft .NET Framework 4 (Web Installer)

        The Microsoft .NET Framework 4 web installer package downloads and installs the .NET Framework components required to run on the target machine architecture and OS. An Internet connection is required during the installation. .NET Framework 4 is required to run and develop applications to target the .NET Framework 4.

      • 04

        Microsoft .NET Framework 3.5 Service Pack 1

        Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing updates to the .NET Framework 2.0 and .NET Framework 3.0 subcomponents.

      • 05

        Microsoft .NET Framework 3.5

        Microsoft .NET Framework 3.5 contains many new features building incrementally upon .NET Framework 2.0 and 3.0, and includes .NET Framework 2.0 service pack 1 and .NET Framework 3.0 service pack 1.

    Loading your results, please wait...

    Free PC updates

    • Security patches
    • Software updates
    • Service packs
    • Hardware drivers

    Microsoft suggests

    Download free tools to build apps for Windows.
    Download free tools to build apps for Windows
    Develop apps that reach the entire family of Windows devices.
    Get started