source: trunk/tests/SWT/java/SWT006_01.java

Last change on this file was 12, checked in by lpino, 18 years ago
  • Initial commit
File size: 23.7 KB
Line 
1/*
2 * SWT006_01.java
3 */
4
5/*
6 * Copyright (c) 2002, 2004 EclipseOS2 Team.
7 * This file is made available under the terms of the Common Public License v1.0
8 * which accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/cpl-v10.html
10 */
11
12import java.util.ArrayList;
13import java.util.Iterator;
14import org.eclipse.swt.*;
15import org.eclipse.swt.widgets.*;
16import org.eclipse.swt.events.*;
17import org.eclipse.swt.graphics.*;
18import org.eclipse.swt.layout.FormAttachment;
19import org.eclipse.swt.layout.FormData;
20import org.eclipse.swt.layout.FormLayout;
21
22/**
23 * This example tests image drawing.
24 *
25 * Page #0
26 * -------
27 *
28 * This test checks scaling and XOR functions in different modes:
29 *
30 * 1. a 8-bit image is drawn as is and then a part of it (marked on the
31 * original with a dotted rectangle) is drawn in different proportions,
32 * then the same is repeated in the XOR mode.
33 * 2. a blank image with the display preferred depth is created, some
34 * graphics is drawn on it and then it is scaled as above.
35 * 3. a combination of the above two: a 8-bit image is taken again
36 * and graphics is drawn on it.
37 * 4. a blank image is created with the abive 8-bit image color depth and
38 * palette and then everything is repeated.
39 *
40 * Also, for images from 2 to 4 background and foreground colors are queried
41 * and printed to the log just after the GC is created and then after drawing
42 * the red circle (when the foreground is changed). Note that on images
43 * 3 and 4 the circle is not actually in red, it has the color closest to the
44 * red in the image's palette.
45 *
46 * For all images, after drawing, an image copy is created using the
47 * getImageData() method and then painted to the right. For the first
48 * image getImageData() is called BEFORE the image's GC is disposed, for all
49 * others -- AFTER it.
50 *
51 * Note that the background of the image 4 is dark -- this is because it is
52 * created using a blank ImageData instance which initially fills the image data
53 * with zeroes, that corresponds to the 0th index in the image's palette (a
54 * color close to black in our case) for palette-based images or to the black
55 * RGB color for direct color images.
56 *
57 * Page #1
58 * -------
59 *
60 * Tests loading and drawing images from files of different image formats.
61 * All images in one row must look identically except 1-bit images at the
62 * bottom, where every image has its own color for "foreground" pixels.
63 *
64 * Page #2
65 * -------
66 *
67 * Tests image transparency:
68 *
69 * 1. the 1-bit image is drawin and scaled (as on the page #0) having its
70 * "background" pixels as transparent ones.
71 * 2. the 1-bit image is drawin and scaled as above having its
72 * "foreground" pixels as transparent ones.
73 * 3. the 24-bit image is drawin and scaled as above having white pixels as
74 * transparent ones.
75 *
76 * Page #3
77 * -------
78 *
79 * Tests image alpha settings:
80 *
81 * 1. the 8-bit image is the same as on the page #0, but with alpha data
82 * manually set to appear as half-transparent in its upper third.
83 * 2. the same image but loaded from the PNG file which contains complex alpha.
84 *
85 * Page #4
86 * -------
87 *
88 * Tests the GC.fillGradientRectangle() method which draws a gradient strip
89 * processing from the current background color to the foreground.
90 *
91 * Page #5
92 * -------
93 *
94 * Tests icon scaling. First two icons are also copied using the getImageData()
95 * method and copies are drawn to the right.
96 *
97 * Two last rows are icons indirectly created from separate icon and mask
98 * image data using the corresponding Image constructor. Note that the last
99 * but one icon is drawn inverted where the last icon is transparent -- this
100 * is because the former is created from the palette-based image which doesn't
101 * have the black color in its palette nor the space to add it (transparent
102 * pixels must be black in order for the icon transparency to work).
103 *
104 * Page #6
105 * -------
106 *
107 * Tests for the Image copy constructor (one that takes one of SWT_IMAGE_*
108 * conatants as its last parameter). First column is created using
109 * SWT_IMAGE_COPY, second -- using SWT_IMAGE_DISABLE and third -- using
110 * SWT_IMAGE_GRAY. First three rows are bitmaps, last three are icons.
111 *
112 * Test output
113 * -----------
114 *
115 * This testcase also performs tests of Image.getBackground() /
116 * setBackground() and GC.getBackground() / setBackground() for images and
117 * its output should contain the following:
118
119[img2]:
120gc bg (before) = Color {255, 255, 255}
121gc fg (before) = Color {0, 0, 0}
122gc fg (after) = Color {255, 0, 0}
123[img3]:
124gc bg (before) = Color {255, 255, 255}
125gc fg (before) = Color {0, 0, 0}
126gc fg (after) = Color {255, 0, 0}
127[img4]:
128gc bg (before) = Color {255, 255, 255}
129gc fg (before) = Color {0, 0, 0}
130gc fg (after) = Color {255, 0, 0}
131img01.1.tr-b.gif: transparent (before) = Color {135, 0, 0}
132img01.1.tr-f.gif: transparent (before) = Color {0, 0, 255}
133img01.24.tr.png: transparent (before) = Color {255, 255, 255}
134img01.1.tr-b.gif: transparent (after) = Color {128, 128, 128}
135img01.1.tr-f.gif: transparent (after) = Color {128, 128, 128}
136img01.24.tr.png: transparent (after) = Color {128, 128, 128}
137
138 * When the system is in 256-color mode the last but five line will be:
139
140img01.1.tr-b.gif: transparent (before) = Color {128, 0, 0}
141
142 * This is because the default palette doesn't have the color with these
143 * RGB values, so the best match is returned.
144 *
145 * This testcase also saves all 15 images from the page #1 to the current
146 * working directory for comparison with originals -- they should be the
147 * same. However, when the system is in 256-color mode saving images doesn't
148 * work as desired -- this issue is descrbed in the $CVSROOT/doc/diff.html,
149 * difference #007.
150 *
151 *
152 * General note. When the Chechers checkbox is un-checked, the "corruption"
153 * behavior of XORed images when sizing is expected because the widget is in
154 * SWT.NO_REDRAW_RESIZE mode (i.e. it isn't completely redrawn when sizing,
155 * so different parts of images can be XORed different number of times).
156 * The same applies to images that have the alpha channel.
157 */
158
159public class SWT006_01 extends SWTTestCase {
160
161static {
162 STEP= "006";
163 TEST = "01";
164 DESC = "Images";
165}
166
167
168int page = 0;
169final static int LAST_PAGE = 6;
170
171Shell shell;
172Button next;
173static String Title;
174
175boolean drawCheckers = true;
176Image background = null;
177
178final static String imageDir = System.getProperty ("user.dir") +
179 "/tests/SWT/images/";
180
181public static void main (String [] args) {
182 Title = "Images";
183 go (new SWT006_01 ());
184}
185
186Shell createTopShell (Display display) {
187
188 shell = new Shell (display,
189 SWT.SHELL_TRIM | SWT.NO_REDRAW_RESIZE);// | SWT.NO_MERGE_PAINTS);
190
191 final Image img1 = new Image (display, imageDir + "icon48_full.bmp");
192 ImageData imgData = img1.getImageData ();
193 final Image img1_copy = new Image (display, imgData);
194
195 final Image img2 = new Image (display, 48, 48);
196 say ("[img2]:");
197 final Image img2_copy = drawTwoCircles (img2, true);
198
199 final Image img3 = new Image (display, imgData);
200 say ("[img3]:");
201 drawTwoCircles (img3, false);
202 final Image img3_copy = new Image (display, img3.getImageData ());
203
204// RGB[] rgbs = new RGB [16];
205// for (int i = 0; i < rgbs.length; i++) rgbs [i] = imgData.palette.colors[i];
206// rgbs [0] = rgbs [2];
207 PaletteData palData = new PaletteData (new RGB[] {
208 new RGB (100, 100, 100),
209 new RGB (222, 0, 0),
210 new RGB (50, 50, 50),
211 });
212 final Image img4 = new Image (display,
213// new ImageData (48, 48, 4, new PaletteData (rgbs)));
214 new ImageData (48, 48, 4, palData));
215 say ("[img4]:");
216 drawTwoCircles (img4, false);
217 final Image img4_copy = new Image (display, img4.getImageData ());
218
219 for (int y = 0; y < imgData.height; y++) {
220 for (int x = 0; x < imgData.width; x++) {
221 imgData.setAlpha (x, y, y < imgData.height / 3 ? 128 : 255);
222 }
223 }
224 final Image img1_alpha = new Image (display, imgData);
225 final Image img1_alpha2 = new Image (display,
226 imageDir + "icon48_full.alpha.png");
227
228 final Image img5 = new Image (display, imageDir + "img01.1.tr-b.gif");
229 final Image img6 = new Image (display, imageDir + "img01.1.tr-f.gif");
230 final Image img7 = new Image (display, imageDir + "img01.24.tr.png");
231 say ("img01.1.tr-b.gif: transparent (before) = " + img5.getBackground());
232 say ("img01.1.tr-f.gif: transparent (before) = " + img6.getBackground());
233 say ("img01.24.tr.png: transparent (before) = " + img7.getBackground());
234 {
235 Color clr = new Color (display, new RGB (128, 128, 128));
236 img5.setBackground (clr);
237 img6.setBackground (clr);
238 img7.setBackground (clr);
239 clr.dispose();
240 }
241 say ("img01.1.tr-b.gif: transparent (after) = " + img5.getBackground());
242 say ("img01.1.tr-f.gif: transparent (after) = " + img6.getBackground());
243 say ("img01.24.tr.png: transparent (after) = " + img7.getBackground());
244
245 final ArrayList images = new ArrayList ();
246 final String[] imgFiles = {
247 imageDir + "img01.24.bmp",
248 imageDir + "img01.24.jpg",
249 imageDir + "img01.24.png",
250 imageDir + "img01.8.bmp",
251 imageDir + "img01.8.gif",
252 imageDir + "img01.8.png",
253 imageDir + "img01.gray.bmp",
254 imageDir + "img01.gray.gif",
255 imageDir + "img01.gray.png",
256 imageDir + "img01.4.bmp",
257 imageDir + "img01.4.gif",
258 imageDir + "img01.4.png",
259 imageDir + "img01.1.bmp",
260 imageDir + "img01.1.gif",
261 imageDir + "img01.1.png"
262 };
263 for (int i = 0; i < imgFiles.length; i ++) {
264 Image img = new Image (display, imgFiles[i]);
265 images.add (img);
266 String name = imgFiles [i];
267 name = "out-" + name.substring (imageDir.length());
268 saveImage (img, name);
269 }
270
271 final Image ico1 = new Image (display, imageDir + "test.ico");
272 final Image ico1_copy = new Image (display, ico1.getImageData());
273 final Image ico2 = new Image (display, imageDir + "test_bw.ico");
274 final Image ico2_copy = new Image (display, ico2.getImageData());
275 ImageLoader il = new ImageLoader ();
276 ImageData[] iconData = il.load (imageDir + "eclipse.ico");
277 final Image[] icons = new Image[iconData.length];
278 for (int i = 0; i < iconData.length; i++) {
279 icons[i] = new Image (display, iconData[i]);
280 }
281
282 final Image img5_copy = new Image (display, img5, SWT.IMAGE_COPY);
283 final Image img6_copy = new Image (
284 display, (Image) images.get (4), SWT.IMAGE_COPY);
285 final Image img7_copy = new Image (display, img7, SWT.IMAGE_COPY);
286 final Image img5_dis = new Image (display, img5, SWT.IMAGE_DISABLE);
287 final Image img6_dis = new Image (
288 display, (Image) images.get (4), SWT.IMAGE_DISABLE);
289 final Image img7_dis = new Image (display, img7, SWT.IMAGE_DISABLE);
290 final Image img5_gray = new Image (display, img5, SWT.IMAGE_GRAY);
291 final Image img6_gray = new Image (
292 display, (Image) images.get (4), SWT.IMAGE_GRAY);
293 final Image img7_gray = new Image (display, img7, SWT.IMAGE_GRAY);
294
295 final Image ico1_copy2 = new Image (display, ico1, SWT.IMAGE_COPY);
296 final Image ico2_copy2 = new Image (display, ico2, SWT.IMAGE_COPY);
297 final Image ico3_copy2 = new Image (
298 display, icons [icons.length - 3], SWT.IMAGE_COPY);
299 final Image ico1_dis = new Image (display, ico1, SWT.IMAGE_DISABLE);
300 final Image ico2_dis = new Image (display, ico2, SWT.IMAGE_DISABLE);
301 final Image ico3_dis = new Image (
302 display, icons [icons.length - 3], SWT.IMAGE_DISABLE);
303 final Image ico1_gray = new Image (display, ico1, SWT.IMAGE_GRAY);
304 final Image ico2_gray = new Image (display, ico2, SWT.IMAGE_GRAY);
305 final Image ico3_gray = new Image (
306 display, icons [icons.length - 3], SWT.IMAGE_GRAY);
307
308 final Image ico1_indirect;
309 final Image ico2_indirect;
310 {
311 ImageData data = new ImageData (
312 48, 48, 1, new PaletteData (new RGB[] {
313 new RGB (0, 0, 0), new RGB (255, 255, 255)
314 })
315 );
316 Image mask = new Image (display, data);
317 GC gc = new GC (mask);
318 gc.setForeground(gc.getBackground());
319 gc.fillOval (6, 5, 40, 40);
320 gc.dispose ();
321 data = img1.getImageData();
322 ico1_indirect = new Image (display, data, mask.getImageData());
323 data = img1_alpha2.getImageData();
324 ico2_indirect = new Image (display, data, mask.getImageData());
325 mask.dispose();
326 }
327
328 shell.addDisposeListener (new DisposeListener () {
329 public void widgetDisposed (DisposeEvent e) {
330 if (background != null) background.dispose();
331 img1.dispose();
332 img1_copy.dispose();
333 img2.dispose();
334 img2_copy.dispose();
335 img3.dispose();
336 img3_copy.dispose();
337 img4.dispose();
338 img4_copy.dispose();
339 img1_alpha.dispose();
340 img1_alpha2.dispose();
341 img5.dispose();
342 img6.dispose();
343 img7.dispose();
344 ico1.dispose();
345 ico2.dispose();
346 ico1_copy.dispose();
347 ico2_copy.dispose();
348 Iterator it = images.iterator();
349 while (it.hasNext ()) ((Image)it.next()).dispose();
350 for (int i = 0; i < icons.length; i++) icons [i].dispose();
351 img5_copy.dispose();
352 img6_copy.dispose();
353 img7_copy.dispose();
354 img5_dis.dispose();
355 img6_dis.dispose();
356 img7_dis.dispose();
357 img5_gray.dispose();
358 img6_gray.dispose();
359 img7_gray.dispose();
360 ico1_copy2.dispose();
361 ico2_copy2.dispose();
362 ico3_copy2.dispose();
363 ico1_dis.dispose();
364 ico2_dis.dispose();
365 ico3_dis.dispose();
366 ico1_gray.dispose();
367 ico2_gray.dispose();
368 ico3_gray.dispose();
369 ico1_indirect.dispose();
370 ico2_indirect.dispose();
371 }
372 });
373
374 shell.addPaintListener(new PaintListener () {
375 public void paintControl(PaintEvent event) {
376 GC gc = event.gc;
377
378 Rectangle r = new Rectangle (event.x, event.y, event.width, event.height);
379 gc.setClipping (r);
380 drawGrid (gc,
381 (r.x / 20) * 20, (r.y / 20) * 20,
382 r.width + 20, r.height + 20, 10);
383
384 switch (page) {
385 case 0:
386 drawImgPieces (gc, img1, 10, 10, 10, 0, 0, 24, 24);
387 gc.setXORMode (true);
388 drawImgPieces (gc, img1, 10, 80, 10, 0, 0, 24, 24);
389 gc.setXORMode (false);
390 drawImgPieces (gc, img2, 10, 150, 10, 0, 0, 24, 24);
391 gc.setXORMode (true);
392 drawImgPieces (gc, img2, 10, 220, 10, 0, 0, 24, 24);
393 gc.setXORMode (false);
394 drawImgPieces (gc, img3, 10, 290, 10, 0, 0, 24, 24);
395 gc.setXORMode (true);
396 drawImgPieces (gc, img3, 10, 360, 10, 0, 0, 24, 24);
397 gc.setXORMode (false);
398 drawImgPieces (gc, img4, 10, 430, 10, 0, 0, 24, 24);
399 gc.setXORMode (true);
400 drawImgPieces (gc, img4, 10, 500, 10, 0, 0, 24, 24);
401 gc.setXORMode (false);
402 gc.drawImage (img1_copy, 480, 10);
403 gc.drawImage (img2_copy, 480, 150);
404 gc.drawImage (img3_copy, 480, 290);
405 gc.drawImage (img4_copy, 480, 430);
406 break;
407 case 1:
408 for (int i = 0; i < images.size (); i++) {
409 Image img = (Image)images.get (i);
410 gc.drawImage (img, 10 + (i % 3) * 260, 10 + (i / 3) * 120);
411 }
412 break;
413 case 2:
414 drawImgPieces (gc, img5, 10, 10, 10, 0, 40, 40, 40);
415 drawImgPieces (gc, img6, 10, 130, 10, 0, 40, 40, 40);
416 drawImgPieces (gc, img7, 10, 250, 10, 0, 40, 40, 40);
417 break;
418 case 3:
419 drawImgPieces (gc, img1_alpha, 10, 10, 10, 0, 0, 24, 24);
420 drawImgPieces (gc, img1_alpha2, 10, 80, 10, 0, 0, 24, 24);
421 break;
422 case 4:
423 gc.fillGradientRectangle (10, 10, 200, 40, false);
424 gc.fillGradientRectangle (210, 60, -200, 40, false);
425 gc.fillGradientRectangle (10, 110, 40, 200, true);
426 gc.fillGradientRectangle (60, 310, 40, -200, true);
427 break;
428 case 5:
429 drawImgPieces (gc, ico1, 10, 10, 10, 0, 0, 24, 24);
430 gc.drawImage (ico1_copy, 480, 10);
431 drawImgPieces (gc, ico2, 10, 70, 10, 0, 0, 24, 24);
432 gc.drawImage (ico2_copy, 480, 70);
433 int h = 130;
434 for (int i = 0; i < icons.length; i++) {
435 Rectangle ib = icons[i].getBounds();
436 drawImgPieces (gc, icons[i], 10, h, 10, 0, 0,
437 ib.width / 2, ib.height / 2);
438 h += 10 + ib.height;
439 }
440 drawImgPieces (gc, ico1_indirect, 10, 400, 10, 0, 0, 24, 24);
441 drawImgPieces (gc, ico2_indirect, 10, 460, 10, 0, 0, 24, 24);
442 break;
443 case 6:
444 gc.drawImage (img5_copy, 10, 10);
445 gc.drawImage (img6_copy, 10, 130);
446 gc.drawImage (img7_copy, 10, 250);
447 gc.drawImage (img5_dis, 270, 10);
448 gc.drawImage (img6_dis, 270, 130);
449 gc.drawImage (img7_dis, 270, 250);
450 gc.drawImage (img5_gray, 530, 10);
451 gc.drawImage (img6_gray, 530, 130);
452 gc.drawImage (img7_gray, 530, 250);
453 gc.drawImage (ico1_copy2, 10, 380);
454 gc.drawImage (ico2_copy2, 10, 430);
455 gc.drawImage (ico3_copy2, 10, 480);
456 gc.drawImage (ico1_dis, 270, 380);
457 gc.drawImage (ico2_dis, 270, 430);
458 gc.drawImage (ico3_dis, 270, 480);
459 gc.drawImage (ico1_gray, 530, 380);
460 gc.drawImage (ico2_gray, 530, 430);
461 gc.drawImage (ico3_gray, 530, 480);
462 break;
463 }
464 }
465 });
466
467 next = new Button (shell, SWT.PUSH);
468 next.setText ("Next >");
469 next.addSelectionListener (new SelectionAdapter () {
470 String title;
471 public void widgetSelected (SelectionEvent e) {
472 ++page;
473 if (page <= LAST_PAGE)
474 updateTitleAndButton();
475 else
476 shell.close();
477 }
478 });
479 updateTitleAndButton();
480
481 Button checks = new Button (shell, SWT.CHECK);
482 checks.setText ("Checkers");
483 checks.setSelection (drawCheckers);
484 checks.addSelectionListener (new SelectionAdapter () {
485 String title;
486 public void widgetSelected (SelectionEvent e) {
487 drawCheckers = ((Button)e.widget).getSelection ();
488 shell.redraw();
489 }
490 });
491
492 FormData fdata = new FormData();
493 fdata.right = new FormAttachment (100, -10);
494 fdata.bottom = new FormAttachment (100, -10);
495 next.setLayoutData (fdata);
496 fdata = new FormData();
497 fdata.left = new FormAttachment (0, 10);
498 fdata.bottom = new FormAttachment (100, -10);
499 checks.setLayoutData (fdata);
500 FormLayout formLayout = new FormLayout ();
501 shell.setLayout (formLayout);
502
503// Rectangle dr = display.getBounds ();
504// Rectangle sr = shell.getBounds ();
505 Rectangle dr = display.getClientArea ();
506 Rectangle sr = new Rectangle (0, 0, 880, 680);
507 sr.x = (dr.width-sr.width)/2;
508 sr.y = (dr.height-sr.height)/2;
509 shell.setBounds (sr);
510// shell.setMaximized (true);
511 return shell;
512}
513
514Image drawTwoCircles (Image img, boolean returnInUseCopy) {
515 Image img_copy = null;
516 Color clr = new Color (display, 255, 0, 0);
517 GC gc = new GC (img);
518 System.out.println("gc bg (before) = " + gc.getBackground ());
519 System.out.println("gc fg (before) = " + gc.getForeground ());
520 gc.drawOval (0, 0, 40, 40);
521 gc.setForeground (clr);
522 System.out.println("gc fg (after) = " + gc.getForeground ());
523 gc.drawOval (5, 5, 40, 40);
524 if (returnInUseCopy) {
525 img_copy = new Image (display, img.getImageData ());
526 }
527 gc.dispose ();
528 clr.dispose ();
529 return img_copy;
530}
531
532void drawImgPieces (GC gc, Image img,
533 int x0, int y0, int gap, int xp, int yp, int wp, int hp) {
534 Rectangle bounds = img.getBounds ();
535 int w0 = bounds.width;
536 int h0 = bounds.height;
537 gc.drawImage (img, x0, y0);
538 gc.drawFocus (x0 + xp, y0 + yp, wp, hp);
539 int w = w0, h, last = x0;
540 for (int i = 0; i < 9; i++) {
541 last += w + gap;
542 last += (gap - (last % gap));
543 int wb = i % 3;
544 int hb = i / 3;
545 if (wb == 0) w = wp / 2;
546 else if (wb == 1) w = wp;
547 else w = wp * 2;
548 if (hb == 0) h = hp / 2;
549 else if (hb == 1) h = hp;
550 else h = hp * 2;
551 gc.drawImage (img, xp, yp, wp, hp, last, y0, w, h);
552 }
553}
554
555void drawGrid (GC gc, int x0, int y0, int width, int height, int step) {
556 if (drawCheckers) {
557 if (background == null) {
558 int w = 20, h = 20;
559 Display display = Display.getDefault();
560 background = new Image (display, w, h);
561 GC bgc = new GC (background);
562 Color c1 = new Color (display, 255, 255, 255);
563 Color c2 = new Color (display, 192, 192, 192);
564 bgc.setBackground (c1);
565 bgc.fillRectangle(0, 0, 10, 10);
566 bgc.fillRectangle(10, 10, 10, 10);
567 bgc.setBackground (c2);
568 bgc.fillRectangle(10, 0, 10, 10);
569 bgc.fillRectangle(0, 10, 10, 10);
570 c1.dispose();
571 c2.dispose();
572 bgc.dispose();
573 }
574 Rectangle r = background.getBounds();
575 for (int y = 0; y <= height; y += r.height)
576 for (int x = 0; x <= width; x += r.width)
577 gc.drawImage (background, x0 + x, y0 + y);
578 } else {
579 int i;
580 for (i = 0; i <= width/step; i++)
581 gc.drawLine (x0+i*step, y0, x0+i*step, y0+height);
582 for (i = 0; i <= height/step; i++)
583 gc.drawLine (x0, y0+i*step, x0+width, y0+i*step);
584 }
585}
586
587void updateTitleAndButton () {
588 if (page <= LAST_PAGE) {
589 if (page == LAST_PAGE)
590 next.setText ("Finish");
591 shell.redraw ();
592 }
593 shell.setText (getName() + ": " + Title + " [page #" + page + "]");
594}
595
596void saveImage (Image image, String baseName) {
597 ImageLoader il = new ImageLoader();
598 ImageData id = image.getImageData();
599 il.data = new ImageData[] {id};
600// String name = baseName + "." + id.depth + ".";
601// if (id.transparentPixel != -1 || id.maskData != null) name += "tr.";
602// if (id.alpha != -1 || id.alphaData != null) name += "alpha.";
603// name += "bmp";
604 String name = baseName + ".bmp";
605 il.save (name, SWT.IMAGE_BMP);
606}
607
608}
609
Note: See TracBrowser for help on using the repository browser.