annotate dwt/graphics/ImageLoader.d @ 312:ebe343095cf1

Fix tango.core.Array.remove use
author Frank Benoit <benoit@tionex.de>
date Fri, 19 Sep 2008 22:37:37 +0200
parents fd9c62a2998e
children
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 /*******************************************************************************
246
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
22
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>
246
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
50 *
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
51 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ImageAnalyzer</a>
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
52 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
22
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 public class ImageLoader {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 * 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
59 * 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
60 * 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
61 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 public ImageData[] data;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 * 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
66 * 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
67 * Logical Screen Width value)
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 public int logicalScreenWidth;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 * 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
73 * 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
74 * Logical Screen Height value)
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 public int logicalScreenHeight;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 * 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
80 * 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
81 * 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
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 public int backgroundPixel;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 * 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
88 * 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
89 * 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
90 * 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
91 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 public int repeatCount;
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 /*
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 * 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
96 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 ImageLoaderListener[] imageLoaderListeners;
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 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 * Construct a new empty ImageLoader.
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 public this() {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 reset();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105
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 * 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
108 * <code>imageLoaderListeners</code> field.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 void reset() {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 data = null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 logicalScreenWidth = 0;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 logicalScreenHeight = 0;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 backgroundPixel = -1;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 repeatCount = 1;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 * 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
120 * 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
121 * 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
122 * 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
123 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 * @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
125 * @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
126 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 * <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
129 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 * <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
132 * <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
133 * <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
134 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 public ImageData[] load(InputStream stream) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 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
138 reset();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139 data = FileFormat.load(stream, this);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 return data;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 * 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
145 * 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
146 * 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
147 * 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
148 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 * @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
150 * @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
151 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 * <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
154 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 * <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
157 * <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
158 * <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
159 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 */
212
ab60f3309436 reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents: 22
diff changeset
161 public ImageData[] load(String filename) {
22
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 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
163 InputStream stream = null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 void close(){
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 if( stream !is null ) stream.close();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 // Ignore error
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 stream = Compatibility.newFileInputStream(filename);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 scope(exit) close();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 return load(stream);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 DWT.error(DWT.ERROR_IO, e);
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 return null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 * 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
184 * 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
185 * <dl>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 * <dt><code>IMAGE_BMP</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 * <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
188 * <dt><code>IMAGE_BMP_RLE</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 * <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
190 * <dt><code>IMAGE_GIF</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191 * <dd>GIF file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 * <dt><code>IMAGE_ICO</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 * <dd>Windows ICO file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 * <dt><code>IMAGE_JPEG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 * <dd>JPEG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196 * <dt><code>IMAGE_PNG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 * <dd>PNG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 * </dl>
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 * @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
201 * @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
202 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204 * <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
205 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 * <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
208 * <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
209 * <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
210 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 public void save(OutputStream stream, int format) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213 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
214 FileFormat.save(stream, format, this);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 * 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
219 * 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
220 * <dl>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 * <dt><code>IMAGE_BMP</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 * <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
223 * <dt><code>IMAGE_BMP_RLE</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 * <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
225 * <dt><code>IMAGE_GIF</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 * <dd>GIF file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 * <dt><code>IMAGE_ICO</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 * <dd>Windows ICO file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
229 * <dt><code>IMAGE_JPEG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 * <dd>JPEG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 * <dt><code>IMAGE_PNG</code></dt>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232 * <dd>PNG file format</dd>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233 * </dl>
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 * @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
236 * @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
237 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 * <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
240 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 * @exception DWTException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 * <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
243 * <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
244 * <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
245 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 */
212
ab60f3309436 reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents: 22
diff changeset
247 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
248 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
249 OutputStream stream = null;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
251 stream = Compatibility.newFileOutputStream(filename);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
252 } catch (IOException e) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
253 DWT.error(DWT.ERROR_IO, e);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
255 save(stream, format);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
256 try {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
257 stream.close();
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
258 } catch (IOException e) {
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 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 /**
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
263 * 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
264 * 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
265 * <p>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
266 * An ImageLoaderListener should be added before invoking
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
267 * 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
268 * <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
269 * 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
270 * GIF/PNG or progressive JPEG images.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
271 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
272 * @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
273 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
274 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
275 * <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
276 * </ul>
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 * @see ImageLoaderListener
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
279 * @see ImageLoaderEvent
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
280 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
281 public void addImageLoaderListener(ImageLoaderListener listener) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
282 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
283 imageLoaderListeners ~= listener;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
284 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
285
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 * 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
288 * 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
289 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
290 * @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
291 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
292 * @exception IllegalArgumentException <ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
293 * <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
294 * </ul>
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
295 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
296 * @see #addImageLoaderListener(ImageLoaderListener)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
297 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 public void removeImageLoaderListener(ImageLoaderListener listener) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 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
300 if (imageLoaderListeners.length == 0 ) return;
312
ebe343095cf1 Fix tango.core.Array.remove use
Frank Benoit <benoit@tionex.de>
parents: 246
diff changeset
301 imageLoaderListeners.length = tango.core.Array.remove( imageLoaderListeners, listener, delegate bool(ImageLoaderListener l1, ImageLoaderListener l2 ){ return l1 is l2; });
22
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303
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 * 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
306 * listeners, and <code>false</code> otherwise.
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308 * @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
309 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 * @see #addImageLoaderListener(ImageLoaderListener)
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
311 * @see #removeImageLoaderListener(ImageLoaderListener)
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 public bool hasListeners() {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
314 return imageLoaderListeners.length > 0;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
315 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
316
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 * 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
319 * 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
320 *
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
321 * @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
322 */
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
323 public void notifyListeners(ImageLoaderEvent event) {
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
324 if (!hasListeners()) return;
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
325 foreach( listener; imageLoaderListeners ){
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
326 listener.imageDataLoaded(event);
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
327 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
328 }
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
329
5f2e72114476 Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
330 }