BBjImageManager::setCacheSize

Description

In BBj 7.0 and higher, this method sets the size of the BBjImageManager's internal cache of images.

Syntax

Return Value

Method

void

setCacheSize(int size)

Parameters

Variable

Description

size

The number of images to keep in memory.

Return Value

None.

Remarks

The default cache size is 32. Passing the argument '0' will prevent any images from being cached. If a program loads the same image from a file name multiple times, the bytes will be transferred to the ThinClient multiple times as well, and the ThinClient will maintain multiple references to that image.

Each interpreter maintains its own image cache. It may be necessary to reduce the cache size if large images are used.

This method only applies to programs that invoke BBjImageManager::loadImageFromFile() or that specify the "BITMAP=file.bmp" syntax in when setting the button text. If a program instead maintains a reference to a BBjImage object and subsequently uses that BBjImage in multiple controls (e.g., BBjButton::setImage() and BBjTabCtrl::setImageAt() ), the bytes for that BBjImage are only transferred to the ThinClient once.

To clear the current cache of images, use the following code:

oldCacheSize = imgMgr!.getCacheSize()
imgMgr!.setCacheSize(0)
imgMgr!.setCacheSize(oldCacheSize)

Example

myAPI! = BBjAPI()
mySysGui! = myAPI!.openSysGui("X0")
myWindow! = mySysGui!.addWindow(100, 100, 500, 400, $00090003$, $$)

rem ' Default image cache size is 32
man! = mySysGui!.getImageManager()

rem ' Add two buttons that use the same image.  These will share
rem ' the same image
b1! = myWindow!.addButton(101, 10, 10, 25, 25, "BITMAP=save.png")
b2! = myWindow!.addButton(102, 45, 10, 25, 25, "BITMAP=save.png")

rem ' Set the cache size to zero to clear the cache
man!.setCacheSize(0)

rem ' Use a distinct image on this button
b3! = myWindow!.addButton(103, 80, 10, 25, 25, "BITMAP=save.png")

See Also

BBjAPI

BBjSysGui

BBjImageManager

BBjImage

BBjImageManager::getCacheSize

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.