Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 31534299608ec576bde604134c940127d5383a5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.examples.texteditor;


import java.io.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class Images {

	// Bitmap Images
	public Image Bold;
	public Image Red;
	public Image Green;
	public Image Blue;
	public Image Erase;
	
	Image  [] AllBitmaps;

Images () {
}

public void freeAll () {
	for (int i=0; i<AllBitmaps.length; i++) AllBitmaps [i].dispose ();
	AllBitmaps = null;
}

Image createBitmapImage(Display display, String fileName) {
	InputStream sourceStream = Images.class.getResourceAsStream (fileName + ".bmp");
	InputStream maskStream = Images.class.getResourceAsStream (fileName + "_mask.bmp");
	ImageData source = new ImageData (sourceStream);
	ImageData mask = new ImageData (maskStream);
	Image result = new Image (display, source, mask);
	try {
		sourceStream.close ();
		maskStream.close ();
	} catch (IOException e) {
		e.printStackTrace ();
	}
	return result;
}

public void loadAll (Display display) {
	// Bitmap Images
	Bold = createBitmapImage (display, "bold");
	Red = createBitmapImage (display, "red");
	Green = createBitmapImage (display, "green");
	Blue = createBitmapImage (display, "blue");
	Erase = createBitmapImage (display, "erase");
	
	AllBitmaps = new Image [] {
		Bold,
		Red,
		Green,
		Blue,
		Erase,
	};
}
}

Back to the top