private byte [ ] [ ] getImageData ( Image image ) throws DocumentException { final int WMF_PLACEABLE_HEADER_SIZE = 22 ; final RtfByteArrayBuffer bab = new RtfByteArrayBuffer ( ) ; try { if ( imageType == Image . ORIGINAL_BMP ) { bab . append ( MetaDo . wrapBMP ( image ) ) ; } else { final byte [ ] iod = image . getOriginalData ( ) ; if ( iod == null ) { final InputStream imageIn = image . getUrl ( ) . openStream ( ) ; if ( imageType == Image . ORIGINAL_WMF ) { //remove the placeable header first for ( int k = 0 ; k < WMF_PLACEABLE_HEADER_SIZE ; k ++ ) { if ( imageIn . read ( ) < 0 ) throw new EOFException ( "while removing wmf placeable header" ) ; } } bab . write ( imageIn ) ; imageIn . close ( ) ; } else { if ( imageType == Image . ORIGINAL_WMF ) { //remove the placeable header bab . write ( iod , WMF_PLACEABLE_HEADER_SIZE , iod . length - WMF_PLACEABLE_HEADER_SIZE ) ; } else { bab . append ( iod ) ; } } } return bab . toByteArrayArray ( ) ; } catch ( IOException ioe ) { throw new DocumentException ( ioe . getMessage ( ) ) ; } }
Extracts the image data from the Image .