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

  • SEARCH
  • Home
  • 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
  • 1 View
  • 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

Related Questions

Do any libraries exist with this functionality? Any recommendations would be useful. Thanks.
I wonder if there exist any other technologies used to establish internet connection between
I want to find (if they exist) any hash tags and get the first
any recommendation on which company providing scalable bosh hosting? p/s: is there exist any
Ok so basically I need to check,whether in my menu #Container exist any third
Do any open source or 'free' libraries exist for Java where i can perform
Do any libraries or other development resources exist that can help reduce the effort
Do any web 2.0 like websites exist for prototyping object oriented class diagrams?
I was wondering if any of the following exist in python: A: non-regex equivalent
Are there any good algorithms for determining the best type to instantiate in order

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.