Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Images in cornerstone #5

Open
norman-ma opened this issue Jun 17, 2022 · 1 comment
Open

Loading Images in cornerstone #5

norman-ma opened this issue Jun 17, 2022 · 1 comment

Comments

@norman-ma
Copy link
Collaborator

This is where the image is loaded in cornerstone.

https://github.com/cornerstonejs/cornerstone/blob/56f51a0752955bab8a308bc900b95e28992cf3ea/src/imageLoader.js#L27

function loadImageFromImageLoader (imageId, options) {
  const colonIndex = imageId.indexOf(':');
  const scheme = imageId.substring(0, colonIndex);
  const loader = imageLoaders[scheme];

  if (loader === undefined || loader === null) {
    if (unknownImageLoader !== undefined) {
      return unknownImageLoader(imageId);
    }

    throw new Error('loadImageFromImageLoader: no image loader for imageId');
  }

  const imageLoadObject = loader(imageId, options);

  // Broadcast an image loaded event once the image is loaded
  imageLoadObject.promise.then(function (image) {
    triggerEvent(events, EVENTS.IMAGE_LOADED, { image });
  }, function (error) {
    const errorObject = {
      imageId,
      error
    };

    triggerEvent(events, EVENTS.IMAGE_LOAD_FAILED, errorObject);
  });

  return imageLoadObject;
}
@norman-ma
Copy link
Collaborator Author

This is where is is invoked in OHIF (cornerstone.loadImage() is a wrapper).

prefetchImageIds(imageIds) {

prefetchImageIds(imageIds) {
    const nonCachedImageIds = this.filterCachedImageIds(imageIds);
    const imageLoadPoolManager = cornerstone.imageLoadPoolManager;

    let requestFn;
    if (this.options.preventCache) {
      requestFn = id => cornerstone.loadImage(id);
    } else {
      requestFn = id => cornerstone.loadAndCacheImage(id);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant