Search code examples
c#asp.nethtml.net-3.5

Implementing User-Controlled Style Changes in ASP.NET


Ok, so we have clients and those clients get to customize their web facing page. One option we are giving them is to be able to change the color of a graphic (it's like a framish-looking bar) using one of those hex wheels or whatever.

So, I've thought about it, and I don't know where to start. I am sending comps out this week to my xhtml guy and I want to have the implementation done at least in my mind before I send things out.

Something about System.Drawing sounds about right, but I've never worked with that before and it sounds hella complicated. Does anyone have an idea?

UPDATE: The color of an image will be changing. So if I want image 1 to be green, and image 2 to be blue, I go into my admin screen and enter those hex values (probably will give them an interface for it) and then when someone else looks at their page they will see the changes they made. Kind of like customizing a facebook or myspace page (OMFGz soooo Werb 2.0)


Solution

  • I'm sort of intuiting that you'll have a black on white bitmap that you use as the base image. The client can then select any other color combination. This may not be exactly your situation, but it should get us started. (The code below is VB -- it's what I know, but converting to C# should be trivial for you.)

    Imports System.Drawing
    
    Private Function createImage(ByVal srcPath As String, ByVal fg As Color, ByVal bg As Color) As Bitmap
        Dim img As New Bitmap(srcPath)
        For x As Int16 = 0 To img.Width
            For y As Int16 = 0 To img.Height
                If img.GetPixel(x, y) = Color.Black Then
                    img.SetPixel(x, y, fg)
                Else
                    img.SetPixel(x, y, bg)
                End If
            Next
        Next
        Return img
    End Function
    

    And then you can do whatever with the image...