bonjour, j'ai un projet a réaliser ou je dois faire un programme de manipulation d'images.

je suis en train de faire l'interface. mon prof m'a donné une classe pour le faire apparaitre l'image dans une fenêtre mais je ne sais pas comment l'utiliser.

je vous la met ci dessous, pouvez vous me l'expliquez et me dire comment l'utilisez.

merci pour votre aide.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.MemoryImageSource;
 
public class IntegrationImage extends Canvas {
 
    /**
         * 
         */
    private static final long serialVersionUID = 1L;
 
    protected Image img;
 
    protected int width;
    protected int height;
    protected int size;
 
    protected int[] pixels;
 
    public IntegrationImage(int width, int height) {
	this.width = width;
	this.height = height;
	this.size = width * height;
    }
 
    /**
     * Constructeur à partir d'un tableau une dimension
     * 
     * @param width
     * @param height
     * @param tab
     */
 
    public IntegrationImage() {
 
    }
 
    public IntegrationImage(int width, int height, int[] tab) {
	this(width, height);
	this.pixels = this.getTabPixel(tab);
	this.build();
 
    }
 
    /**
     * Constructeur à partir d'un tableau deux dimensions
     * 
     * @param width
     * @param height
     * @param tab
     */
    public IntegrationImage(int width, int height, int[][] tab) {
	this(width, height);
	this.pixels = this.getTabPixel(tab);
	this.build();
    }
 
    /**
     * Transforme le tableau
     * 
     * @param tab
     * @return
     */
    protected int[] getTabPixel(int[] tab) {
	int[] res = new int[this.size];
	for (int i = 0; i < this.size; i++)
	    res[i] = 0xFF000000 + tab[i] * 0x010101;
	return res;
    }
 
    /**
     * Transforme le tableau
     * 
     * @param tab
     * @return
     */
    protected int[] getTabPixel(int[][] tab) {
	int[] res = new int[this.size];
	for (int i = 0; i < tab.length; i++)
	    for (int j = 0; j < tab[0].length; j++)
		res[i * tab.length + j] = tab[i][j];
	return this.getTabPixel(res);
    }
 
    /**
     * Construit
     */
    protected void build() {
	MemoryImageSource source = new MemoryImageSource(this.width,
		this.height, this.pixels, 0, this.width);
	this.img = Toolkit.getDefaultToolkit().createImage(source);
    }
 
    @Override
    public void paint(Graphics gr) {
	gr.drawImage(this.img, 0, 0, this);
    }
 
}