Saving out multi-page TIFF files to a byte array in Java

Saving images to memory on the fly enhances the speed, usability and security of your client-server imaging application by eliminating the necessity of local drive access. Snowbound has expanded this capability in RasterMaster 8.0 to allow the saving of multi-page TIFF files to a byte array in Java. Here's an example:

 byte[] saveAs_Tiff_OutputByteArray(String filename)

{

Snowbnd snbd = new Snowbnd();

File input = new File(filename);

int pages = snbd.IMGLOW_get_pages(input.toString());

byte imagebytearray[] = new byte[(int)(input.length()*3)];//Three 

times the size of the input image

int outputsize = 0;

for (int pg=0; pg<pages; pg++)

{

snbd.IMG_decompress_bitmap(input.toString(),pg); //Decompress each page

outputsize = 

snbd.IMG_save_bitmap(imagebytearray,Snow.Defines.TIFF_G4_FAX);//Save to tmp 

byte array

}

//Correct byte array size

byte imagedata[] = new byte[outputsize];

System.arraycopy(imagebytearray,0,imagedata,0,outputsize);

return imagedata; //corrected data

}

Category:

Online Demo