To help someone else, I put together some color functions and thought I'd share it for anyone else to use/abuse. The class contains functions that can be pulled out (for the most part) individually and added to existing projects or it can be used as is. Use it more as a learning tool. Read the comments throughout the class.
The gist of the attached class is manual color modifications: blending, color & lightness addition/subtraction, conversion between different color formats, premultipllication, gray scaling, and several more routines.
I do not plan on appending new routines/functions to this class. However, there are dozens upon dozens of other color functions/matrices out on the web. Maybe start your own collection.
Edited: Here's another function. I'll leave it to you to build an Array version of it if needed.
Code:
Public Function UnPremultiplyColor(ByVal Color As Long) As Long
' remove premultiplication and returns a color in RGBA format
' Note: Premultiplication is not 100% recoverable. The returned
' color compared to its original color is dependent upon the
' alpha level. The higher the alpha level the closer the
' returned color is to the original color.
' Any alpha value of zero will always return vbBlack as the color
Dim R As Long, G As Long, B As Long, Alpha As Long
If (Color And &HFF000000) <> 0& Then
Alpha = Me.Alpha(Color)
R = ((Color And &HFF&) * &HFF&) \ Alpha
G = (((Color And &HFF00&) \ &H100&) * &HFF&) \ Alpha
B = (((Color And &HFF0000) \ &H10000) * &HFF&) \ Alpha
UnPremultiplyColor = (Color And &HFF000000) Or R Or G * &H100& Or B * &H10000
End If
End Function
Last edited by LaVolpe; Aug 6th, 2010 at 01:12 PM.
Insomnia is just a byproduct of, "It can't be done"
To help someone else, I put together some color functions and thought I'd share it for anyone else to use/abuse. The class contains functions that can be pulled out (for the most part) individually and added to existing projects or it can be used as is. Use it more as a learning tool. Read the comments throughout the class.
The gist of the attached class is manual color modifications: blending, color & lightness addition/subtraction, conversion between different color formats, premultipllication, gray scaling, and several more routines.
I do not plan on appending new routines/functions to this class. However, there are dozens upon dozens of other color functions/matrices out on the web. Maybe start your own collection.
Edited: Here's another function. I'll leave it to you to build an Array version of it if needed.
Code:
Public Function UnPremultiplyColor(ByVal Color As Long) As Long
' remove premultiplication and returns a color in RGBA format
' Note: Premultiplication is not 100% recoverable. The returned
' color compared to its original color is dependent upon the
' alpha level. The higher the alpha level the closer the
' returned color is to the original color.
' Any alpha value of zero will always return vbBlack as the color
Dim R As Long, G As Long, B As Long, Alpha As Long
If (Color And &HFF000000) <> 0& Then
Alpha = Me.Alpha(Color)
R = ((Color And &HFF&) * &HFF&) \ Alpha
G = (((Color And &HFF00&) \ &H100&) * &HFF&) \ Alpha
B = (((Color And &HFF0000) \ &H10000) * &HFF&) \ Alpha
UnPremultiplyColor = (Color And &HFF000000) Or R Or G * &H100& Or B * &H10000
End If
End Function
Thank you very much for sharing your valuable code, excuse my ignorance but I would like to know how to send the parameters from a form.
I feel that you mis-understand what LaVolpe is providing us in this CodeBank entry. Basically (in summary), he's providing us some tools for dealing with images that contain an alpha channel. Briefly, that's a channel (RGBA) that can be contained in an image for providing translucency (or opacity, which ever way you'd like to think about it) for each pixel within the image. In a straightforward VB6 way, this has virtually nothing to do with VB6 forms (even including images on forms, as they don't handle the alpha channel).
Also, I'm not bad at VB6, but I'm clueless about what you're actual question is. And, I think you'd do well to try and expand on what you're asking, and also just start a new thread over in the main VB6 Q&A section.
Also, LaVolpe said adios to us back in February, having started a new job that apparently had little to do with VB6. So, I'm not sure you should expect a reply from him.
Good Luck,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
I feel that you mis-understand what LaVolpe is providing us in this CodeBank entry. Basically (in summary), he's providing us some tools for dealing with images that contain an alpha channel. Briefly, that's a channel (RGBA) that can be contained in an image for providing translucency (or opacity, which ever way you'd like to think about it) for each pixel within the image. In a straightforward VB6 way, this has virtually nothing to do with VB6 forms (even including images on forms, as they don't handle the alpha channel).
Also, I'm not bad at VB6, but I'm clueless about what you're actual question is. And, I think you'd do well to try and expand on what you're asking, and also just start a new thread over in the main VB6 Q&A section.
Also, LaVolpe said adios to us back in February, having started a new job that apparently had little to do with VB6. So, I'm not sure you should expect a reply from him.
Good Luck,
Elroy
Hello, what I wanted to say was an example of the use of the module, I don't have much skill.
Thanks a lot