[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? :sick:
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?
Re: Image Selective Color?
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.
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.
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.
1 Attachment(s)
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:
'This project requires two picture boxes
'Both picture boxes should contain a picture
Const AC_SRC_OVER = &H0
Private Type BLENDFUNCTION
BlendOp As Byte
BlendFlags As Byte
SourceConstantAlpha As Byte
AlphaFormat As Byte
End Type
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
Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Form_Load()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
Dim BF As BLENDFUNCTION, lBF As Long
'Set the graphics mode to persistent
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
'API uses pixels
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
'set the parameters
With BF
.BlendOp = AC_SRC_OVER
.BlendFlags = 0
.SourceConstantAlpha = 128
.AlphaFormat = 0
End With
'copy the BLENDFUNCTION-structure to a Long
RtlMoveMemory lBF, BF, 4
'AlphaBlend the picture from Picture1 over the picture of Picture2
AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF
End Sub
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.
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
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
Re: Image Selective Color?
Oh ok. :) That should work perfect then. Thanks. :cool: