Объекты Windows Image Acquisition используются в этом коде.Приведенный ниже код создает объект wia.Vector , затем заполняет его, затем назначает его объекту wia.ImageFile и затем сохраняет его.Другими словами, это создает пустое изображение.Проблема в том, что он работает, только если изображение размером 2х2 пикселя.Кто-нибудь может сказать мне, почему?
Sub main()
Dim v As Object
Dim img As Object
Dim bytes() As Byte
Dim sFile As String
Dim d As Long
Set img = CreateObject("wia.ImageFile")
Set v = CreateObject("wia.Vector")
'The image is a square and the dimension for both sides is d
'If I change the value of d to ,let's say, 4
'the following error is generated.
'-----------------------------
'Run-time error '-2147024809(80070057)':
'The parameter is incorrect
'---------------------------------
d = 2
sFile = Application.CurrentProject.Path & "\Test.bmp"
bytes = StrConv(String(d ^ 2, Chr(255)), vbUnicode)
v.binarydata = bytes
Set img = v.ImageFile(d, d)'This is the line that raises the error
img.Savefile sFile
End Sub