ImageGear Professional v18.2 > User Guide > Using ImageGear > Working with Gigabyte-Sized Images > Accessing Pixels of a Gigabyte-Sized Image |
ImageGear manages the use of memory mapped files internally. In most cases, the application does not need any additional code for working with memory mapped images, except for setting the global control parameters. However, if an application accesses individual pixels or rasters of a large image, ImageGear does not know when to flush the image's memory mapped file. In this case the application shall flush the memory mapped file explicitly, using IGPage Object.Flush Method:
Copy Code
|
|
---|---|
'Example: flushing the image after accessing 1000 rasters Dim pixArray as IGIntegerArray Dim curRaster as Integer curRaster = 0 'Get raster length Set pixArray = page. GetRasterCopy(0, IG_PIX_ACC_UNPACKED) For i = 0 To page.ImageHeight - 1 Set pixArray = page. GetRasterCopy(j, IG_PIX_ACC_UNPACKED) ' Some raster processing '... curRaster = curRaster + 1 If curRaster = 1000 Then page.Flush() curRaster = 0 End If Next |
A similar situation occurs when the application accesses image areas. Since areas can be small, even one automatic flush per area access operation can be too much, and can significantly degrade performance. ImageGear does not use automatic flushing in area access operations. Instead, the application shall flush the DIB after accessing one or several areas. If an area to be accessed is very large (hundreds of megabytes or more), we recommend splitting it into smaller areas and processing it sub-area by sub-area.
In order to minimize the amount of flushing, try to prefer a row-wise order of processing, as opposed to column-wise. For example, if you need to access an image area consisting of 10 sub-areas vertically and 10 sub-areas horizontally, do it as follows: