-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8366208: Unexpected exception in sun.java2d.cmm.lcms.LCMSImageLayout #26994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
36261fe
8366208: Unexpected exception in sun.java2d.cmm.lcms.LCMSImageLayout
mrserb abf0ac3
Update FilterSemiCustomImages.java
mrserb a7f3aa2
Update FilterSemiCustomImages.java
mrserb 83c4c62
Update test/jdk/sun/java2d/cmm/ColorConvertOp/FilterSemiCustomImages.…
mrserb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
test/jdk/sun/java2d/cmm/ColorConvertOp/FilterSemiCustomImages.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
/* | ||
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import java.awt.Color; | ||
import java.awt.Point; | ||
import java.awt.color.ColorSpace; | ||
import java.awt.image.BufferedImage; | ||
import java.awt.image.ColorConvertOp; | ||
import java.awt.image.ColorModel; | ||
import java.awt.image.SampleModel; | ||
import java.awt.image.WritableRaster; | ||
import java.io.File; | ||
|
||
import javax.imageio.ImageIO; | ||
|
||
import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; | ||
import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR; | ||
import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE; | ||
import static java.awt.image.BufferedImage.TYPE_INT_ARGB; | ||
import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE; | ||
import static java.awt.image.BufferedImage.TYPE_INT_BGR; | ||
import static java.awt.image.BufferedImage.TYPE_INT_RGB; | ||
import static java.awt.image.BufferedImage.TYPE_USHORT_GRAY; | ||
|
||
/** | ||
* @test | ||
* @bug 8366208 | ||
* @summary Verifies ColorConvertOp works correctly with BufferedImage and | ||
* semi-custom raster | ||
*/ | ||
public final class FilterSemiCustomImages { | ||
|
||
private static final int W = 144; | ||
private static final int H = 123; | ||
|
||
private static final int[] TYPES = { | ||
TYPE_INT_RGB, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, | ||
TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE, | ||
TYPE_USHORT_GRAY | ||
}; | ||
|
||
private static final int[] CSS = { | ||
ColorSpace.CS_CIEXYZ, ColorSpace.CS_GRAY, ColorSpace.CS_LINEAR_RGB, | ||
ColorSpace.CS_PYCC, ColorSpace.CS_sRGB | ||
}; | ||
|
||
private static final class CustomRaster extends WritableRaster { | ||
CustomRaster(SampleModel sampleModel, Point origin) { | ||
super(sampleModel, origin); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
for (int fromIndex : CSS) { | ||
for (int toIndex : CSS) { | ||
if (fromIndex != toIndex) { | ||
for (int type : TYPES) { | ||
test(fromIndex, toIndex, type); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void test(int fromIndex, int toIndex, int type) | ||
throws Exception | ||
{ | ||
ColorSpace fromCS = ColorSpace.getInstance(fromIndex); | ||
ColorSpace toCS = ColorSpace.getInstance(toIndex); | ||
ColorConvertOp op = new ColorConvertOp(fromCS, toCS, null); | ||
|
||
// standard source -> standard dst | ||
BufferedImage srcGold = new BufferedImage(W, H, type); | ||
fill(srcGold); | ||
BufferedImage dstGold = new BufferedImage(W, H, type); | ||
op.filter(srcGold, dstGold); | ||
|
||
// custom source -> standard dst | ||
BufferedImage srcCustom = makeCustomBI(srcGold); | ||
fill(srcCustom); | ||
BufferedImage dst = new BufferedImage(W, H, type); | ||
op.filter(srcCustom, dst); | ||
verify(dstGold, dst); | ||
|
||
// standard source -> custom dst | ||
BufferedImage src = new BufferedImage(W, H, type); | ||
fill(src); | ||
BufferedImage dstCustom = makeCustomBI(dstGold); | ||
op.filter(src, dstCustom); | ||
verify(dstGold, dstCustom); | ||
|
||
// custom source -> custom dst | ||
srcCustom = makeCustomBI(srcGold); | ||
fill(srcCustom); | ||
dstCustom = makeCustomBI(dstGold); | ||
op.filter(srcCustom, dstCustom); | ||
verify(dstGold, dstCustom); | ||
} | ||
|
||
private static BufferedImage makeCustomBI(BufferedImage bi) { | ||
ColorModel cm = bi.getColorModel(); | ||
SampleModel sm = bi.getSampleModel(); | ||
CustomRaster cr = new CustomRaster(sm, new Point()); | ||
return new BufferedImage(cm, cr, bi.isAlphaPremultiplied(), null) { | ||
@Override | ||
public int getType() { | ||
return bi.getType(); | ||
} | ||
}; | ||
} | ||
|
||
private static void fill(BufferedImage image) { | ||
int width = image.getWidth(); | ||
int height = image.getHeight(); | ||
for (int x = 0; x < width; ++x) { | ||
for (int y = 0; y < height; ++y) { | ||
// alpha channel may be calculated slightly differently on | ||
// different code paths, so only check fully transparent and | ||
// fully opaque pixels | ||
Color c = new Color(y * 255 / (height - 1), | ||
x * 255 / (width - 1), | ||
x % 255, | ||
(x % 2 == 0) ? 0 : 255); | ||
image.setRGB(x, y, c.getRGB()); | ||
} | ||
} | ||
} | ||
|
||
private static void verify(BufferedImage dstGold, BufferedImage dst) | ||
throws Exception | ||
{ | ||
mrserb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (int x = 0; x < W; ++x) { | ||
for (int y = 0; y < H; ++y) { | ||
if (dst.getRGB(x, y) != dstGold.getRGB(x, y)) { | ||
ImageIO.write(dst, "png", new File("custom.png")); | ||
ImageIO.write(dstGold, "png", new File("gold.png")); | ||
throw new RuntimeException("Test failed."); | ||
} | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.