|
发表于 2024-8-12 18:04
来自手机
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 lss001 于 2024-8-12 18:26 编辑
aman1516 发表于 2024-8-8 22:47
继续依葫芦画瓢:
Sub 指定透明颜色范围()
Dim img As Object, v As Object, argbs As Object
Dim a%, r%, g%, b%, i&, j&, k&, w&, h&
f = "d:\1.jpg"
Set img = CreateObject("Wia.ImageFile")
Set v = CreateObject("Wia.Vector")
img.loadfile f
w = img.Width
h = img.Height
Set argbs = img.ARGBData
For i = 1 To h
For j = 1 To w
k = k + 1
argb = Hex(argbs(k))
'a = CInt("&H" & Mid(argb, 1, 2))
r = CInt("&H" & Mid(argb, 3, 2))
g = CInt("&H" & Mid(argb, 5, 2))
b = CInt("&H" & Mid(argb, 7, 2))
If r > 200 And r < 255 Then
If g > 200 And g < 255 Then
If b > 200 And b < 255 Then
r = 255: g = 255: b = 255
End If
End If
End If
'注意:rgb填写顺序从右往左←
v.Add RGB(b, g, r)
Next
Next
Set img = v.ImageFile(w, h)
img.SaveFile "d:\m1.jpg"
End Sub |
评分
-
1
查看全部评分
-
|