cornerstoneWADOImageLoader是支持multi-frame的,官方有提供example:
https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/examples/wadourimultiframe/index.html
用法寫的很明白,主要是通過在wado url后加上frame參數(shù)來切分,實際用的時候有問題想補充一下。
下面官方例子中的代碼中要注意unload這個一定要加,要釋放cache,不然loadAndCacheImage的時候就會報"frame exceeds size of pixelData"錯誤。除了unload,如果你的業(yè)務(wù)場景不方便用這個方法來指定清楚這個url對應(yīng)的cache的話,也可以使用 cornerstoneWADOImageLoader.wadouri.dataSetCacheManager.purge()
我用下來多幀圖像的首次加載是需要一張一張加載的,每加載一張清一次cache,才不會報錯(不知道是不是有cachesize之類,或者是我用法不對,有知道的小伙伴麻煩評論告訴我,感謝)。所以比如scroll的場景,和預(yù)加載的場景,都需要注意單張加載且及時清理。
cornerstone.loadAndCacheImage(imageIds[0]).then(function(image) {
// now that we have an image frame in the cornerstone cache, we can decrement
// the reference count added by load() above when we loaded the metadata. This way
// cornerstone will free all memory once all imageId's are removed from the cache
cornerstoneWADOImageLoader.wadouri.dataSetCacheManager.unload(url);
cornerstone.displayImage(element, image);
.....
}, function(err) {
alert(err);
});