1 /*
2 * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * - Neither the name of Oracle nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
126 new ImageWriterWrite();
127 }
128 }
129
130 private static void initIIOWriteFormats() {
131 List spis = new ArrayList();
132 List shortNames = new ArrayList();
133
134 ImageIO.scanForPlugins();
135 IIORegistry registry = IIORegistry.getDefaultInstance();
136 java.util.Iterator writerspis =
137 registry.getServiceProviders(ImageWriterSpi.class, false);
138 while (writerspis.hasNext()) {
139 // REMIND: there could be more than one non-core plugin for
140 // a particular format, as is the case for JPEG2000 in the JAI
141 // IIO Tools package, so we should support that somehow
142 ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
143 String klass = spi.getClass().getName();
144 String format = spi.getFormatNames()[0].toLowerCase();
145 String suffix = spi.getFileSuffixes()[0].toLowerCase();
146 if (suffix == null || suffix.equals("")) {
147 suffix = format;
148 }
149 String shortName;
150 if (klass.startsWith("com.sun.imageio.plugins")) {
151 shortName = "core-" + suffix;
152 } else {
153 shortName = "ext-" + suffix;
154 }
155 spis.add(spi);
156 shortNames.add(shortName);
157 }
158
159 imageioWriterSpis = new ImageWriterSpi[spis.size()];
160 imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
161 imageioWriteFormatShortNames = new String[shortNames.size()];
162 imageioWriteFormatShortNames =
163 (String[])shortNames.toArray(imageioWriteFormatShortNames);
164 }
165
166 protected OutputImageTests(Group parent,
|
1 /*
2 * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * - Neither the name of Oracle nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
126 new ImageWriterWrite();
127 }
128 }
129
130 private static void initIIOWriteFormats() {
131 List spis = new ArrayList();
132 List shortNames = new ArrayList();
133
134 ImageIO.scanForPlugins();
135 IIORegistry registry = IIORegistry.getDefaultInstance();
136 java.util.Iterator writerspis =
137 registry.getServiceProviders(ImageWriterSpi.class, false);
138 while (writerspis.hasNext()) {
139 // REMIND: there could be more than one non-core plugin for
140 // a particular format, as is the case for JPEG2000 in the JAI
141 // IIO Tools package, so we should support that somehow
142 ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
143 String klass = spi.getClass().getName();
144 String format = spi.getFormatNames()[0].toLowerCase();
145 String suffix = spi.getFileSuffixes()[0].toLowerCase();
146 if (suffix == null || suffix.isEmpty()) {
147 suffix = format;
148 }
149 String shortName;
150 if (klass.startsWith("com.sun.imageio.plugins")) {
151 shortName = "core-" + suffix;
152 } else {
153 shortName = "ext-" + suffix;
154 }
155 spis.add(spi);
156 shortNames.add(shortName);
157 }
158
159 imageioWriterSpis = new ImageWriterSpi[spis.size()];
160 imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
161 imageioWriteFormatShortNames = new String[shortNames.size()];
162 imageioWriteFormatShortNames =
163 (String[])shortNames.toArray(imageioWriteFormatShortNames);
164 }
165
166 protected OutputImageTests(Group parent,
|