gwlucastrig commented on a change in pull request #72: URL: https://github.com/apache/commons-imaging/pull/72#discussion_r422140919
########## File path: src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/fp/PaletteEntryForRange.java ########## @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.commons.imaging.formats.tiff.photometricinterpreters.fp; + +import java.awt.Color; + +/** + * Provides a palette entry for colors associated with a range of values. The + * return value will be interpolated between the minimum and maximum value for + * this entry. + * <p> + * In keeping with the conventions of many Geographic Information Systems (GIS) + * and art applications, this instance "covered" values in the range v0 ≤ f + * < v1. Thus, a value that exactly matches the upper bound of the range is + * not considered "covered". + */ +public class PaletteEntryForRange implements IPaletteEntry { + + private final float v0; + private final float v1; + private final float deltaV; + private final float r0; + private final float r1; + private final float g0; + private final float g1; + private final float b0; + private final float b1; + private final float a0; + private final float a1; + private final float deltaA; + private final float deltaR; + private final float deltaG; + private final float deltaB; Review comment: We could just get rid of the "delta" variables and change the places where it's used such as int r = (int) (t * deltaR + r0 + 0.5); To int r = (int) (t * (r1-r0) + r0 + 0.5); I don't think the first form actually saves any processing time. It's just the way I happened to code it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org