Skip to content

Package: AssignColorProfileJ2DOp

AssignColorProfileJ2DOp

nameinstructionbranchcomplexitylinemethod
AssignColorProfileJ2DOp()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
execute(AssignColorProfileOp, EditableImage, BufferedImage)
M: 45 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.image.java2d;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.concurrent.Immutable;
31: import java.awt.color.ColorSpace;
32: import java.awt.color.ICC_ColorSpace;
33: import java.awt.image.BufferedImage;
34: import java.awt.image.ColorModel;
35: import java.awt.image.ComponentColorModel;
36: import it.tidalwave.image.EditableImage;
37: import it.tidalwave.image.ImageUtils;
38: import it.tidalwave.image.op.AssignColorProfileOp;
39: import it.tidalwave.image.op.OperationImplementation;
40: import lombok.extern.slf4j.Slf4j;
41:
42: /***********************************************************************************************************************
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: @Immutable @Slf4j
48: public class AssignColorProfileJ2DOp extends OperationImplementation<AssignColorProfileOp, BufferedImage>
49: {
50: @Override @Nonnull
51: protected BufferedImage execute (@Nonnull final AssignColorProfileOp operation,
52: @Nonnull final EditableImage image,
53: @Nonnull final BufferedImage bufferedImage)
54: {
55: final var targetProfile = operation.getIccProfile();
56: log.trace("assignColorProfile({})", ImageUtils.getICCProfileName(targetProfile));
57: Java2DUtils.logImage(log, ">>>> source bufferedImage", bufferedImage);
58:
59: final ColorSpace colorSpace = new ICC_ColorSpace(targetProfile);
60: final ColorModel colorModel = new ComponentColorModel(colorSpace, false, false, ColorModel.OPAQUE,
61: bufferedImage.getRaster().getDataBuffer().getDataType());
62: final var result = new BufferedImage(colorModel,
63: bufferedImage.getRaster(),
64: false,
65: Java2DUtils.getProperties(bufferedImage));
66: Java2DUtils.logImage(log, ">>>> assignColorProfile() returning ", bufferedImage);
67:
68: return result;
69: }
70: }