1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.image;
16  
17  import java.awt.image.BufferedImage;
18  import java.awt.image.RenderedImage;
19  
20  import java.io.File;
21  import java.io.IOException;
22  import java.io.OutputStream;
23  
24  /**
25   * <a href="ImageProcessorUtil.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class ImageProcessorUtil {
30  
31      public static BufferedImage convertImageType(
32          BufferedImage sourceImage, int type) {
33  
34          return getImageProcessor().convertImageType(sourceImage, type);
35      }
36  
37      public static void encodeGIF(RenderedImage renderedImage, OutputStream os)
38          throws IOException {
39  
40          getImageProcessor().encodeGIF(renderedImage, os);
41      }
42  
43      public static void encodeWBMP(RenderedImage renderedImage, OutputStream os)
44          throws InterruptedException, IOException {
45  
46          getImageProcessor().encodeWBMP(renderedImage, os);
47      }
48  
49      public static BufferedImage getBufferedImage(RenderedImage renderedImage) {
50          return getImageProcessor().getBufferedImage(renderedImage);
51      }
52  
53      public static byte[] getBytes(
54              RenderedImage renderedImage, String contentType)
55          throws IOException {
56  
57          return getImageProcessor().getBytes(renderedImage, contentType);
58      }
59  
60      public static ImageProcessor getImageProcessor() {
61          return _imageProcessor;
62      }
63  
64      public static ImageBag read(File file) throws IOException {
65          return getImageProcessor().read(file);
66      }
67  
68      public static ImageBag read(byte[] bytes) throws IOException {
69          return getImageProcessor().read(bytes);
70      }
71  
72      public static RenderedImage scale(
73          RenderedImage renderedImage, int maxHeight, int maxWidth) {
74  
75          return getImageProcessor().scale(renderedImage, maxHeight, maxWidth);
76      }
77  
78      public void setImageProcessor(ImageProcessor imageProcessor) {
79          _imageProcessor = imageProcessor;
80      }
81  
82      private static ImageProcessor _imageProcessor;
83  
84  }