01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.svggen;
20:
21: import java.awt.Rectangle;
22: import java.awt.RenderingHints;
23: import java.awt.geom.Point2D;
24: import java.awt.geom.Rectangle2D;
25: import java.awt.image.BufferedImage;
26: import java.awt.image.BufferedImageOp;
27: import java.awt.image.ColorModel;
28:
29: /**
30: *
31: * @version $Id: NullOp.java 498740 2007-01-22 18:35:57Z dvholten $
32: */
33: class NullOp implements BufferedImageOp {
34: public BufferedImage filter(BufferedImage src, BufferedImage dest) {
35: java.awt.Graphics2D g = dest.createGraphics();
36: g.drawImage(src, 0, 0, null);
37: g.dispose();
38: return dest;
39: }
40:
41: public Rectangle2D getBounds2D(BufferedImage src) {
42: return new Rectangle(0, 0, src.getWidth(), src.getHeight());
43: }
44:
45: /**
46: * Creates a destination image compatible with the source.
47: */
48: public BufferedImage createCompatibleDestImage(BufferedImage src,
49: ColorModel destCM) {
50: BufferedImage dest = null;
51: if (destCM == null)
52: destCM = src.getColorModel();
53:
54: dest = new BufferedImage(destCM, destCM
55: .createCompatibleWritableRaster(src.getWidth(), src
56: .getHeight()), destCM.isAlphaPremultiplied(),
57: null);
58:
59: return dest;
60: }
61:
62: /**
63: * Returns the location of the destination point given a
64: * point in the source image. If DestPt is non-null, it
65: * will be used to hold the return value.
66: */
67: public Point2D getPoint2D(Point2D srcPt, Point2D destPt) {
68: // This operation does not affect pixel location
69: if (destPt == null)
70: destPt = new Point2D.Double();
71: destPt.setLocation(srcPt.getX(), srcPt.getY());
72: return destPt;
73: }
74:
75: /**
76: * Returns the rendering hints for this BufferedImageOp. Returns
77: * null if no hints have been set.
78: */
79: public RenderingHints getRenderingHints() {
80: return null;
81: }
82: }
|