用API函数取色后,如何将其分成RGB颜色?
来源:互联网 发布:磐厚资本知乎 编辑:程序博客网 时间:2024/06/13 00:44
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
用API函数取色后,如何将其分成RGB颜色?
问题:
用API函数取色后,是一个10进制的数值,如何将其分成RGB颜色?
方法一:
用 HEX 函数将数值转换为 16 进制,然后,每两个切分一下就可以得到 RGB 数值了
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 & "_" & strB
End Function
Sub test1()
Debug.Print C10ToRGB_1(33023)
Debug.Print RGB(255, 128, 0)
End Sub
方法二:
【转载】
如果要将VB的颜色转换为COLORREF,需要使用OleTranslateColor函数。例子:
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
更完整的例子参考:http://www.mvps.org/vbnet/index.html?code/system/oletranslatecolor.htm
方法三:
用 HEX 函数将数值转换为 16 进制,然后,每两个切分一下就可以得到 RGB 数值了
Sub test1()
Debug.Print C10ToRGB(33023)1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
用API函数取色后,如何将其分成RGB颜色?
问题:
用API函数取色后,是一个10进制的数值,如何将其分成RGB颜色?
方法一:
用 HEX 函数将数值转换为 16 进制,然后,每两个切分一下就可以得到 RGB 数值了
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 & "_" & strB
End Function
Sub test1()
Debug.Print C10ToRGB_1(33023)
Debug.Print RGB(255, 128, 0)
End Sub
方法二:
【转载】
如果要将VB的颜色转换为COLORREF,需要使用OleTranslateColor函数。例子:
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
更完整的例子参考:http://www.mvps.org/vbnet/index.html?code/system/oletranslatecolor.htm
方法三:
用 HEX 函数将数值转换为 16 进制,然后,每两个切分一下就可以得到 RGB 数值了
Sub test1()
Debug.Print C10ToRGB(33023)1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 用API函数取色后,如何将其分成RGB颜色?
- 用API函数取色后,如何将其分成RGB颜色?
- 用API函数取色后,如何将其分成RGB颜色?
- 如何将24位RGB颜色转换16位RGB颜色
- iOS 之如何将#000000颜色转化成RGB
- iOS 之如何将#737373颜色转化成RGB
- RGB颜色转换函数
- 将RGB转换成颜色
- 颜色RGB如何转成#号值
- 用API函数设置颜色
- 如何将一个包含颜色信息的长整类型转化为 RGB 表示
- java后台如何将rgb与16进制颜色进行转换
- 将RGB颜色值转换为UIColor
- IOS小技巧——如何将美工的16进制颜色转换成IOS中的RGB颜色
- JS练习:选择颜色,得到其HEX 和RGB
- 将RGB颜色转换成16bit颜色
- VB取各颜色分量,将RGB转为HTML颜色.
- 将RGB颜色转换成16bit颜色
- Intel HEX文件格式
- tip:一些可以用于null值处理的函数
- Spring事务心得
- asp.net实现网站Rss订阅功能
- 关于vc6.0中很多函数编译不通过的解决:
- 用API函数取色后,如何将其分成RGB颜色?
- C语言学习笔记-递归2
- 一个简单T9输入法的实现(有代码)
- .ldb文件到底派什么用场得?
- 日语流行口语极短句1
- 对物流网(易流)的调研
- 如何在工具栏中,加上图标和文字?(How To Add Icon A
- 简单叙述动态公式的工资系统的计算方式
- DCC32參數_月夜风筝