Home > Articles > Data

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Getting a dynamic image from a Microsoft Access database

Microsoft Access stores an image as an array of image bytes preceded by 78 bytes of header information. BIRT does not use the header information. To get a dynamic image from an Access database, you must copy the image data from the database field into a Java array of type byte. You perform this copy operation in the dynamic image expression.

The following script is an example of how to copy the image data from the Access image field into a byte array that BIRT can use:

var picBytes = row["Picture"];
var offset = 78;
var lengthOfImage = picBytes.length - offset;
var imgBytes =
   java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE,
   lengthOfImage);
java.lang.System.arraycopy(picBytes, offset, imgBytes, 0,
   lengthOfImage);
imgBytes;
  • + Share This
  • 🔖 Save To Your Account