BBjButton::getImageWidth

Description

In BBj 15.0 and higher, this BBjButton method returns the width in pixels of the button image.

Syntax

Return Value

Method

int

getImageWidth()

Parameters

None.

Return Value

If the image size has been set using setImageSize, that value is returned. If no image size has been set, the inherent image width is returned, or 0 if the menu item has no image.

Example

Copy

BBjButton::getImageWidth Example

REM ' BBjButton::getImageWidth
image$ = "https://basis.com/sites/basis.com/files/amity_island_logo.jpg"
msg$ = "Image: "+image$ + $0a$
sysgui = UNT
OPEN (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
imagemanager! = sysgui!.getImageManager()
image! = javax.imageio.ImageIO.read(new java.net.URL(image$))
os! = new java.io.ByteArrayOutputStream()
javax.imageio.ImageIO.write(image!,"jpg",os!)
bytes! = os!.toByteArray()
image! = imagemanager!.loadImageFromBytes(bytes!)
msg$ = msg$ + "Image width: "+str(image!.getWidth()) + $0a$
msg$ = msg$ + "Image height: "+str(image!.getHeight()) + $0a$
window! = sysgui!.addWindow(100,100,250,225,"setImageSize",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
unscaled! = window!.addButton(101,25,25,200,100,"",$$)
unscaled!.setImage(image!)
scaled! = window!.addButton(102,25,150,200,50,"Scaled Image",$$)
scaled!.setImage(image!)
msg$ = msg$ + $0a$
msg$ = msg$ + "Default image size:" + $0a$
msg$ = msg$ + "getImageWidth: "+str(scaled!.getImageWidth()) + $0a$
msg$ = msg$ + "getImageHeight: "+str(scaled!.getImageHeight()) + $0a$
scaled!.setImageSize(image!.getWidth()/2,image!.getHeight()/2)
msg$ = msg$ + $0a$
msg$ = msg$ + "Scaled image size:" + $0a$
msg$ = msg$ + "getImageWidth: "+str(scaled!.getImageWidth()) + $0a$
msg$ = msg$ + "getImageHeight: "+str(scaled!.getImageHeight()) + $0a$
PRINT msg$
i = msgbox(msg$,0,"BBjButton::getImageWidth")
PROCESS_EVENTS

eoj:
RELEASE

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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