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 8521229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:45:46+00:00 2026-06-11T06:45:46+00:00

I wrote a small color picker code my self and it works well. However

  • 0

I wrote a small color picker code my self and it works well. However the issue, when I move the slide to get a selected color (RGB) the canvas(gradient of white black and selected color is taking time. The delay is because of code:
enter image description here

The code is as follows:

Try
    'Dim converter As New SlidertoColor
    'Dim cornercolor As Color = converter.Convert(MySlider.Value, Nothing, Nothing, Nothing)

    Dim cornercolor As Color = Value
    Dim y As Integer = 0
    Dim x As Integer = 0


    Dim wb As New WriteableBitmap(256, 256, 96, 96, PixelFormats.Pbgra32, Nothing)
    Dim stride As Integer = CInt((wb.PixelWidth * wb.Format.BitsPerPixel) / 8)

    Dim RD As Decimal = cornercolor.R / 255
    Dim GD As Decimal = cornercolor.G / 255
    Dim BD As Decimal = cornercolor.B / 255

    Dim r As Decimal = cornercolor.R
    Dim g As Decimal = cornercolor.G
    Dim b As Decimal = cornercolor.B

    Dim lr As New List(Of Decimal)
    Dim lb As New List(Of Decimal)
    Dim lg As New List(Of Decimal)

    Try
        For i = 0 To 255
            lr.Add(r)
            r = r - RD
            lg.Add(g)
            g = g - GD
            lb.Add(b)
            b = b - BD
        Next

    Catch ex As Exception

    End Try

    r = cornercolor.R
    g = cornercolor.G
    b = cornercolor.B

    'For y = 255 To 0 Step -1
    For y = 0 To 255
        RD = ((255 - y) - lr(y)) / 255
        GD = ((255 - y) - lg(y)) / 255
        BD = ((255 - y) - lb(y)) / 255

        If RD < 0 Then
            RD = RD * -1
        End If
        If GD < 0 Then
            GD = GD * -1
        End If
        If BD < 0 Then
            BD = BD * -1
        End If

        'Need to work on this section
        r = 255 - y
        g = 255 - y
        b = 255 - y


        For x = 0 To 255
            Try
                Dim colorData As Byte() = {
                CByte(b),
                CByte(g),
                CByte(r),
                CByte(255)}

                Dim rect As New Int32Rect(x, y, 1, 1)
                wb.WritePixels(rect, colorData, stride, 0)

                r = r - RD
                g = g - GD
                b = b - BD

                If r < 0 Then
                    r = 0
                End If
                If g < 0 Then
                    g = 0
                End If
                If b < 0 Then
                    b = 0
                End If
            Catch ex As Exception

            End Try

        Next
    Next

    'Dim colorData As Byte() = {CByte(blue), CByte(green),
    '                           CByte(red), CByte(255)}
    'Dim rect As New Int32Rect(x, y, 1, 1)

    'Try
    '    wb.WritePixels(rect, colorData, stride, 0)
    'Catch ex As Exception
    'End Try

    Dim k As New ImageBrush
    k.ImageSource = wb
    Return k

Could you please tell my how to speed up this process, or is there a efficient way to achieve this. I know that there are free to use color pickers, but I want to try my own.
I am using VB.Net, WPF.
Thank you.

  • 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-06-11T06:45:48+00:00Added an answer on June 11, 2026 at 6:45 am

    Found the answer, it seems that the gradient chart is also produced exactly the same way by using the xaml as follows:

    </Canvas>-->
        <Canvas Width="256" Height="256" Margin="32,30,215,26">
            <Canvas.Background>
                <LinearGradientBrush StartPoint="0 0.5" EndPoint="1 0.5">
                    <GradientStop Color="White" Offset="0" />
                    <GradientStop Offset="1" Color="{Binding ElementName=MySlider, Path=Value, Converter={StaticResource SlidertoColor1}}" />
                </LinearGradientBrush>
            </Canvas.Background>
            <Canvas Width="256" Height="256">
                <Canvas.Background>
                    <LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
                        <GradientStop Color="Transparent" Offset="0" />
                        <GradientStop Color="Black" Offset="1" />
                    </LinearGradientBrush>
                </Canvas.Background>
            </Canvas>
        </Canvas>
    

    Thank you for your support.

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

Sidebar

Related Questions

I wrote a small Shotgun app, however, the section of code that needs to
I wrote small piece of code which should toggle reporting box on my page.
I have a small chunk of code I can't seem to get working. I
I wrote a small script to let a label move out of the way
I wrote a small example to test my understanding of pointers and memory, however
I wrote a small express.js based web app. I serve a manifest.webapp but express.js
I wrote two small applications (a client and a server) to test UDP communication
I wrote a small test program for flipperview. I have 3 views. I call
I wrote two small java programs: a TCP client which sends many lines of
I wrote a small internal web app using (a subset of) pylons . As

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.