Examples of PictureData


Examples of org.apache.poi.hslf.usermodel.PictureData

     * Resize this picture to the default size.
     * For PNG and JPEG resizes the image to 100%,
     * for other types sets the default size of 200x200 pixels. 
     */
    public void setDefaultSize(){
        PictureData pict = getPictureData();
        if (pict  instanceof Bitmap){
            BufferedImage img = null;
            try {
                 img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
            }
            catch (IOException e){}
          catch (NegativeArraySizeException ne) {}
         
            if(img != null) {
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

        logger.log(POILogger.ERROR, "Problem reading picture: Invalid image type 0, on picture with length " + imgsize + ".\nYou document will probably become corrupted if you save it!");
        logger.log(POILogger.ERROR, "" + pos);
      } else {
        // Build the PictureData object from the data
        try {
          PictureData pict = PictureData.create(type - 0xF018);

                    // Copy the data, ready to pass to PictureData
                    byte[] imgdata = new byte[imgsize];
                    System.arraycopy(pictstream, pos, imgdata, 0, imgdata.length);
                    pict.setRawData(imgdata);

                    pict.setOffset(offset);
          _pictures.add(pict);
        } catch(IllegalArgumentException e) {
          logger.log(POILogger.ERROR, "Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!");
        }
      }
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

   */
  public int addPicture(PictureData img) {
    int offset = 0;

        if(_pictures.size() > 0){
            PictureData prev = _pictures.get(_pictures.size() - 1);
            offset = prev.getOffset() + prev.getRawData().length + 8;
        }
        img.setOffset(offset);
        _pictures.add(img);
        return offset;
   }
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

                System.arraycopy(pictstream, pos, imgdata, 0, imgdata.length);
              }
             
        // Build the PictureData object from the data
        try {
          PictureData pict = PictureData.create(type - 0xF018);
          pict.setRawData(imgdata);
          pict.setOffset(offset);
          p.add(pict);
        } catch(IllegalArgumentException e) {
          logger.log(POILogger.ERROR, "Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!");
        }
      }
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

     * Resize this picture to the default size.
     * For PNG and JPEG resizes the image to 100%,
     * for other types sets the default size of 200x200 pixels. 
     */
    public void setDefaultSize(){
        PictureData pict = getPictureData();
        if (pict  instanceof Bitmap){
            BufferedImage img = null;
            try {
                 img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
            }
            catch (IOException e){}
          catch (NegativeArraySizeException ne) {}
         
            if(img != null) {
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

    public void draw(Graphics2D graphics){
        AffineTransform at = graphics.getTransform();
        ShapePainter.paint(this, graphics);

        PictureData data = getPictureData();
        if (data  instanceof Bitmap){
            BufferedImage img = null;
            try {
                 img = ImageIO.read(new ByteArrayInputStream(data.getData()));
            }
            catch (Exception e){
                logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + data.getType());
                return;
            }
            Rectangle anchor = getAnchor();
            Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
            graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
        } else {
            logger.log(POILogger.WARN, "Rendering of metafiles is not yet supported. image.type: " + (data == null ? "NA" : data.getClass().getName()));
        }
        graphics.setTransform(at);
    }
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

            byte[] imgdata = new byte[imgsize];
            System.arraycopy(pictstream, pos, imgdata, 0, imgdata.length);

            try {
              PictureData pict = PictureData.create(type - 0xF018);
              pict.setRawData(imgdata);
              pict.setOffset(offset);
              p.add(pict);
            } catch(IllegalArgumentException e) {
              System.err.println("Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!");
            }
           
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

        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;
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

    /**
     * Resize this picture to the default size.
     */
    public void setDefaultSize(){
        PictureData pict = getPictureData();
        if (pict  instanceof Bitmap){
            BufferedImage img = null;
            try {
                 img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
            }
            catch (IOException e){}
          catch (NegativeArraySizeException ne) {}
         
            if(img != null) {
View Full Code Here

Examples of org.apache.poi.hslf.usermodel.PictureData

     * Resize this picture to the default size.
     * For PNG and JPEG resizes the image to 100%,
     * for other types sets the default size of 200x200 pixels. 
     */
    public void setDefaultSize(){
        PictureData pict = getPictureData();
        if (pict  instanceof Bitmap){
            BufferedImage img = null;
            try {
                 img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
            }
            catch (IOException e){}
          catch (NegativeArraySizeException ne) {}
         
            if(img != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.