BBjMenuItem::getImageHeight

Description

In BBj 15.0 and higher, this BBjMenuItem method returns the height in pixels of the menu item image.

Syntax

Return Value

Method

int

getImageHeight()

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 height is returned, or 0 if the menu item has no image.

Remarks

None.

Example

rem ' BBjMenuItem::getImageHeight

image$ = "https://www.basis.cloud/images/basislogo.jpg"
print "Image: ",image$
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
imagemanager! = sysgui!.getImageManager()
image! = javax.imageio.ImageIO.read(newjava.net.URL(image$))
os! = new java.io.ByteArrayOutputStream()
javax.imageio.ImageIO.write(image!,"jpg",os!)
bytes! = os!.toByteArray()
image! = imagemanager!.loadImageFromBytes(bytes!)
print "Image width:",image!.getWidth()
print "Image height:",image!.getHeight()
window! = sysgui!.addWindow(100,100,250,225,"getImageHeight",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
menubar! = window!.addMenuBar()
menu! = menubar!.addMenu(-100,"&Menu")
menu!.setImageSize(image!.getWidth()/4,image!.getHeight()/4)
menu!.setImage(image!)
menuitem! = menu!.addMenuItem(-101,"MenuItem")
menuitem!.setImageSize(image!.getWidth()/4,image!.getHeight()/4)
menuitem!.setImage(image!)
menuitem!.setCallback(menuitem!.ON_MENU_ITEM_SELECT,"resetImageSize")
unscaled! = window!.addButton(101,25,25,200,100,"",$$)
unscaled!.setImage(image!)
scaled! = window!.addButton(102,25,150,200,50,"ScaledImage",$$)
scaled!.setImage(image!)
scaled!.setImageSize(image!.getWidth()/2,image!.getHeight()/2)
process_events

eoj:
release

resetImageSize:
    if menuitem!.getImageHeight()>16then
        menuitem!.setImageSize(image!.getWidth()/4,image!.getHeight()/4)
    else
        menuitem!.clearImageSize()
    endif
    print "MenuItem ImageSize:",
    print menuitem!.getImageWidth(),
    print menuitem!.getImageHeight()

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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