[VBA][CorelDraw X7] Do While ... 循环(和 For ... next)的限制?

问题描述 投票:0回答:1

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 循环也是如此):

图片

有人知道有什么解决办法吗?

vba coreldraw
1个回答
0
投票

完整代码

 '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 像素)。

© www.soinside.com 2019 - 2024. All rights reserved.