本文整理汇总了Java中org.apache.poi.hslf.usermodel.SlideShow.getPictureData方法的典型用法代码示例。如果您正苦于以下问题:Java SlideShow.getPictureData方法的具体用法?Java SlideShow.getPictureData怎么用?Java SlideShow.getPictureData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hslf.usermodel.SlideShow
的用法示例。
在下文中一共展示了SlideShow.getPictureData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPictureData
import org.apache.poi.hslf.usermodel.SlideShow; //导入方法依赖的package包/类
/**
* Returns the picture data for this picture.
*
* @return the picture data for this picture.
*/
public PictureData getPictureData(){
SlideShow ppt = getSheet().getSlideShow();
PictureData[] pict = ppt.getPictureData();
EscherBSERecord bse = getEscherBSERecord();
if (bse == null){
logger.log(POILogger.ERROR, "no reference to picture data found ");
} else {
for ( int i = 0; i < pict.length; i++ ) {
if (pict[i].getOffset() == bse.getOffset()){
return pict[i];
}
}
logger.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset());
}
return null;
}
示例2: handleSlideEmbeddedPictures
import org.apache.poi.hslf.usermodel.SlideShow; //导入方法依赖的package包/类
private void handleSlideEmbeddedPictures(SlideShow slideshow,
XHTMLContentHandler xhtml) throws TikaException, SAXException,
IOException {
for (PictureData pic : slideshow.getPictureData()) {
String mediaType = null;
switch (pic.getType()) {
case Picture.EMF:
mediaType = "application/x-emf";
break;
case Picture.JPEG:
mediaType = "image/jpeg";
break;
case Picture.PNG:
mediaType = "image/png";
break;
case Picture.WMF:
mediaType = "application/x-msmetafile";
break;
case Picture.DIB:
mediaType = "image/bmp";
break;
}
try {
handleEmbeddedResource(TikaInputStream.get(pic.getData()), null, null,
mediaType, xhtml, false);
} catch (Exception e) {
// log as info
}
}
}
示例3: getPictureData
import org.apache.poi.hslf.usermodel.SlideShow; //导入方法依赖的package包/类
/**
* <code>PictureData</code> object used in a texture, pattern of picture fill.
*/
public PictureData getPictureData(){
EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if (p == null) return null;
SlideShow ppt = shape.getSheet().getSlideShow();
PictureData[] pict = ppt.getPictureData();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
java.util.List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue();
if (idx == 0){
logger.log(POILogger.WARN, "no reference to picture data found ");
} else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
for ( int i = 0; i < pict.length; i++ ) {
if (pict[i].getOffset() == bse.getOffset()){
return pict[i];
}
}
}
return null;
}
示例4: main
import org.apache.poi.hslf.usermodel.SlideShow; //导入方法依赖的package包/类
public static void main(String args[]) throws IOException {
if (args.length < 1) {
System.err.println("Usage:");
System.err.println("\tImageExtractor <file>");
return;
}
SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0]));
//extract all pictures contained in the presentation
PictureData[] pdata = ppt.getPictureData();
for (int i = 0; i < pdata.length; i++) {
PictureData pict = pdata[i];
// picture data
byte[] data = pict.getData();
int type = pict.getType();
String ext;
switch (type) {
case Picture.JPEG:
ext = ".jpg";
break;
case Picture.PNG:
ext = ".png";
break;
case Picture.WMF:
ext = ".wmf";
break;
case Picture.EMF:
ext = ".emf";
break;
case Picture.PICT:
ext = ".pict";
break;
case Picture.DIB:
ext = ".dib";
break;
default:
continue;
}
FileOutputStream out = new FileOutputStream("pict_" + i + ext);
out.write(data);
out.close();
}
}