public void writeContent(final OutputStream result) throws IOException
    {
    	
        if(this.topLevelElement) {
            result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
            switch(alignment) {
                case Element.ALIGN_LEFT:
                    result.write(RtfParagraphStyle.ALIGN_LEFT);
                    break;
                case Element.ALIGN_RIGHT:
                    result.write(RtfParagraphStyle.ALIGN_RIGHT);
                    break;
                case Element.ALIGN_CENTER:
                    result.write(RtfParagraphStyle.ALIGN_CENTER);
                    break;
                case Element.ALIGN_JUSTIFIED:
                    result.write(RtfParagraphStyle.ALIGN_JUSTIFY);
                    break;
            }
        }
        result.write(OPEN_GROUP);
        result.write(PICTURE_GROUP);
        result.write(OPEN_GROUP);
        result.write(PICTURE);
        switch(imageType) {
        	case Image.ORIGINAL_JPEG:
        	    result.write(PICTURE_JPEG);
        		break;
        	case Image.ORIGINAL_PNG:
            case Image.ORIGINAL_GIF:
        	    result.write(PICTURE_PNG);
        		break;
        	case Image.ORIGINAL_WMF:
        	case Image.ORIGINAL_BMP:
        	    result.write(PICTURE_WMF);
        		break;
        }
        result.write(PICTURE_WIDTH);
        result.write(intToByteArray((int) width));
        result.write(PICTURE_HEIGHT);
        result.write(intToByteArray((int) height));
        if(this.document.getDocumentSettings().isWriteImageScalingInformation()) {
            result.write(PICTURE_SCALE_X);
            result.write(intToByteArray((int)(100 * plainWidth / width)));
            result.write(PICTURE_SCALE_Y);
            result.write(intToByteArray((int)(100 * plainHeight / height)));
        }
        if(this.document.getDocumentSettings().isImagePDFConformance()) {
            result.write(PICTURE_SCALED_WIDTH);
            result.write(intToByteArray((int) (plainWidth * RtfElement.TWIPS_FACTOR)));
            result.write(PICTURE_SCALED_HEIGHT);
            result.write(intToByteArray((int) (plainHeight * RtfElement.TWIPS_FACTOR)));
        } else {
            if(this.width != this.plainWidth || this.imageType == Image.ORIGINAL_BMP) {
                result.write(PICTURE_SCALED_WIDTH);
                result.write(intToByteArray((int) (plainWidth * PIXEL_TWIPS_FACTOR)));
            }
            if(this.height != this.plainHeight || this.imageType == Image.ORIGINAL_BMP) {
                result.write(PICTURE_SCALED_HEIGHT);
                result.write(intToByteArray((int) (plainHeight * PIXEL_TWIPS_FACTOR)));
            }
        }

        if(this.document.getDocumentSettings().isImageWrittenAsBinary()) {
        	//binary
        	result.write('\n');
        	result.write(PICTURE_BINARY_DATA);
        	result.write(intToByteArray(imageDataSize()));
            result.write(DELIMITER);
            if(result instanceof RtfByteArrayBuffer) {
            	((RtfByteArrayBuffer)result).append(imageData);
            } else {
            	for(int k = 0; k < imageData.length; k++) {
					result.write(imageData[k]);
				}
            }
        } else {
        	//hex encoded
            result.write(DELIMITER);
        	result.write('\n');
        	writeImageDataHexEncoded(result);
        }
        
        result.write(CLOSE_GROUP);
        result.write(CLOSE_GROUP);
        if(this.topLevelElement) {
            result.write(RtfParagraph.PARAGRAPH);
            result.write(RtfParagraph.PARAGRAPH);
        }
        result.write('\n');    	
    }
public void writeContent ( final OutputStream result ) throws IOException { if ( this . topLevelElement ) { result . write ( RtfParagraph . PARAGRAPH_DEFAULTS ) ; switch ( alignment ) { case Element . ALIGN_LEFT : result . write ( RtfParagraphStyle . ALIGN_LEFT ) ; break ; case Element . ALIGN_RIGHT : result . write ( RtfParagraphStyle . ALIGN_RIGHT ) ; break ; case Element . ALIGN_CENTER : result . write ( RtfParagraphStyle . ALIGN_CENTER ) ; break ; case Element . ALIGN_JUSTIFIED : result . write ( RtfParagraphStyle . ALIGN_JUSTIFY ) ; break ; } } result . write ( OPEN_GROUP ) ; result . write ( PICTURE_GROUP ) ; result . write ( OPEN_GROUP ) ; result . write ( PICTURE ) ; switch ( imageType ) { case Image . ORIGINAL_JPEG : result . write ( PICTURE_JPEG ) ; break ; case Image . ORIGINAL_PNG : case Image . ORIGINAL_GIF : result . write ( PICTURE_PNG ) ; break ; case Image . ORIGINAL_WMF : case Image . ORIGINAL_BMP : result . write ( PICTURE_WMF ) ; break ; } result . write ( PICTURE_WIDTH ) ; result . write ( intToByteArray ( ( int ) width ) ) ; result . write ( PICTURE_HEIGHT ) ; result . write ( intToByteArray ( ( int ) height ) ) ; if ( this . document . getDocumentSettings ( ) . isWriteImageScalingInformation ( ) ) { result . write ( PICTURE_SCALE_X ) ; result . write ( intToByteArray ( ( int ) ( 100 * plainWidth / width ) ) ) ; result . write ( PICTURE_SCALE_Y ) ; result . write ( intToByteArray ( ( int ) ( 100 * plainHeight / height ) ) ) ; } if ( this . document . getDocumentSettings ( ) . isImagePDFConformance ( ) ) { result . write ( PICTURE_SCALED_WIDTH ) ; result . write ( intToByteArray ( ( int ) ( plainWidth * RtfElement . TWIPS_FACTOR ) ) ) ; result . write ( PICTURE_SCALED_HEIGHT ) ; result . write ( intToByteArray ( ( int ) ( plainHeight * RtfElement . TWIPS_FACTOR ) ) ) ; } else { if ( this . width != this . plainWidth || this . imageType == Image . ORIGINAL_BMP ) { result . write ( PICTURE_SCALED_WIDTH ) ; result . write ( intToByteArray ( ( int ) ( plainWidth * PIXEL_TWIPS_FACTOR ) ) ) ; } if ( this . height != this . plainHeight || this . imageType == Image . ORIGINAL_BMP ) { result . write ( PICTURE_SCALED_HEIGHT ) ; result . write ( intToByteArray ( ( int ) ( plainHeight * PIXEL_TWIPS_FACTOR ) ) ) ; } } if ( this . document . getDocumentSettings ( ) . isImageWrittenAsBinary ( ) ) { result . write ( '\n' ) ; result . write ( PICTURE_BINARY_DATA ) ; result . write ( intToByteArray ( imageDataSize ( ) ) ) ; result . write ( DELIMITER ) ; if ( result instanceof RtfByteArrayBuffer ) { ( ( RtfByteArrayBuffer ) result ) . append ( imageData ) ; } else { for ( int k = 0 ; k < imageData . length ; k ++ ) { result . write ( imageData [ k ] ) ; } } } else { result . write ( DELIMITER ) ; result . write ( '\n' ) ; writeImageDataHexEncoded ( result ) ; } result . write ( CLOSE_GROUP ) ; result . write ( CLOSE_GROUP ) ; if ( this . topLevelElement ) { result . write ( RtfParagraph . PARAGRAPH ) ; result . write ( RtfParagraph . PARAGRAPH ) ; } result . write ( '\n' ) ; }
Writes the RtfImage content