|
-
Aug 10th, 2021, 12:05 AM
#2
Member
Re: [VB6] Color Functions - Blending, etc
 Originally Posted by LaVolpe
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.
Thank you, teacher
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|