Click here to Skip to main content
15,895,011 members
Articles / Desktop Programming / WPF

WPF Color Picker Construction Kit

Rate me:
Please Sign up or sign in to vote.
4.97/5 (59 votes)
26 Dec 2010CPOL9 min read 117K   7.7K   76  
A WPF color picker (like Adobe's) constructed in a modular fashion for easy modification.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ColorPicker.ColorModels
{
    public abstract class NormalComponent : ColorComponent
    {
        //Is the Normal bitmap independent of the specific color (false for all but Hue of HSB)
        public abstract bool IsNormalIndependantOfColor { get; } 

        //Updates the normal Bitmap (The bitmap with the slider)
        public abstract void UpdateNormalBitmap(WriteableBitmap bitmap, Color color);

        //Updates the color plane bitmap (the bitmap where one selects the colors)
        public abstract void UpdateColorPlaneBitmap(WriteableBitmap bitmap, int normalComponentValue);

        //Gets the color corresponding to a selected point (with 255 alpha)
        public abstract Color  ColorAtPoint(Point selectionPoint,int colorComponentValue);

        //Gets the point on the color plane that corresponds to the color (alpha ignored)
        public abstract Point PointFromColor(Color color);
    }
}

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 The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Written software for what seems like forever. I'm currenly infatuated with WPF. Hopefully my affections are returned.

Comments and Discussions