2010-05-04 126 views
0

我試圖使用JAI創建單個鑲嵌組成4個TIF圖像的每一個是5000 X 5000我所編寫的代碼是如下圖像的馬賽克..問題創建使用JAI

RenderedOp mosaic=null; 
    ParameterBlock pbMosaic=new ParameterBlock(); 
    pbMosaic.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY); 
    RenderedOp in=null; 
    // Get 4 tiles and add them to the Mosaic 
    in=returnRenderedOp(path,"northwest.tif"); 
    pbMosaic.addSource(in); 
    in=returnRenderedOp(path,"northeast.tif"); 
    pbMosaic.addSource(in); 
    in=returnRenderedOp(path,"southwest.tif"); 
    pbMosaic.addSource(in);  
    in=returnRenderedOp(path,"southeast.tif"); 
    pbMosaic.addSource(in); 
    // Setup the ImageLayout 
    ImageLayout imageLayout=new ImageLayout(0,0,10000,10000); 
    imageLayout.setTileWidth(5000); 
    imageLayout.setTileHeight(5000); 
    imageLayout.setColorModel(in.getColorModel()); 
    imageLayout.setSampleModel(in.getSampleModel()); 
    mosaic=JAI.create("mosaic",pbMosaic,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,imageLayout)); 

問題是,所有4張圖像都位於鑲嵌圖左上角的相同位置,所以其他四分之三的圖像都是空的。任何人都可以告訴我如何選擇組成馬賽克的每幅圖片的位置,以便每個圖片都出現在正確的位置?

感謝

伊恩

回答

1

http://download.oracle.com/docs/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/MosaicDescriptor.html

我想你是誤會你需要操作前設置了minX MINY每個源圖像的文檔。

northwest.tif應具有其minX = 0和MINY = 0,

northeast.tif應具有其minX = 5000和MINY = 0,

southwest.tif應具有其minX = 0,MINY = 5000和

southeast.tif應該有瘋丫頭= 5000和MINY = 5000

在他們建議您直接反序列化文件「移動」通過使用反序列化操作呈現提示的文檔。

不知何故,馬賽克只是一個正常的合成操作。