Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

GraphicImage.write()

Write an image out to the client browser

Syntax

GraphicImage = GraphicImage.write(format, quality)

Parameters

The 'GraphicImage.write' method takes 2 parameters:

Name Type/Value Range/Length Description
formatstring  Required. Type of the image to write (mime-type)
qualitynumber  Optional.

An optional 'quality' for the resulting image. This currently is only used if the type is specified as 'image/jpeg' and is used to specify the level of compression (and hence file size) of the resulting image.

For JPEG images, ommit this parameter to use the default quality (usually fine). Otherwise specify a postive interger between 0 (lowest quality) to 95 (highest quality).


Results

The 'GraphicImage.write' method returns GraphicImage:

Type/Value Range/Length Description
GraphicImage   Returns a reference to 'this' if the operation succeeds, otherwise throws an exception.

Remarks

This method tells Whitebeam to send the content of the image object to the client browser in the format specified.

This method is the most efficient way to send the image to the browser and avoids unnecessary copying of data.

Note : for application that need to generate the same image frequently it's worth considering saving the resulting image, either in the file system or to the file template, rather than regenerate each time.

The mime-type should be one of the following external formats :

  • image/jpeg
    A JPEG format image.
  • image/gif
    A palette based 256 colour GIF image.
  • image/png
    A PNG format image.

Example

  // Load an image then create a smaller thumbnail to send to the browser
  var src= new GraphicImage
  src.make('/images/myBigImage.jpg','image/jpeg');

  // Create a smaller thumbnail
  var thumb = (new GraphicImage).create(100,100);

  thumb.copyRect(srcImage,null,{z:0, y:0, w:100, h:100});

  rb.page.setMimeType('image/jpeg');
  thumb.write(thumb, 'image/jpeg');
        
Whitebeam release 1.3.36
(loadtime : 13ms)