Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 635755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:26:23+00:00 2026-05-13T20:26:23+00:00

Do exist any algorithms to create programmatically images, for use then a base for

  • 0

Do exist any algorithms to create programmatically images, for use then a base for a color picking control?

If you know some useful sources for document or code about this topic they are welcome.

EDIT: my idea is to create a WPF Picker Control, I know there already some for WPF, Sacha’s one, or the one from Microsoft Sample. The point of this question is not too much oriented to the technology I will use later, but to the algorithm for creating the image.

EDIT2: I would like to create something like the gradient image in the square, programmatically.

alt text http://patterns.holehan.org/uploads/gimp_color_chooser.png

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:26:24+00:00Added an answer on May 13, 2026 at 8:26 pm

    Here are some possibilities:

    1. Create the image using overlapping linear gradient brushes.
    2. Create the image as a bitmap.
    3. Create the image during rendering using pixel shaders.

    Overlapping gradient brushes

    For the image you showed, you may be able to achieve the effect you need by using something along these lines:

    <Grid>
      <Rectangle>
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <GradientStop Offset="0" Color="#FFFF8040" />
            <GradientStop Offset="1" Color="#FFFFFFFF" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle>
        <Rectangle.Fill>
          <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
            <GradientStop Offset="0" Color="#FF000000" />
            <GradientStop Offset="1" Color="#00000000" />
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
    </Grid>
    

    The first fill sets the color and the second fill darkens it. Obviously this could be done in a Drawing or a VisualBrush.

    This is the easiest solution but is limited in what it can produce.

    Creating the image as a bitmap

    Using a bitmap will work but is not resolution-independent. You’ll need to pick the resolution at which to create the bitmap. If you choose too low a resolution you’ll get poor quality. If you choose too high a resolution you’ll waste resources. Automatically selecting the resolution based on screen resolution and transforms is difficult but possible: You must subscribe to several events to detect resolution changes and use TransformToDevice on the target to determine the transform from WPF coordinates to device coordinates.

    Once you have decided on the resolution for your bitmap, the rest is easy:

    uint[] pixels = new uint[width*height];
    for(int x=0; x<width; x++)
      for(int y=0; y<height; y++)
        pixels[y*width + x] = ComputeColor(x, y);
    
    var bitmap = new WritableBitmap(width, height, 96, 96, PixelFormat.Pbgra32, null);
    bitmap.WritePixels(new Rect(0, 0, width, height), pixels, width*4, 0);
    

    Using pixel shaders

    Pixel shaders actually run within the GPU itself, and they run for each pixel. They already know the target resolution, so the color computation is easy. What is difficult is that you can’t write the algorithm in C# or VB.NET: You must write it in the High Level Shader Language (HLSL), which can be a significant learning curve.

    Here are some web sites with examples of custom shaders:

    Pixel shaders and silverlight
    WPF pixel shader effects library
    Interactive example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 310k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Backup and restore is usually the simplest way. The only… May 13, 2026 at 10:15 pm
  • Editorial Team
    Editorial Team added an answer Try this, it uses lookahead so that the LI is… May 13, 2026 at 10:15 pm
  • Editorial Team
    Editorial Team added an answer In SQL Server 2008, ItemCount won't count records that the… May 13, 2026 at 10:15 pm

Related Questions

I have some algorithms to do that are very similar in very aspects but
Say I have a table called HoursCharged ChrgNum(varchar(10)) CategoryID(uniqueidentifier) Month(datetime) Hours(int) CategoryID is a
I always wondered why there exists no removeParameters() method in Servlet API. What could
Let's say you want to diagram a Map class (the mathematical kind, not the
I've got a couple of really old MSDos based paint programs. They work on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.