Java Code Examples for org.apache.poi.hssf.model.InternalWorkbook#getBSERecord()

The following examples show how to use org.apache.poi.hssf.model.InternalWorkbook#getBSERecord() . 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: HSSFPicture.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return picture data for this shape
 *
 * @return picture data for this shape or {@code null} if picture wasn't embedded, i.e. external linked
 */
@Override
public HSSFPictureData getPictureData(){
    int picIdx = getPictureIndex();
    if (picIdx == -1) {
        return null;
    }
    
    HSSFPatriarch patriarch = getPatriarch();
    HSSFShape parent = getParent();
    while(patriarch == null && parent != null) {
        patriarch = parent.getPatriarch();
        parent = parent.getParent();
    }
    if(patriarch == null) {
        throw new IllegalStateException("Could not find a patriarch for a HSSPicture");
    }

    InternalWorkbook iwb = patriarch.getSheet().getWorkbook().getWorkbook();
    EscherBSERecord bse = iwb.getBSERecord(picIdx);
	EscherBlipRecord blipRecord = bse.getBlipRecord();
	return new HSSFPictureData(blipRecord);
}
 
Example 2
Source File: HSSFPicture.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the dimension of the embedded image in pixel
 *
 * @return image dimension in pixels
 */
@Override
public Dimension getImageDimension(){
    InternalWorkbook iwb = getPatriarch().getSheet().getWorkbook().getWorkbook();
    EscherBSERecord bse = iwb.getBSERecord(getPictureIndex());
    byte[] data = bse.getBlipRecord().getPicturedata();
    int type = bse.getBlipTypeWin32();
    return ImageUtils.getImageDimension(new ByteArrayInputStream(data), type);
}