src/main/java/com/spinyowl/legui/image/StbBackedLoadableImage.java
@Override
  public void load() {
    try {
      ByteBuffer byteBuffer = IOUtil.resourceToByteBuffer(getPath());
      int[] w = {0};
      int[] h = {0};
      int[] c = {0};
      ByteBuffer buffer = STBImage.stbi_load_from_memory(byteBuffer, w, h, c, 4);

      if (buffer != null) {
        this.width = w[0];
        this.height = h[0];
        this.channels = ImageChannels.instance(c[0]);
        this.imageData = buffer;
      } else { // if error occurs
        throw LeguiExceptionTemplate.FAILED_TO_LOAD_IMAGE.create(STBImage.stbi_failure_reason());
      }
    } catch (IOException e) {
      throw LeguiExceptionTemplate.FAILED_TO_LOAD_IMAGE.create(e, e.getMessage());
    }
  }
/**
   * Should be used to load image data from source.
   */
Should be used to load image data from source.
Should be used to load image data from source .
@Override
  public void load() {
    try {
      ByteBuffer byteBuffer = IOUtil.resourceToByteBuffer(getPath());
      int[] w = {0};
      int[] h = {0};
      int[] c = {0};
      ByteBuffer buffer = STBImage.stbi_load_from_memory(byteBuffer, w, h, c, 4);
      if (buffer != null) {
        this.width = w[0];
        this.height = h[0];
        this.channels = ImageChannels.instance(c[0]);
        this.imageData = buffer;
      } else { 
        throw LeguiExceptionTemplate.FAILED_TO_LOAD_IMAGE.create(STBImage.stbi_failure_reason());
      }
    } catch (IOException e) {
      throw LeguiExceptionTemplate.FAILED_TO_LOAD_IMAGE.create(e, e.getMessage());
    }
  }
@ Override public void load ( ) { try { ByteBuffer byteBuffer = IOUtil . resourceToByteBuffer ( getPath ( ) ) ; int [ ] w = { 0 } ; int [ ] h = { 0 } ; int [ ] c = { 0 } ; ByteBuffer buffer = STBImage . stbi_load_from_memory ( byteBuffer , w , h , c , 4 ) ; if ( buffer != null ) { this . width = w [ 0 ] ; this . height = h [ 0 ] ; this . channels = ImageChannels . instance ( c [ 0 ] ) ; this . imageData = buffer ; } else { throw LeguiExceptionTemplate . FAILED_TO_LOAD_IMAGE . create ( STBImage . stbi_failure_reason ( ) ) ; } } catch ( IOException e ) { throw LeguiExceptionTemplate . FAILED_TO_LOAD_IMAGE . create ( e , e . getMessage ( ) ) ; } }
Should be used to load image data from source.
Should be used to load image data from source .
// if error occurs