Examples of PictureData


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

        SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();

        Picture pict = new Picture(-1); //index to non-existing picture data
        pict.setSheet(slide);
        PictureData data = pict.getPictureData();
        assertNull(data);

        BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = img.createGraphics();
        pict.draw(graphics);
View Full Code Here

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

                Color color = f.getForegroundColor();
                graphics.setPaint(color);
                graphics.fill(anchor);
                break;
            case Fill.FILL_PICTURE:
                PictureData data = f.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;
                    }
                    Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
                    graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
View Full Code Here

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

        SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();

        Picture pict = new Picture(-1); //index to non-existing picture data
        pict.setSheet(slide);
        PictureData data = pict.getPictureData();
        assertNull(data);

        BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = img.createGraphics();
        pict.draw(graphics);
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

        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

     }
    
     // Add the new picture in
      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

        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
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.