How to divide it into RGB color after colors with an API function?

zhaozj2021-02-16  57

How to divide it into RGB color after colors with an API function?

problem:

After colors with the API function, it is a 10-en-product value, how does it divide it into RGB?

method one:

Convert the numerical value to 16 credits with the HEX function, then you can get the RGB value.

Function C10ToRGB_1 (lngColor As Long) As String Dim strR As String Dim strG As String Dim strB As String strR = lngColor Mod 256 strG = lngColor / 256 Mod 256 strB = lngColor / 256/256 C10ToRGB_1 = strR & "_" & strG & "_" & Strbend function

SUB Test1 () Debug.print C10 Torgb_1 (33023) Debug.print RGB (255, 128, 0) End Sub

Method Two:

[Reserved] If you want to convert the color of VB to ColorRef, you need to use the OletranslateColor function. example:

Private Declare Function OleTranslateColor Lib "olepro32.dll" _ (ByVal OLE_COLOR As Long, _ ByVal HPALETTE As Long, _ pccolorref As Long) As Long Private Sub GetRBGFromOLEColour (ByVal dwOleColour As Long, r As Long, g As Long, b As Long ) 'pass a hex colour, return the rgb components Dim clrref As Long' translate OLE color to valid color if passed OleTranslateColor dwOleColour, 0, clrref b = (clrref / 65536) And & HFF g = (clrref / 256) And & HFF r = CLRREF AND & HFF text1 (0) .text = dwolecolour text1 (1) .text = CLRREF END SUB more complete example reference: http://www.mvps.org/vbnet/index.html? code / system / oletranslateColor.htm

Method 3:

Convert the numerical value to 16 credits with the HEX function, then you can get the RGB value.

Sub Test1 () Debug.print C10 Torgb (33023) Debug.print RGB (255, 128, 0) End Sub

转载请注明原文地址:https://www.9cbs.com/read-24507.html

New Post(0)