CorelDraw 中的 VBA 有任何限制吗?我需要对图像的每个像素执行一些检查。代码如下:
'For x = 0 To sh.Bitmap.Image.Height - 1
Do While x < sh.Bitmap.Image.Height - 1
'For y = 0 To sh.Bitmap.Image.Width - 1
Do While y < sh.Bitmap.Image.Width - 1
do some stuff
'Next y
y = y + 1
Loop
'Next x
x = x + 1
Loop
和错误(DO WHILE 和 FOR 循环也是如此):
有人知道有什么解决办法吗?
完整代码
'Dim bm As Bitmap
Dim x As Long, y As Long
Dim kolor As Color
x = 0
y = 0
Dim whitePix As Boolean
whitePix= False
'For x = 0 To sh.Bitmap.Image.Height - 1
Do While x < sh.Bitmap.Image.Height - 1
'For y = 0 To sh.Bitmap.Image.Width - 1
Do While y < sh.Bitmap.Image.Width - 1
Set kolor = sh.Bitmap.Image.Pixel(x, y)
'kolor = kolor.ConvertToCMYK
With kolor
If .Type = cdrColorCMYK Then
If kolor.CMYKBlack = 0 And .CMYKCyan = 0 And .CMYKMagenta = 0 And .CMYKYellow = 0 Then
whitePix = True
End If
ElseIf .Type = cdrColorRGB Then
If .RGBRed > 253 And .RGBGreen > 253 And .RGBBlue > 253 Then
whitePix = True
End If
End If
End With
'Next y
y = y + 1
Loop
'Next x
x = x + 1
Loop
sh = 形状
哪一行抛出该错误?我
问题是由声明循环限制的行引起的。当然,这取决于图像的大小(大于 300 x 300 像素)。