Skip to content
Snippets Groups Projects
Commit ac0aa71c authored by tpylak's avatar tpylak
Browse files

fix: display a subset of channels with right colors when all channels are...

fix: display a subset of channels with right colors when all channels are originally merged on one image

SVN: 19985
parent 9eb7aa01
No related branches found
No related tags found
No related merge requests found
......@@ -680,17 +680,53 @@ public class ImageChannelsUtils
ImageWithReference image = images.get(index);
int rgb = image.getBufferedImage().getRGB(x, y);
Color singleColor = new Color(rgb, true);
int channelIndex = image.getReference().getChannelIndex();
for (int i : getRGBColorIndexes(channelIndex))
{
colorBuffer[i] = Math.max(colorBuffer[i], extractMaxColorIngredient(singleColor));
}
AbsoluteImageReference imageReference = image.getReference();
setColorComponents(colorBuffer, singleColor, imageReference);
// merge alpha channel
colorBuffer[3] = Math.max(colorBuffer[3], singleColor.getAlpha());
}
return asRGB(colorBuffer);
}
private static void setColorComponents(int[] colorBuffer, Color singleColor,
AbsoluteImageReference imageReference)
{
ColorComponent colorComponent = imageReference.tryGetColorComponent();
if (colorComponent != null)
{
int index = getColorComponentIndex(colorComponent);
colorBuffer[index] = colorComponent.getComponent(singleColor);
} else
{
int channelIndex = imageReference.getChannelIndex();
setColorComponentsForChannelIndex(colorBuffer, singleColor, channelIndex);
}
}
private static int getColorComponentIndex(ColorComponent colorComponent)
{
switch (colorComponent)
{
case RED:
return 0;
case GREEN:
return 1;
case BLUE:
return 2;
default:
throw new IllegalStateException("Unknown color " + colorComponent);
}
}
private static void setColorComponentsForChannelIndex(int[] colorBuffer, Color singleColor,
int channelIndex)
{
for (int i : getRGBColorIndexes(channelIndex))
{
colorBuffer[i] = Math.max(colorBuffer[i], extractMaxColorIngredient(singleColor));
}
}
// --------- common
private EnvironmentFailureException createImageNotFoundException(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment