Results 1 to 11 of 11

Thread: [RESOLVED] Image Selective Color?

  1. #1

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Resolved [RESOLVED] Image Selective Color?

    If any of you have used the new Windows Live Messenger, then you'll know what I'm talking about.

    I'm making a messenger with a similar look. It's a blue colored theme that uses a single image as the background.

    I'd like to let the user choose a color for the theme and have it apply that color to the image. Sort of like the Selective Color feature in Adobe Photoshop.

    I'm somewhat familiar with DIB programming, but I'm not quite sure how to do this.

    Any ideas?

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Image Selective Color?

    I have a vague idea of what you are wanting to accomplish. I am imagining a monochromatic image, modifying the hue to change the color. Could you show us your blue-theme image, and what it should look like if the user wanted it red?

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Image Selective Color?

    See if this thread helps you:
    http://www.vbforums.com/showthread.php?t=404105
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Image Selective Color?

    I couldn't get a red color through Photoshop but it should still show you what I'm talking about.

    I also attached images of what MSN looks like with a blue color, then with red.

    The one for mine is just the BG image, it actually looks a lot better than that but I haven't designed the custom controls for it yet.

    Thanks.
    Last edited by DigiRev; Mar 26th, 2007 at 02:55 AM.

  5. #5

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Image Selective Color?

    Quote Originally Posted by iPrank
    Thanks iPrank, I already got the transparency part working, but I'm gonna take a look at the hue part of it.

  6. #6

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Image Selective Color?

    Hm didn't really see any code in there that I could use for this...the DMA code was helpful though but I think I may stick to the basic GetDIBits() API, etc.

    Anyone have any suggestions? Or algorithms to alter a color based on hue/saturation? I could probably work it out myself from there.

  7. #7
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Image Selective Color?

    I put the image into picturebox1 and gave picturebox2 a red background, then using this code from the APIGuide i got the picture below.
    VB Code:
    1. 'This project requires two picture boxes
    2. 'Both picture boxes should contain a picture
    3. Const AC_SRC_OVER = &H0
    4. Private Type BLENDFUNCTION
    5.   BlendOp As Byte
    6.   BlendFlags As Byte
    7.   SourceConstantAlpha As Byte
    8.   AlphaFormat As Byte
    9. End Type
    10. Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
    11. Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
    12. Private Sub Form_Load()
    13.     'KPD-Team 2000
    14.     'URL: [url]http://www.allapi.net/[/url]
    15.     'E-Mail: [email][email protected][/email]
    16.     Dim BF As BLENDFUNCTION, lBF As Long
    17.     'Set the graphics mode to persistent
    18.     Picture1.AutoRedraw = True
    19.     Picture2.AutoRedraw = True
    20.     'API uses pixels
    21.     Picture1.ScaleMode = vbPixels
    22.     Picture2.ScaleMode = vbPixels
    23.     'set the parameters
    24.     With BF
    25.         .BlendOp = AC_SRC_OVER
    26.         .BlendFlags = 0
    27.         .SourceConstantAlpha = 128
    28.         .AlphaFormat = 0
    29.     End With
    30.     'copy the BLENDFUNCTION-structure to a Long
    31.     RtlMoveMemory lBF, BF, 4
    32.     'AlphaBlend the picture from Picture1 over the picture of Picture2
    33.     AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF
    34. End Sub
    Attached Images Attached Images  

  8. #8

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Image Selective Color?

    Thanks Andrew but doesn't that require Windows 2000 or greater? I'd like the messenger to be compatible with Windows 98 and up.

  9. #9

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Image Selective Color?

    I found a free DLL written in C++ that is lightning fast and I think works for Windows 98 too. So I'm going to try that.

    If anyone with Windows 98 can test this for me I would really appreciate it:

    http://www.pscode.com/vb/scripts/Sho...21470&lngWId=1

  10. #10
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Image Selective Color?

    Nope it can also work on 98 and up

    Quote Originally Posted by APIGuide
    Requires Windows 2000 or later; Requires Windows 98 or later
    http://web.archive.org/web/200304251...phaBlend.shtml
    Last edited by Andrew G; Feb 15th, 2007 at 05:39 AM.

  11. #11

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Image Selective Color?

    Oh ok. That should work perfect then. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width