1 // Copyright 2010 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.images
;
5 import com
.google
.appengine
.api
.images
.ImagesService
.OutputEncoding
;
8 * {@code OutputSettings} represents the different settings to specify how
9 * a particular transform or composite will return an {@link Image}.
12 public class OutputSettings
{
14 * The output encoding of the image.
16 private OutputEncoding outputEncoding
;
19 * The quality of the returned image. The number should be between 1 and 100
20 * when set. This value should only be set for
21 * JPEG encoding and will not be honored for other encodings.
23 private int quality
= -1;
25 public OutputSettings(OutputEncoding outputEncoding
) {
26 this.outputEncoding
= outputEncoding
;
30 * Gets the output encoding.
31 * @return The output encoding.
33 public OutputEncoding
getOutputEncoding() {
34 return outputEncoding
;
38 * Sets the output encoding.
39 * @param outputEncoding The encoding to set.
41 public void setOutputEncoding(OutputEncoding outputEncoding
) {
42 this.outputEncoding
= outputEncoding
;
47 * @return If the quality has been set, a value between 1 and 100.
48 * Otherwise, it returns -1.
50 public int getQuality() {
55 * Sets the quality of the returned image. Value must be between
57 * @param quality The quality to set.
58 * @throws IllegalArgumentException if quality is not between 1 and 100.
60 public void setQuality(int quality
) {
61 if (quality
>= 1 && quality
<= 100) {
62 this.quality
= quality
;
64 throw new IllegalArgumentException("Trying to set an invalid quality: " +
65 quality
+ ". Value must be between 1 and 100.");
70 * Checks if the quality value has been set.
71 * @return If the quality has been set, true. Otherwise, false.
73 public boolean hasQuality() {
74 return this.quality
!= -1;