2010-02-03 6 views

Répondre

1

Je ne sais pas à propos de Jai, mais voici l'approche BufferedImage que vous pourriez utiliser comme entrée pour JAI. Alors peut-être que cela fonctionne pour votre usecase

public static BufferedImage[] divide(BufferedImage source) { 
    // for odd widths or heights, the last row or column will be ignored 
    // fixing this behaviour is left as an exercise to the eager 
    int height = source.getHeight()/2; 
    int width = source.getWidth()/2; 

    return new BufferedImage[] { 
    source.getSubimage(0, 0, height, width), // top left 
    source.getSubimage(width, 0, height, width), // top right 
    source.getSubimage(0, height, height, width), // bottom left 
    source.getSubimage(width, height, width, height) // bottom right 
    }; 
} 
1

Il y a un peu intéressant de Trompe-l'œil dans Java2D* démo en utilisant quatre unequal parts de dim.

* Voir le quadrant inférieur droit de l'onglet Images.

+0

+1 pour me faire interroger sur ce Trompe-l'œil signifie ;-) – stacker

1

Dans l'exemple, la largeur doit être supérieure à la hauteur. C'est:

source.getSubimage(0, 0,width, height), // top left 
source.getSubimage(width, 0, width, height), // top right 
source.getSubimage(0, height, width, height), // bottom left