Bonjour,
Je cherche à redimensionner une image dans mon programme.

J'ai trouvé ceci :
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
 
 
	 /*--------------------------------------------------
	   * Redimmension Image
	   *-------------------------------------------------*/
	 private Image redimImage(Image _image, int _longueur, int _hauteur){
	         int sourceWidth = _image.getWidth();
	         int sourceHeight = _image.getHeight();
	         int redimWidth = _longueur;
	         int redimHeight = _hauteur;
 
	         if (redimHeight < 0)
	             redimHeight = redimWidth * sourceHeight / sourceWidth;
 
	         if (redimWidth < 0)
	        	 redimWidth = redimHeight * sourceWidth / sourceHeight;
 
	         Image redimImage = Image.createImage(redimWidth, redimHeight);
	         Graphics g = redimImage.getGraphics();
 
	         for (int y = 0; y < redimHeight; y++)
	         {
	             for (int x = 0; x < redimWidth; x++)
	             {
	                 g.setClip(x, y, 1, 1);
	                 int dx = x * sourceWidth / redimWidth;
	                 int dy = y * sourceHeight / redimHeight;
	                 g.drawImage(_image, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
	             }
	         }
 
	         return Image.createImage(redimImage);
	     }
Voila, sa marche mais c'est très très lent donc si vous avez une autre méthode, ou bien quelque info pour améliorer ce code.
Merci