Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Image By Building byte array in Expression (BIRT)

< To: Report Developer Examples (BIRT)
This example has no Bugzilla entry.


This example demonstrates how to include an image by creating a byte array in an expression.

BIRT Version Compatibility

This example was built and tested with BIRT 2.1.2.

Example Files

This example has no example attachment.


BIRT Image elements support URLs, Embedded images within the report, Images from resource folders, and Dynamic images (BLOB) types usually from databases. Another way of using the Dynamic image is construct your own byte array within the birt expression. This can also be done within a Java Event Handler on the image element.
When selecting the Dynamic image radial in the Image editor, the expression return value needs to be a byte array which contains the data for the image. As an example the following expression will return a working image. If you are using BIRT 2.2 or greater add the expression to a binding entry. This can be done by selecting the image element and then select the binding tab. Select add and enter a name and the expression. The data type should be set to any.

var file = new File("c:/temp/test.png");
var ist = new FileInputStream(file);
var lengthi = file.length();
bytesa = new ByteArrayOutputStream( lengthi);
var c;
while(( != -1){

If you are using an SWT ImageLoader you can build an expression similar to:


imgl = new ImageLoader();
baos = new ByteArrayOutputStream();, SWT.IMAGE_PNG);
myout = baos.toByteArray();


Please enter comments below by selecting the edit icon to the right. You will need a Bugzilla account to add comments.

Back to the top