001 /*
002 * Copyright 2011 Christian Kumpe http://kumpe.de/christian/java
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package de.kumpe.hadooptimizer.examples.painting;
017
018 import java.awt.Graphics2D;
019 import java.awt.Image;
020 import java.awt.image.BufferedImage;
021 import java.io.IOException;
022
023 import javax.imageio.ImageIO;
024
025 public final class MonaLisa extends PolygonPaintBase {
026 private final static int WIDTH = 200;
027 private final static int HEIGHT = 200;
028
029 public MonaLisa() {
030 super(200, 3);
031 }
032
033 @Override
034 BufferedImage createReferenceImage() {
035 final BufferedImage reference = new BufferedImage(WIDTH, HEIGHT,
036 BufferedImage.TYPE_BYTE_GRAY);
037 Image monalisa;
038 try {
039 monalisa = ImageIO.read(MonaLisa.class
040 .getResourceAsStream("/MonaLisa.jpg"));
041 } catch (final IOException e) {
042 throw new RuntimeException(e);
043 }
044 final Graphics2D graphics = reference.createGraphics();
045 graphics.drawImage(monalisa, 0, 0, WIDTH, HEIGHT, null);
046 graphics.dispose();
047 return reference;
048 }
049
050 @Override
051 protected String getVersionInfo() {
052 return "$Id: MonaLisa.java 3797 2011-04-05 07:43:01Z baumbart $";
053 }
054 }