2014-12-11 1 views
3

우리는 갤러리 기능이있는 응용 프로그램을 가지고 있으며 이미지를 파워 포인트 프레젠테이션으로 내보내고 싶습니다. 이 작업을 수행 할 수 있었지만 이미지가 다른 크기와 방향으로 표시되면 거의 항상 이미지 범위가 ppt 슬라이드에서 사라집니다. 어떻게 이미지 크기를 조정할 수 있습니까? 물리적으로 크기를 조정하고 싶지 않고 크기를 슬라이드에 추가하기 만하면됩니다. 그리고 그것을 슬라이드 위에 놓습니다.Apache POI ppt. Slide에서 이미지 크기를 조정하고 가운데에 맞추는 방법

감사합니다.

+0

나는 동일한 문제에 직면 해있다. –

답변

0

슬라이드에 추가하기 전에 이미지의 크기를 조정할 수 있습니다.

private static byte[] resizeImage(byte[] fileData, Integer img_width, Integer img_height) throws IOException{ 
    ByteArrayInputStream in = new ByteArrayInputStream(fileData); 

    BufferedImage originalImage = ImageIO.read(in); 
    int type = originalImage.getType() == 0? BufferedImage.TYPE_INT_ARGB 
      : originalImage.getType(); 

    if(img_height == 0){ 
     img_height = originalImage.getHeight(); 
    } 

    BufferedImage resizedImage = new BufferedImage(img_width, img_height, type); 
    Graphics2D g = resizedImage.createGraphics(); 
    g.drawImage(originalImage, 0, 0, img_width, img_height, null); 
    g.dispose(); 

    ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 
    ImageIO.write(resizedImage, "png", buffer); 
    return buffer.toByteArray(); 
} 
관련 문제