BBjImage::getBytes

Description

In BBj 11.00 and higher, this method returns the raw image bytes from a BBjImage.

Syntax

Return Value

Method

byte[]

getBytes(string format)

Parameters

Variable

Description

format

Name of a standard image format (bmp, gif, jpeg, png, tiff, wbmp)

Return Value

Returns the raw image bytes in the requested format.

Remarks

Methods that return byte[] can usually be treated as if they returned string, because BBj automatically handles the conversion. However, when that byte[] value is directly assigned to an object variable or passed to a Java method, BBj skips the conversion and the raw internal byte[] format is used. You can always use the STR() function to explicitly convert the byte[] value to a string.

Example

rem ' Signature capture 
         sample
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
x = 50, y = 50, w = 400, 
         h = 250, title$ = "Signature"
window! = sysgui!.addWindow(x,y,w,h,title$,$00090883$,$$)
window!.setCallback(window!.ON_CLOSE,"eoj")
menu! = window!.addMenuBar()
file! = menu!.addMenu(100,"&File")
wipe! = file!.addMenuItem(101,"&New")
wipe!.setCallback(wipe!.ON_MENU_ITEM_SELECT,"wipe")
save! = file!.addMenuItem(102,"Save 
         &As...")
save!.setCallback(wipe!.ON_MENU_ITEM_SELECT,"save")
exit! = file!.addMenuItem(199,"E&xit")
exit!.setCallback(exit!.ON_MENU_ITEM_SELECT,"eoj")
print (sysgui)'clear'(255,255,240)
print (sysgui)'pencolor'(0,0,255)
print (sysgui)'penwidth'(3)
print (sysgui)'scribble'(1)
print (sysgui)'track'(0)
format$ = "png"
process_events
eoj:
release
wipe:
  print (sysgui)'clear'
return
save:
  file$ = "Signature."+format$
  file$ = filesave("Save 
         Signature",dsk("")+dir(""),file$,"")
  if pos("::"=file$) 
         then return
  file! = new 
         java.io.File(file$)
  file$ = file!.getCanonicalPath()
  path! = file!.getCanonicalPath().toLowerCase()
  if path!.endsWith(".gif") 
         then format$ = "gif"
  if path!.endsWith(".png") 
         then format$ = "png"
  if path!.endsWith(".jpg") 
         then format$ = "jpg"
  if path!.endsWith(".jpeg") 
         then format$ = "jpeg"
  image! = window!.getDrawPanelImage()
  image$ = image!.getBytes(format$,err=failed)
  image = unt
  open (image,mode="O_CREATE,O_TRUNC")file$
  writerecord 
         (image)image$
  close (image)
  i = msgbox(file$,0,"Signature 
         image file created")
return
failed:
  i = msgbox(errmes(-1),16,"Signature 
         image file failed")
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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