/**
 * Map response handler for JPEG image format.
 *
 * @author Simone Giannecchini
 * @since 1.4.x
 */
public final class JPEGMapResponse extends RenderedImageMapResponse {

  /** Logger. */
  private static final Logger LOGGER =
      org.geotools.util.logging.Logging.getLogger(JPEGMapResponse.class.toString());

  private static final boolean CODEC_LIB_AVAILABLE = PackageUtil.isCodecLibAvailable();

  /**
   * Default capabilities for JPEG .
   *
   * <p>
   *
   * <ol>
   *   <li>tiled = supported
   *   <li>multipleValues = unsupported
   *   <li>paletteSupported = false
   *   <li>transparency = false
   * </ol>
   *
   * <p>We should soon support multipage tiff.
   */
  private static MapProducerCapabilities CAPABILITIES =
      new MapProducerCapabilities(true, false, false, false);

  /** the only MIME type this map producer supports */
  private static final String MIME_TYPE = "image/jpeg";

  public JPEGMapResponse(WMS wms) {
    super(MIME_TYPE, wms);
  }

  @Override
  public void formatImageOutputStream(
      RenderedImage image, OutputStream outStream, WMSMapContext mapContext) throws IOException {
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("About to write a JPEG image.");
    }

    boolean JPEGNativeAcc = wms.getJPEGNativeAcceleration() && CODEC_LIB_AVAILABLE;
    float quality = (100 - wms.getJpegCompression()) / 100.0f;
    ImageWorker iw = new ImageWorker(image);
    iw.writeJPEG(outStream, "JPEG", quality, JPEGNativeAcc);

    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("Writing a JPEG done!!!");
    }
  }

  @Override
  public MapProducerCapabilities getCapabilities(String outputFormat) {
    return CAPABILITIES;
  }
}
 public BMPImageWriterSpi() {
   super(
       PackageUtil.getVendor(),
       PackageUtil.getVersion(),
       formatNames,
       extensions,
       mimeTypes,
       "com.sun.media.imageioimpl.plugins.bmp.BMPImageWriter",
       STANDARD_OUTPUT_TYPE,
       readerSpiNames,
       false,
       null,
       null,
       null,
       null,
       true,
       BMPMetadata.nativeMetadataFormatName,
       "com.sun.media.imageioimpl.plugins.bmp.BMPMetadataFormat",
       null,
       null);
 }
 public TIFFImageReaderSpi() {
   super(
       PackageUtil.getVendor(),
       PackageUtil.getVersion(),
       names,
       suffixes,
       MIMETypes,
       readerClassName,
       STANDARD_INPUT_TYPE,
       writerSpiNames,
       false,
       TIFFStreamMetadata.nativeMetadataFormatName,
       "com.sun.media.imageioimpl.plugins.tiff.TIFFStreamMetadataFormat",
       null,
       null,
       true,
       TIFFImageMetadata.nativeMetadataFormatName,
       "com.sun.media.imageioimpl.plugins.tiff.TIFFImageMetadataFormat",
       null,
       null);
 }
Exemplo n.º 4
0
 public WBMPImageReaderSpi() {
   super(
       PackageUtil.getVendor(),
       PackageUtil.getVersion(),
       formatNames,
       entensions,
       mimeType,
       "com.sun.media.imageioimpl.plugins.wbmp.WBMPImageReader",
       STANDARD_INPUT_TYPE,
       writerSpiNames,
       true,
       null,
       null,
       null,
       null,
       true,
       WBMPMetadata.nativeMetadataFormatName,
       "com.sun.media.imageioimpl.plugins.wbmp.WBMPMetadataFormat",
       null,
       null);
 }
