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
-
(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-1You should also change the order of dimensions in your array to:
ReDim ImBuf(Area.Top To Area.Bottom,Area.Left To Area.Right) As Integer0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions