Home Image-Pro Plus Automation with Macros
Options

Limit the image buffer size

(Originally posted by Geeda on 3/28/2006)

Hello everyone,

I am trying to do some specific pixel by pixel manipulation using IpDocGetArea and IpDocPutArea. Here is a snippet of my code

Dim iInfo As IPDOCINFO
Dim Row As Long
Dim Column As Long
Dim Area As RECT

ret = IpDocGet(GETDOCINFO, DOCSEL_ACTIVE, iInfo)
Area.Left = 1
Area.Top = 1
Area.Right = iInfo.Width-1
Area.Bottom = iInfo.Height-1

ReDim ImBuf(Area.Left To Area.Right, Area.Top To Area.Bottom) As Integer
ret = IpDocGetArea(DOCSEL_ACTIVE,Area,ImBuf(Area.Left,Area.Top),0)

For Row = Area.Top To Area.Bottom
For Column = Area.Left To Area.Right
ImBuf(Row, Column) = SomeValue
Next Column
Next Row

ret = IpDocPutArea(DOCSEL_ACTIVE,Area,ImBuf(Area.Left,Area.Top),0)
ret = IpAppUpdateDoc(DOCSEL_ACTIVE)

When I try to run the macro, Image-Pro crashes with the following messages:
ipwin32.exe - Application Error
The instruction at "0x0800c084" referenced memory at "0x0022a000". The memory could not be "written".

ipwin32.exe - Application Error
The instruction at "0x7c910de3" referenced memory at "0xfffffff8". The memory could not be "read".

I tried it with a very small rectange (10x10) and had no problems. The problems start when the area gets bigger, say 100

 

Comments

  • Options

    (Originally posted by YuriG on 3/28/2006)

    The crash was due to small buffer size reading the data. You should set left and top values to 0:
    Area.Left = 0
    Area.Top = 0
    Area.Right = iInfo.Width-1
    Area.Bottom = iInfo.Height-1

    You should also change the order of dimensions in your array to:
    ReDim ImBuf(Area.Top To Area.Bottom,Area.Left To Area.Right) As Integer

     

Sign In or Register to comment.