import fr.jussieu.script.Deug; public class images_NB{ public static void dessine(boolean[][] image) { for(int i = 0; i < image.length; i++) for(int j = 0; j < image[i].length; j++) { if(image[i][j]) Deug.drawPoint(i, j); } } public static boolean[][] croix(int l, int h){ boolean[][] image = new boolean [l][h]; for(int i = 0; i < l; i++) image[i][h/2] = true; for(int j = 0; j < h; j++) image[l/2][j] = true; return image; } public static boolean[][] croixDiagonale(int l){ boolean[][] image = new boolean [l][l]; for(int i = 0; i < l; i++){ image[i][i] = true; image[i][l-1-i] = true; } return image; } public static boolean[][] superpose(boolean[][] im1, boolean[][] im2){ boolean[][] image = new boolean [im1.length][im1[0].length]; if ((im1.length != im2.length) || (im1[0].length != im2[0].length)){ Deug.println("les dimensions des 2 images ne correspondent pas"); return image; } for(int i = 0; i < image.length; i++) for(int j = 0; j < image[i].length; j++) image[i][j] = im1[i][j] || im2[i][j]; return image; } public static void main(String[] args){ int longueur = 200, hauteur = 200; Deug.startDrawings(longueur, hauteur); boolean[][] img_croix = croix(longueur, hauteur); boolean[][] img_croix_diag = croixDiagonale(longueur); boolean[][] img_superpose = superpose(img_croix, img_croix_diag); dessine(img_superpose); } }