Package net.sf.jpluck.palm.bitmap

Examples of net.sf.jpluck.palm.bitmap.Bitmap


                    addCompositeImage(resource, embeddedImage, embeddedSettings, false);
                } else {
                    embeddedImage = ImageConverter.rescale(image, embeddedSettings.getBitDepth(),
                                                           embeddedSettings.getMaxWidth(),
                                                           embeddedSettings.getMaxHeight());
                    Bitmap bitmap = ImageConverter.convert(embeddedImage, embeddedSettings.getBitDepth());
                    ImageRecord imageRecord = resource.createImageRecord(bitmap, false);
                    pluckerDocument.addRecord(imageRecord);
                }
                if (!embeddedSettings.isIncludeAlternate() ||
                        ((image.getWidth() <= embeddedImage.getWidth()) &&
                        (image.getHeight() <= embeddedImage.getHeight()))) {
                    return;
                }
            }

            if ((jxlDocument.isIncludeStandaloneImages())) {
                // TODO: Improve heuristic for determining whether to include an alternate image.
                ImageSettings standaloneSettings = jxlDocument.getStandaloneImageSettings();
                if (ClientConfiguration.getDefault().isUseMultiImage()) {
                    BufferedImage standaloneImage = ImageConverter.rescale(image, standaloneSettings.getMaxWidth(),
                                                                           standaloneSettings.getMaxHeight());
                    addCompositeImage(resource, standaloneImage, standaloneSettings, resource.isEmbedded());
                } else {
                    BufferedImage standaloneImage = ImageConverter.rescale(image, standaloneSettings.getMaxWidth(),
                                                                           standaloneSettings.getMaxHeight());
                    int width = standaloneImage.getWidth();
                    int height = standaloneImage.getHeight();

                    int targetBitDepth = standaloneSettings.getBitDepth();
                    int maxPossiblebitDepth = 0;
                    if ((maxPossiblebitDepth == 0) && (targetBitDepth >= 8)) {
                        if ((width * height) <= 60000) {
                            maxPossiblebitDepth = 8;
                        }
                    }
                    if ((maxPossiblebitDepth == 0) && (targetBitDepth >= 4)) {
                        if ((width * height) <= 120000) {
                            maxPossiblebitDepth = 4;
                        }
                    }
                    if ((maxPossiblebitDepth == 0) && (targetBitDepth >= 2)) {
                        if ((width * height) <= 240000) {
                            maxPossiblebitDepth = 2;
                        }
                    }
                    if ((maxPossiblebitDepth == 0) && (targetBitDepth >= 1)) {
                        if ((width * height) <= 480000) {
                            maxPossiblebitDepth = 1;
                        }
                    }
                    if (maxPossiblebitDepth > 0) {
                        Bitmap bitmap = ImageConverter.convert(standaloneImage, maxPossiblebitDepth);
                        ImageRecord imageRecord = resource.createImageRecord(bitmap, resource.isEmbedded());
                        pluckerDocument.addRecord(imageRecord);
                    }
                }
            }
View Full Code Here


  }

  protected Paragraph[] writeData(PdbOutputStream out)
               throws IOException {
    // Restore bitmap
    Bitmap bitmap;
    if (tempFile != null) {
      InputStream in = null;
      try {
        in = new BufferedInputStream(new FileInputStream(tempFile));
        bitmap = new Bitmap(in);
      } finally {
        if (in != null) {
          in.close();
        }
        TemporaryFile.delete(tempFile);
      }
    } else {
      if (this.inMemoryBitmap == null) {
        throw new RuntimeException("Could not retrieve bitmap.");
      }
      bitmap = this.inMemoryBitmap;
    }

    int size = bitmap.getUncompressedSize();
    if (size > BITMAP_SIZE_LIMIT) {
      throw new RuntimeException("Bitmap size of " + size + " exceeds maximum size of " + BITMAP_SIZE_LIMIT);
    }
    out.write(bitmap.toByteArray());
    return null;
  }
View Full Code Here

TOP

Related Classes of net.sf.jpluck.palm.bitmap.Bitmap

Copyright © 2018 www.massapicom. 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.