annotate dwt/graphics/ImageLoader.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents 5f2e72114476
children fd9c62a2998e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module dwt.graphics.ImageLoader;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 public import dwt.graphics.ImageLoaderListener;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 public import dwt.graphics.ImageLoaderEvent;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 public import dwt.graphics.ImageData;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import dwt.DWT;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwt.internal.Compatibility;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 import dwt.internal.image.FileFormat;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 import tango.core.Exception;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import tango.core.Array;
212
ab60f3309436 reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents: 22
diff changeset
26 import dwt.dwthelper.utils;
22
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 * Instances of this class are used to load images from,
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 * and save images to, a file or stream.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 * <p>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 * Currently supported image formats are:
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 * </p><ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * <li>BMP (Windows or OS/2 Bitmap)</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * <li>ICO (Windows Icon)</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 * <li>JPEG</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * <li>GIF</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 * <li>PNG</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 * <li>TIFF</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 * <code>ImageLoaders</code> can be used to:
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 * <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 * <li>load/save single images in all formats</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * <li>load/save multiple images (GIF/ICO/TIFF)</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 * <li>load/save animated GIF images</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 * <li>load interlaced GIF/PNG images</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 * <li>load progressive JPEG images</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 public class ImageLoader {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 * the array of ImageData objects in this ImageLoader.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 * This array is read in when the load method is called,
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 * and it is written out when the save method is called
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 public ImageData[] data;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 * the width of the logical screen on which the images
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 * reside, in pixels (this corresponds to the GIF89a
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 * Logical Screen Width value)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 public int logicalScreenWidth;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 * the height of the logical screen on which the images
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 * reside, in pixels (this corresponds to the GIF89a
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 * Logical Screen Height value)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 public int logicalScreenHeight;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 * the background pixel for the logical screen (this
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 * corresponds to the GIF89a Background Color Index value).
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 * The default is -1 which means 'unspecified background'
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 public int backgroundPixel;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84 * the number of times to repeat the display of a sequence
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 * of animated images (this corresponds to the commonly-used
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 * GIF application extension for "NETSCAPE 2.0 01").
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 * The default is 1. A value of 0 means 'display repeatedly'
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 public int repeatCount;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 /*
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 * the set of ImageLoader event listeners, created on demand
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94 ImageLoaderListener[] imageLoaderListeners;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 * Construct a new empty ImageLoader.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99 public this() {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 reset();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 * Resets the fields of the ImageLoader, except for the
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 * <code>imageLoaderListeners</code> field.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 void reset() {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108 data = null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 logicalScreenWidth = 0;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 logicalScreenHeight = 0;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 backgroundPixel = -1;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 repeatCount = 1;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 * Loads an array of <code>ImageData</code> objects from the
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 * specified input stream. Throws an error if either an error
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 * occurs while loading the images, or if the images are not
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 * of a supported type. Returns the loaded image data array.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 * @param stream the input stream to load the images from
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 * @return an array of <code>ImageData</code> objects loaded from the specified input stream
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 * <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 * <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130 * <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 public ImageData[] load(InputStream stream) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 if (stream is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 reset();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 data = FileFormat.load(stream, this);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 return data;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 * Loads an array of <code>ImageData</code> objects from the
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 * file with the specified name. Throws an error if either
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 * an error occurs while loading the images, or if the images are
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 * not of a supported type. Returns the loaded image data array.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 * @param filename the name of the file to load the images from
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 * @return an array of <code>ImageData</code> objects loaded from the specified file
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150 * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 * <li>ERROR_IO - if an IO error occurs while reading from the file</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 * <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157 */
212
ab60f3309436 reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents: 22
diff changeset
158 public ImageData[] load(String filename) {
22
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159 if (filename is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 InputStream stream = null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 void close(){
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163 if( stream !is null ) stream.close();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 // Ignore error
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 stream = Compatibility.newFileInputStream(filename);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 scope(exit) close();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 return load(stream);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 DWT.error(DWT.ERROR_IO, e);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 return null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 * Saves the image data in this ImageLoader to the specified stream.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 * The format parameter can have one of the following values:
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 * <dl>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 * <dt><code>IMAGE_BMP</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184 * <dd>Windows BMP file format, no compression</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 * <dt><code>IMAGE_BMP_RLE</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 * <dd>Windows BMP file format, RLE compression if appropriate</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 * <dt><code>IMAGE_GIF</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 * <dd>GIF file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 * <dt><code>IMAGE_ICO</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 * <dd>Windows ICO file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191 * <dt><code>IMAGE_JPEG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 * <dd>JPEG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 * <dt><code>IMAGE_PNG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 * <dd>PNG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 * </dl>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 * @param stream the output stream to write the images to
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 * @param format the format to write the images in
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
199 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
200 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
201 * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204 * <li>ERROR_IO - if an IO error occurs while writing to the stream</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 * <li>ERROR_INVALID_IMAGE - if the image data contains invalid data</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 * <li>ERROR_UNSUPPORTED_FORMAT - if the image data cannot be saved to the requested format</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
209 public void save(OutputStream stream, int format) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
210 if (stream is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 FileFormat.save(stream, format, this);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
214 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 * Saves the image data in this ImageLoader to a file with the specified name.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216 * The format parameter can have one of the following values:
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217 * <dl>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 * <dt><code>IMAGE_BMP</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
219 * <dd>Windows BMP file format, no compression</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220 * <dt><code>IMAGE_BMP_RLE</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 * <dd>Windows BMP file format, RLE compression if appropriate</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 * <dt><code>IMAGE_GIF</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
223 * <dd>GIF file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 * <dt><code>IMAGE_ICO</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
225 * <dd>Windows ICO file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 * <dt><code>IMAGE_JPEG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 * <dd>JPEG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 * <dt><code>IMAGE_PNG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
229 * <dd>PNG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 * </dl>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232 * @param filename the name of the file to write the images to
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233 * @param format the format to write the images in
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
234 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
235 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
236 * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
237 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 * <li>ERROR_IO - if an IO error occurs while writing to the file</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
240 * <li>ERROR_INVALID_IMAGE - if the image data contains invalid data</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 * <li>ERROR_UNSUPPORTED_FORMAT - if the image data cannot be saved to the requested format</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
243 */
212
ab60f3309436 reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents: 22
diff changeset
244 public void save(String filename, int format) {
22
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 if (filename is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 OutputStream stream = null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
247 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
248 stream = Compatibility.newFileOutputStream(filename);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
249 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250 DWT.error(DWT.ERROR_IO, e);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
251 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
252 save(stream, format);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
253 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 stream.close();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
255 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
256 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
257 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
258
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
259 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
260 * Adds the listener to the collection of listeners who will be
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261 * notified when image data is either partially or completely loaded.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 * <p>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
263 * An ImageLoaderListener should be added before invoking
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
264 * one of the receiver's load methods. The listener's
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
265 * <code>imageDataLoaded</code> method is called when image
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
266 * data has been partially loaded, as is supported by interlaced
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
267 * GIF/PNG or progressive JPEG images.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
268 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
269 * @param listener the listener which should be notified
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
270 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
271 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
272 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
273 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
274 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
275 * @see ImageLoaderListener
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
276 * @see ImageLoaderEvent
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
277 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
278 public void addImageLoaderListener(ImageLoaderListener listener) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
279 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
280 imageLoaderListeners ~= listener;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
281 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
282
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
283 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
284 * Removes the listener from the collection of listeners who will be
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
285 * notified when image data is either partially or completely loaded.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
286 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
287 * @param listener the listener which should no longer be notified
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
288 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
289 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
290 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
291 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
292 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
293 * @see #addImageLoaderListener(ImageLoaderListener)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
294 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
295 public void removeImageLoaderListener(ImageLoaderListener listener) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
296 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
297 if (imageLoaderListeners.length == 0 ) return;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 tango.core.Array.remove( imageLoaderListeners, listener, delegate bool(ImageLoaderListener l1, ImageLoaderListener l2 ){ return l1 is l2; });
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
300
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
301 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302 * Returns <code>true</code> if the receiver has image loader
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303 * listeners, and <code>false</code> otherwise.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
304 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
305 * @return <code>true</code> if there are <code>ImageLoaderListener</code>s, and <code>false</code> otherwise
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
306 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307 * @see #addImageLoaderListener(ImageLoaderListener)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308 * @see #removeImageLoaderListener(ImageLoaderListener)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
309 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 public bool hasListeners() {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
311 return imageLoaderListeners.length > 0;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
312 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
313
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
314 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
315 * Notifies all image loader listeners that an image loader event
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
316 * has occurred. Pass the specified event object to each listener.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
317 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
318 * @param event the <code>ImageLoaderEvent</code> to send to each <code>ImageLoaderListener</code>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
319 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
320 public void notifyListeners(ImageLoaderEvent event) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
321 if (!hasListeners()) return;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
322 foreach( listener; imageLoaderListeners ){
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
323 listener.imageDataLoaded(event);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
324 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
325 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
326
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
327 }