Exemplo n.º 5
0
  private void updateModel() {
    values.put(KEY_DATA_DIR, getDataDirectory());
    values.put(KEY_LOCKS, Long.toString(getLockCount()));
    values.put(KEY_CONNECTIONS, Long.toString(getConnectionCount()));
    values.put(KEY_MEMORY, formatUsedMemory());
    values.put(
        KEY_JVM_VERSION,
        System.getProperty("java.vendor")
            + ": "
            + System.getProperty("java.version")
            + " ("
            + System.getProperty("java.vm.name")
            + ")");

    values.put(KEY_JAI_AVAILABLE, Boolean.toString(isNativeJAIAvailable()));
    values.put(KEY_JAI_IMAGEIO_AVAILABLE, Boolean.toString(PackageUtil.isCodecLibAvailable()));

    GeoServerInfo geoServerInfo = getGeoServer().getGlobal();
    JAIInfo jaiInfo = geoServerInfo.getJAI();
    JAI jai = jaiInfo.getJAI();
    CoverageAccessInfo coverageAccess = geoServerInfo.getCoverageAccess();
    TileCache jaiCache = jaiInfo.getTileCache();

    values.put(KEY_JAI_MAX_MEM, formatMemory(jaiCache.getMemoryCapacity()));
    if (jaiCache instanceof CacheDiagnostics) {
      values.put(
          KEY_JAI_MEM_USAGE, formatMemory(((CacheDiagnostics) jaiCache).getCacheMemoryUsed()));
    } else {
      values.put(KEY_JAI_MEM_USAGE, "-");
    }
    values.put(
        KEY_JAI_MEM_THRESHOLD,
        Integer.toString((int) (100.0f * jaiCache.getMemoryThreshold())) + "%");
    values.put(KEY_JAI_TILE_THREADS, Integer.toString(jai.getTileScheduler().getParallelism()));
    values.put(
        KEY_JAI_TILE_THREAD_PRIORITY, Integer.toString(jai.getTileScheduler().getPriority()));

    values.put(
        KEY_COVERAGEACCESS_CORE_POOL_SIZE, Integer.toString(coverageAccess.getCorePoolSize()));
    values.put(KEY_COVERAGEACCESS_MAX_POOL_SIZE, Integer.toString(coverageAccess.getMaxPoolSize()));
    values.put(
        KEY_COVERAGEACCESS_KEEP_ALIVE_TIME, Integer.toString(coverageAccess.getKeepAliveTime()));

    values.put(KEY_UPDATE_SEQUENCE, Long.toString(geoServerInfo.getUpdateSequence()));
    values.put(KEY_JAVA_RENDERER, checkRenderer());
  }
Exemplo n.º 6
0
  /**
   * Testing JPEG capabilities.
   *
   * @throws IOException If an error occured while writting the image.
   */
  @Test
  public void testJPEGWrite() throws IOException {
    assertTrue("Assertions should be enabled.", ImageWorker.class.desiredAssertionStatus());
    // get the image of the world with transparency
    final ImageWorker worker = new ImageWorker(getSyntheticRGB(true));
    show(worker, "Input JPEG");

    // /////////////////////////////////////////////////////////////////////
    // nativeJPEG  with compression JPEG-LS
    // ////////////////////////////////////////////////////////////////////
    final File outFile = TestData.temp(this, "temp.jpeg");
    ImageWorker readWorker;
    if (PackageUtil.isCodecLibAvailable()) {
      worker.writeJPEG(outFile, "JPEG-LS", 0.75f, true);
      readWorker = new ImageWorker(ImageIO.read(outFile));
      show(readWorker, "Native JPEG LS");
    } else {
      try {
        worker.writeJPEG(outFile, "JPEG-LS", 0.75f, true);
        assertFalse(true);
      } catch (Exception e) {
        // TODO: handle exception
      }
    }

    // /////////////////////////////////////////////////////////////////////
    // native JPEG compression
    // /////////////////////////////////////////////////////////////////////
    worker.setImage(worldImage);
    worker.writeJPEG(outFile, "JPEG", 0.75f, true);
    readWorker = new ImageWorker(ImageIO.read(outFile));
    show(readWorker, "native JPEG");

    // /////////////////////////////////////////////////////////////////////
    // pure java JPEG compression
    // /////////////////////////////////////////////////////////////////////
    worker.setImage(worldImage);
    worker.writeJPEG(outFile, "JPEG", 0.75f, false);
    readWorker.setImage(ImageIO.read(outFile));
    show(readWorker, "Pure Java JPEG");
    outFile.delete();
  }
 public String getDescription(Locale locale) {
   String desc = PackageUtil.getSpecificationTitle() + " BMP Image Writer";
   return desc;
 }
 public String getDescription(Locale locale) {
   String desc = PackageUtil.getSpecificationTitle() + " TIFF Image Reader";
   return desc;
 }