コード例 #1
0
  /**
   * @param s
   * @param fill
   * @return
   */
  public Bitmap getImage(String s, int fill) {
    // check image has for image
    Bitmap image = images.get(s);
    if (image != null) {
      return image;
    }
    // check xobjects for stream
    Stream st = (Stream) library.getObject(xobjects, s);
    if (st == null) {
      return null;
    }
    // return null if the xobject is not an image
    if (!st.isImageSubtype()) {
      return null;
    }
    // lastly return the images.
    try {
      image = st.getImage(fill, this, true);
    } catch (Exception e) {
      logger.log(Level.FINE, "Error getting image by name: " + s, e);
    }

    if (image != null && !st.isImageMask()) {
      images.put(s, image);
    }
    return image;
  }
コード例 #2
0
  public void dispose(boolean cache) {
    /*
    System.out.println("Resources.dispose()  cache: " + cache);
    try { throw new RuntimeException("MARK"); } catch(Exception e) {
        StackTraceElement[] ste = e.getStackTrace();
        for(int i = 1; i < Math.min(20,ste.length); i++)
            System.out.println("  " + ste[i].getClassName() + "." + ste[i].getMethodName() + " : " + ste[i].getLineNumber());
    }
    */
    // remove all images.
    if (images != null) {
      Enumeration shapeContent = images.elements();
      // find all shapes that are images
      while (shapeContent.hasMoreElements()) {
        Object image = shapeContent.nextElement();
        if (image instanceof Bitmap) {
          Bitmap tmp = (Bitmap) image;
          tmp.recycle();
        }
      }
      // clear hash to free max memory
      images.clear();
    }
    // NOTE: Make sure not to clear fonts, color spaces, pattern,
    // or extGStat's as this hold reverences to object not the actual
    // object. The only images contain object with a lot of memory

    if (xobjects != null) {
      Enumeration xobjectContent = xobjects.elements();
      while (xobjectContent.hasMoreElements()) {
        Object tmp = xobjectContent.nextElement();
        if (tmp instanceof Stream) {
          Stream stream = (Stream) tmp;
          stream.dispose(cache);
        }
        if (tmp instanceof Reference) {
          Object reference = library.getObject((Reference) tmp);
          if (reference instanceof Form) {
            Form form = (Form) reference;
            form.dispose(cache);
          }
          if (reference instanceof Stream) {
            Stream stream = (Stream) reference;
            stream.dispose(cache);
          }
        }
      }
    }
  }
コード例 #3
0
ファイル: ICCBased.java プロジェクト: CyberReveal/icepdf511
 public ICCBased(Library l, Stream h) {
   super(l, h.getEntries());
   iccColorCache3B = new ConcurrentHashMap<Integer, Color>();
   iccColorCache4B = new ConcurrentHashMap<Integer, Color>();
   numcomp = h.getInt(N_KEY);
   switch (numcomp) {
     case 1:
       alternate = new DeviceGray(l, null);
       break;
     case 3:
       alternate = new DeviceRGB(l, null);
       break;
     case 4:
       alternate = new DeviceCMYK(l, null);
       break;
   }
   stream = h;
 }
コード例 #4
0
ファイル: ICCBased.java プロジェクト: CyberReveal/icepdf511
  public synchronized void init() {
    if (inited) {
      return;
    }

    byte[] in;
    try {
      stream.init();
      in = stream.getDecodedStreamBytes(0);
      if (logger.isLoggable(Level.FINEST)) {
        String content = Utils.convertByteArrayToByteString(in);
        logger.finest("Content = " + content);
      }
      if (in != null) {
        ICC_Profile profile = ICC_Profile.getInstance(in);
        colorSpace = new ICC_ColorSpace(profile);
      }
    } catch (Exception e) {
      logger.log(Level.FINE, "Error Processing ICCBased Colour Profile", e);
    }
    inited = true;
  }