mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-03 03:25:28 -04:00
Fixed a threading issue. Thanks to Lachlan O'Dea <lodea@me.com> for pointing it out!
This commit is contained in:
parent
ff3d578806
commit
897da0ebca
@ -218,49 +218,53 @@ public final class ColorSpaces {
|
|||||||
|
|
||||||
switch (colorSpace) {
|
switch (colorSpace) {
|
||||||
case CS_ADOBE_RGB_1998:
|
case CS_ADOBE_RGB_1998:
|
||||||
profile = adobeRGB1998.get();
|
synchronized (ColorSpaces.class) {
|
||||||
|
profile = adobeRGB1998.get();
|
||||||
if (profile == null) {
|
|
||||||
// Try to get system default or user-defined profile
|
|
||||||
profile = readProfileFromPath(Profiles.getPath("ADOBE_RGB_1998"));
|
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
// Fall back to the bundled ClayRGB1998 public domain Adobe RGB 1998 compatible profile,
|
// Try to get system default or user-defined profile
|
||||||
// identical for all practical purposes
|
profile = readProfileFromPath(Profiles.getPath("ADOBE_RGB_1998"));
|
||||||
profile = readProfileFromClasspathResource("/profiles/ClayRGB1998.icc");
|
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
// Should never happen given we now bundle fallback profile...
|
// Fall back to the bundled ClayRGB1998 public domain Adobe RGB 1998 compatible profile,
|
||||||
throw new IllegalStateException("Could not read AdobeRGB1998 profile");
|
// identical for all practical purposes
|
||||||
}
|
profile = readProfileFromClasspathResource("/profiles/ClayRGB1998.icc");
|
||||||
}
|
|
||||||
|
|
||||||
adobeRGB1998 = new WeakReference<ICC_Profile>(profile);
|
if (profile == null) {
|
||||||
|
// Should never happen given we now bundle fallback profile...
|
||||||
|
throw new IllegalStateException("Could not read AdobeRGB1998 profile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adobeRGB1998 = new WeakReference<ICC_Profile>(profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return createColorSpace(profile);
|
return createColorSpace(profile);
|
||||||
|
|
||||||
case CS_GENERIC_CMYK:
|
case CS_GENERIC_CMYK:
|
||||||
profile = genericCMYK.get();
|
synchronized (ColorSpaces.class) {
|
||||||
|
profile = genericCMYK.get();
|
||||||
if (profile == null) {
|
|
||||||
// Try to get system default or user-defined profile
|
|
||||||
profile = readProfileFromPath(Profiles.getPath("GENERIC_CMYK"));
|
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
if (DEBUG) {
|
// Try to get system default or user-defined profile
|
||||||
System.out.println("Using fallback profile");
|
profile = readProfileFromPath(Profiles.getPath("GENERIC_CMYK"));
|
||||||
|
|
||||||
|
if (profile == null) {
|
||||||
|
if (DEBUG) {
|
||||||
|
System.out.println("Using fallback profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to generic CMYK ColorSpace, which is *insanely slow* using ColorConvertOp... :-P
|
||||||
|
return CMYKColorSpace.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to generic CMYK ColorSpace, which is *insanely slow* using ColorConvertOp... :-P
|
genericCMYK = new WeakReference<ICC_Profile>(profile);
|
||||||
return CMYKColorSpace.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
genericCMYK = new WeakReference<ICC_Profile>(profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return createColorSpace(profile);
|
return createColorSpace(profile);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Default cases for convenience
|
// Default cases for convenience
|
||||||
return ColorSpace.getInstance(colorSpace);
|
return ColorSpace.getInstance(colorSpace);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user