org.apache.poi.hssf.usermodel.HSSFPicture.resize()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(352)

本文整理了Java中org.apache.poi.hssf.usermodel.HSSFPicture.resize()方法的一些代码示例,展示了HSSFPicture.resize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFPicture.resize()方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFPicture
类名称:HSSFPicture
方法名:resize

HSSFPicture.resize介绍

[英]Reset the image to the dimension of the embedded image

Please note, that this method works correctly only for workbooks with default font size (Arial 10pt for .xls). If the default font is changed the resized image can be streched vertically or horizontally.
[中]将图像重置为嵌入图像的尺寸
请注意,此方法仅适用于默认字体大小(Arial 10pt代表.xls)的工作簿。如果更改默认字体,则可以垂直或水平拉伸调整大小的图像。

代码示例

代码示例来源:origin: org.apache.poi/poi

/**
 * Resize the image proportionally.
 *
 * @see #resize(double, double)
 */
@Override
public void resize(double scale) {
  resize(scale,scale);
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Reset the image to the dimension of the embedded image
 * 
 * <p>
 * Please note, that this method works correctly only for workbooks
 * with default font size (Arial 10pt for .xls).
 * If the default font is changed the resized image can be streched vertically or horizontally.
 * </p>
 */
@Override
public void resize(){
  resize(Double.MAX_VALUE);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * Reset the image to the original size.
 * 
 * <p>
 * Please note, that this method works correctly only for workbooks
 * with default font size (Arial 10pt for .xls).
 * If the default font is changed the resized image can be streched vertically or horizontally.
 * </p>
 */
public void resize(){
  resize(1.0);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Reset the image to the original size.
 * 
 * <p>
 * Please note, that this method works correctly only for workbooks
 * with default font size (Arial 10pt for .xls).
 * If the default font is changed the resized image can be streched vertically or horizontally.
 * </p>
 */
public void resize(){
  resize(1.0);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Reset the image to the dimension of the embedded image
 * 
 * <p>
 * Please note, that this method works correctly only for workbooks
 * with default font size (Arial 10pt for .xls).
 * If the default font is changed the resized image can be streched vertically or horizontally.
 * </p>
 */
@Override
public void resize(){
  resize(Double.MAX_VALUE);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Resize the image proportionally.
 *
 * @see #resize(double, double)
 */
@Override
public void resize(double scale) {
  resize(scale,scale);
}

代码示例来源:origin: cuba-platform/yarg

@Override
public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) {
  try {
    Image image = new Image(paramValue, paramsMatcher);
    if (image.isValid()) {
      HSSFSheet sheet = resultCell.getSheet();
      HSSFWorkbook workbook = sheet.getWorkbook();
      int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG);
      CreationHelper helper = workbook.getCreationHelper();
      ClientAnchor anchor = helper.createClientAnchor();
      anchor.setCol1(resultCell.getColumnIndex());
      anchor.setRow1(resultCell.getRowIndex());
      anchor.setCol2(resultCell.getColumnIndex());
      anchor.setRow2(resultCell.getRowIndex());
      if (patriarch == null) {
        throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName()));
      }
      HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
      Dimension size = ImageUtils.getDimensionFromAnchor(picture);
      double actualHeight = size.getHeight() / EMU_PER_PIXEL;
      double actualWidth = size.getWidth() / EMU_PER_PIXEL;
      picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight);
    }
  } catch (IllegalArgumentException e) {
    throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e);
  }
}

代码示例来源:origin: com.haulmont.yarg/yarg

@Override
public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) {
  try {
    Image image = new Image(paramValue, paramsMatcher);
    if (image.isValid()) {
      HSSFSheet sheet = resultCell.getSheet();
      HSSFWorkbook workbook = sheet.getWorkbook();
      int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG);
      CreationHelper helper = workbook.getCreationHelper();
      ClientAnchor anchor = helper.createClientAnchor();
      anchor.setCol1(resultCell.getColumnIndex());
      anchor.setRow1(resultCell.getRowIndex());
      anchor.setCol2(resultCell.getColumnIndex());
      anchor.setRow2(resultCell.getRowIndex());
      if (patriarch == null) {
        throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName()));
      }
      HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
      Dimension size = ImageUtils.getDimensionFromAnchor(picture);
      double actualHeight = size.getHeight() / EMU_PER_PIXEL;
      double actualWidth = size.getWidth() / EMU_PER_PIXEL;
      picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight);
    }
  } catch (IllegalArgumentException e) {
    throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e);
  }
}

代码示例来源:origin: org.apache.poi/poi-examples

private static void drawSheet5( HSSFSheet sheet5, HSSFWorkbook wb ) throws IOException
{
  // Create the drawing patriarch.  This is the top level container for
  // all shapes. This will clear out any existing shapes for that sheet.
  HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
  HSSFClientAnchor anchor;
  anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
  anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE );
  patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
  anchor = new HSSFClientAnchor(0,0,0,255,(short)4,2,(short)5,7);
  anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE );
  patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4edited.png", wb ));
  anchor = new HSSFClientAnchor(0,0,1023,255,(short)6,2,(short)8,7);
  anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE );
  HSSFPicture picture = patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4s.png", wb ));
  //Reset the image to the original size.
  picture.resize();
  picture.setLineStyle( HSSFShape.LINESTYLE_DASHDOTGEL );
}

相关文章