14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.image; 27 28 import java.awt.Image; 29 import java.awt.image.ImageFilter; 30 import java.awt.image.ImageConsumer; 31 import java.awt.image.ImageProducer; 32 import java.util.Hashtable; 33 import java.awt.image.ColorModel; 34 35 /** 36 * This class is an implementation of the ImageProducer interface which 37 * takes an existing image and a filter object and uses them to produce 38 * image data for a new filtered version of the original image. 39 * Here is an example which filters an image by swapping the red and 40 * blue components: 41 * <pre> 42 * 43 * Image src = getImage("doc:///demo/images/duke/T1.gif"); 44 * ImageFilter colorfilter = new RedBlueSwapFilter(); 45 * Image img = createImage(new FilteredImageSource(src.getSource(), 46 * colorfilter)); 47 * 48 * </pre> 49 * 50 * @see ImageProducer 51 * 52 * @author Jim Graham 53 */ 189 * handed to the ImageFilter for further processing, since the 190 * ability to preserve the pixel ordering depends on the filter. 191 * 192 * <p> 193 * This method is public as a side effect 194 * of this class implementing 195 * the {@code ImageProducer} interface. 196 * It should not be called from user code, 197 * and its behavior if called from user code is unspecified. 198 * 199 * @see ImageConsumer 200 */ 201 public void requestTopDownLeftRightResend(ImageConsumer ic) { 202 if (proxies != null) { 203 ImageFilter imgf = proxies.get(ic); 204 if (imgf != null) { 205 imgf.resendTopDownLeftRight(src); 206 } 207 } 208 } 209 } | 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.image; 27 28 import java.awt.Image; 29 import java.awt.image.ImageFilter; 30 import java.awt.image.ImageConsumer; 31 import java.awt.image.ImageProducer; 32 import java.util.Hashtable; 33 import java.awt.image.ColorModel; 34 import java.util.Arrays; 35 import java.util.Collections; 36 import java.util.LinkedList; 37 import java.util.List; 38 import java.util.stream.Collectors; 39 import sun.awt.image.MultiResolutionToolkitImage; 40 41 /** 42 * This class is an implementation of the ImageProducer interface which 43 * takes an existing image and a filter object and uses them to produce 44 * image data for a new filtered version of the original image. 45 * Here is an example which filters an image by swapping the red and 46 * blue components: 47 * <pre> 48 * 49 * Image src = getImage("doc:///demo/images/duke/T1.gif"); 50 * ImageFilter colorfilter = new RedBlueSwapFilter(); 51 * Image img = createImage(new FilteredImageSource(src.getSource(), 52 * colorfilter)); 53 * 54 * </pre> 55 * 56 * @see ImageProducer 57 * 58 * @author Jim Graham 59 */ 195 * handed to the ImageFilter for further processing, since the 196 * ability to preserve the pixel ordering depends on the filter. 197 * 198 * <p> 199 * This method is public as a side effect 200 * of this class implementing 201 * the {@code ImageProducer} interface. 202 * It should not be called from user code, 203 * and its behavior if called from user code is unspecified. 204 * 205 * @see ImageConsumer 206 */ 207 public void requestTopDownLeftRightResend(ImageConsumer ic) { 208 if (proxies != null) { 209 ImageFilter imgf = proxies.get(ic); 210 if (imgf != null) { 211 imgf.resendTopDownLeftRight(src); 212 } 213 } 214 } 215 216 @Override 217 public boolean isMultiResolutionImageProducer() { 218 return src.isMultiResolutionImageProducer(); 219 } 220 221 @Override 222 public List<ResolutionVariantItem<ImageProducer>> getResolutionVariantItems() { 223 return src.getResolutionVariantItems().stream().map( 224 (rvItem) -> new ResolutionVariantItem<ImageProducer>( 225 new FilteredImageSource(rvItem.getValue(), 226 filter.getScaledFilterInstance( 227 rvItem.getScaleX(), 228 rvItem.getScaleY())), 229 rvItem.getScaleX(), rvItem.getScaleY())) 230 .collect(Collectors.toList()); 231 } 232 } |