Java Code Examples for com.lowagie.text.Image#getDpiX()
The following examples show how to use
com.lowagie.text.Image#getDpiX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerArea.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void updateBackgroundImage( ) { BackgroundImageInfo bgi = boxStyle.getBackgroundImage( ); Image img = null; if ( bgi != null ) { img = bgi.getImageInstance( ); if ( img != null ) { int resolutionX = img.getDpiX( ); int resolutionY = img.getDpiY( ); if ( 0 == resolutionX || 0 == resolutionY ) { resolutionX = 96; resolutionY = 96; } float imageWidth = img.getPlainWidth( ) / resolutionX * 72; float imageHeight = img.getPlainHeight( ) / resolutionY * 72; if ( content != null ) { IStyle style = content.getComputedStyle( ); int ox = getDimensionValue( style .getProperty( IStyle.STYLE_BACKGROUND_POSITION_X ), ( width - (int) ( imageWidth * PDFConstants.LAYOUT_TO_PDF_RATIO ) ) ); int oy = getDimensionValue( style .getProperty( IStyle.STYLE_BACKGROUND_POSITION_Y ), ( height - (int) ( imageHeight * PDFConstants.LAYOUT_TO_PDF_RATIO ) ) ); bgi.setXOffset( ox ); bgi.setYOffset( oy ); } } } }
Example 2
Source File: PDFPage.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void drawBackgroundImage( float x, float y, float width, float height, float imageWidth, float imageHeight, int repeat, String imageUrl, byte[] imageData, float offsetX, float offsetY ) throws Exception { contentByte.saveState( ); clip( x, y, width, height ); PdfTemplate image = null; if ( imageUrl != null ) { if ( pageDevice.getImageCache( ).containsKey( imageUrl ) ) { image = pageDevice.getImageCache( ).get( imageUrl ); } } if ( image == null ) { Image img = Image.getInstance( imageData ); if ( imageHeight == 0 || imageWidth == 0 ) { int resolutionX = img.getDpiX( ); int resolutionY = img.getDpiY( ); if ( 0 == resolutionX || 0 == resolutionY ) { resolutionX = 96; resolutionY = 96; } imageWidth = img.getPlainWidth( ) / resolutionX * 72; imageHeight = img.getPlainHeight( ) / resolutionY * 72; } image = contentByte.createTemplate( imageWidth, imageHeight ); image.addImage( img, imageWidth, 0, 0, imageHeight, 0, 0 ); if ( imageUrl != null && image != null ) { pageDevice.getImageCache( ).put( imageUrl, image ); } } boolean xExtended = ( repeat & BackgroundImageInfo.REPEAT_X ) == BackgroundImageInfo.REPEAT_X; boolean yExtended = ( repeat & BackgroundImageInfo.REPEAT_Y ) == BackgroundImageInfo.REPEAT_Y; imageWidth = image.getWidth( ); imageHeight = image.getHeight( ); float originalX = offsetX; float originalY = offsetY; if ( xExtended ) { while ( originalX > 0 ) originalX -= imageWidth; } if ( yExtended ) { while ( originalY > 0 ) originalY -= imageHeight; } float startY = originalY; do { float startX = originalX; do { drawImage( image, x + startX, y + startY, imageWidth, imageHeight ); startX += imageWidth; } while ( startX < width && xExtended ); startY += imageHeight; } while ( startY < height && yExtended ); contentByte.restoreState( ); }