Return-Path: Delivered-To: apmail-xmlgraphics-commits-archive@www.apache.org Received: (qmail 80959 invoked from network); 15 Jan 2009 09:47:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2009 09:47:23 -0000 Received: (qmail 7189 invoked by uid 500); 15 Jan 2009 09:47:23 -0000 Mailing-List: contact commits-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@xmlgraphics.apache.org Delivered-To: mailing list commits@xmlgraphics.apache.org Received: (qmail 7179 invoked by uid 99); 15 Jan 2009 09:47:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Jan 2009 01:47:23 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Jan 2009 09:47:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A68BA238889E; Thu, 15 Jan 2009 01:46:59 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r734650 - in /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image: GraphicsConstants.java loader/impl/DefaultImageContext.java loader/impl/ImageConverterG2D2Bitmap.java Date: Thu, 15 Jan 2009 09:46:59 -0000 To: commits@xmlgraphics.apache.org From: maxberger@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090115094659.A68BA238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: maxberger Date: Thu Jan 15 01:46:58 2009 New Revision: 734650 URL: http://svn.apache.org/viewvc?rev=734650&view=rev Log: Created Constants for default resolution Added Headless-Check to DefaultImageContext, bug #46520 Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java (with props) Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java?rev=734650&view=auto ============================================================================== --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java (added) +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java Thu Jan 15 01:46:58 2009 @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.xmlgraphics.image; + +public final class GraphicsConstants { + + /** + * The default DPI used when they cannot be determined by the graphics + * environment or loaded from the image. + */ + public static final int DEFAULT_DPI = 72; + + /** + * Graphics may be sampled at this resolution. + */ + public static final int DEFAULT_SAMPLE_DPI = 300; + + /** + * This class should not be instantiated. + */ + private GraphicsConstants() { + } +} Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java ------------------------------------------------------------------------------ svn:executable = * Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java ------------------------------------------------------------------------------ svn:keywords = Id Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java?rev=734650&r1=734649&r2=734650&view=diff ============================================================================== --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java (original) +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java Thu Jan 15 01:46:58 2009 @@ -19,8 +19,10 @@ package org.apache.xmlgraphics.image.loader.impl; +import java.awt.GraphicsEnvironment; import java.awt.Toolkit; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.ImageContext; /** @@ -28,13 +30,18 @@ */ public class DefaultImageContext implements ImageContext { - private float sourceResolution; + private final float sourceResolution; /** * Main constructor. */ public DefaultImageContext() { - this.sourceResolution = Toolkit.getDefaultToolkit().getScreenResolution(); + if (GraphicsEnvironment.isHeadless()) { + this.sourceResolution = GraphicsConstants.DEFAULT_DPI; + } else { + this.sourceResolution = Toolkit.getDefaultToolkit() + .getScreenResolution(); + } } /** {@inheritDoc} */ Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java?rev=734650&r1=734649&r2=734650&view=diff ============================================================================== --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java (original) +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java Thu Jan 15 01:46:58 2009 @@ -34,6 +34,7 @@ import java.awt.image.WritableRaster; import java.util.Map; +import org.apache.xmlgraphics.image.GraphicsConstants; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageProcessingHints; @@ -64,7 +65,7 @@ withAlpha = false; } - int resolution = 300; //default: 300dpi + int resolution = GraphicsConstants.DEFAULT_SAMPLE_DPI; Number res = (Number)hints.get(ImageProcessingHints.TARGET_RESOLUTION); if (res != null) { resolution = res.intValue(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: commits-help@xmlgraphics.apache.org