Author: dspicar
Date: Mon Aug 27 17:14:59 2012
New Revision: 1377751
URL: http://svn.apache.org/viewvc?rev=1377751&view=rev
Log:
CLEREZZA-716: added missing files
Added:
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/BufferedImageProvider.java
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/ImageIOBufferedImageProvider.java
Added:
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/BufferedImageProvider.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/BufferedImageProvider.java?rev=1377751&view=auto
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/BufferedImageProvider.java
(added)
+++
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/BufferedImageProvider.java
Mon Aug 27 17:14:59 2012
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.clerezza.utils.imageprocessing;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * A service that reads image data and provides {@link BufferedImage}s.
+ *
+ * By providing a custom service it is easy to extend the platform's image
+ * processing capabilities with new image formats or use alternate processing
+ * libraries for reading image data.
+ *
+ * @author daniel
+ */
+public interface BufferedImageProvider {
+
+ /**
+ * Creates a {@link BufferedImage} from an {@link File}.
+ *
+ * @param file the image file.
+ * @return a {@link BufferedImage} containing the data of the specified
+ * image.
+ */
+ public BufferedImage getBufferedImage(File file) throws IOException;
+
+ /**
+ * Creates a {@link BufferedImage} from an {@link InputStream}.
+ *
+ * @param in a stream from which the image data can be read.
+ * @return a {@link BufferedImage} containing the data of the specified
+ * image.
+ */
+ public BufferedImage getBufferedImage(InputStream in) throws IOException;
+
+ /**
+ * Creates a {@link BufferedImage} from a {@link URL}.
+ *
+ * @param url the location of the image described as a URL.
+ * @return a {@link BufferedImage} containing the data of the specified
+ * image.
+ */
+ public BufferedImage getBufferedImage(URL url) throws IOException;
+}
Added:
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/ImageIOBufferedImageProvider.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/ImageIOBufferedImageProvider.java?rev=1377751&view=auto
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/ImageIOBufferedImageProvider.java
(added)
+++
incubator/clerezza/issues/CLEREZZA-716/utils.imageprocessing/src/main/java/org/apache/clerezza/utils/imageprocessing/ImageIOBufferedImageProvider.java
Mon Aug 27 17:14:59 2012
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.clerezza.utils.imageprocessing;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageInputStream;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+
+/**
+ * A service using Java Image IO to read images.
+ *
+ * @author daniel
+ */
+@Component
+@Service(BufferedImageProvider.class)
+public class ImageIOBufferedImageProvider implements BufferedImageProvider {
+
+ @Override
+ public BufferedImage getBufferedImage(File file) throws IOException {
+ return ImageIO.read(file);
+ }
+
+ @Override
+ public BufferedImage getBufferedImage(InputStream in) throws IOException {
+ if(in instanceof ImageInputStream) {
+ return ImageIO.read((ImageInputStream) in);
+ }
+ return ImageIO.read(in);
+ }
+
+ @Override
+ public BufferedImage getBufferedImage(URL url) throws IOException {
+ return ImageIO.read(url);
+ }
+
+}