Yalantis/uCrop · error · CImgArgumentException

CImgDisplay::display(): Empty specified image.

Error message

CImgDisplay::display(): Empty specified image.

What it means

Thrown by CImgDisplay::display() when it is asked to render an image into the display window, but the passed CImg instance is empty (null data / zero size, i.e. CImg's operator bool is false). This is a guard against a default-constructed or failed-load image being pushed to the screen; populate the image (load or assign) before calling display().

Solutions

  1. Load or construct the image (e.g. with CImg::load or assign) and verify it is non-empty via is_empty() before calling display()
  2. Check the return value of the loading step that produced the image; a failed load often yields an empty image
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at ucrop/src/main/jni/CImg.h:10853 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/86ea79cdc094cef7. Report an issue: GitHub.

Appendix: source

Thrown at ucrop/src/main/jni/CImg.h:10853

      if (!std::strcmp(_title,tmp)) { delete[] tmp; return *this; }
      delete[] _title;
      const unsigned int s = (unsigned int)std::strlen(tmp) + 1;
      _title = new char[s];
      std::memcpy(_title,tmp,s*sizeof(char));

      cimg::X11_attr &X11_attr = cimg::X11_attr::ref();
      Display *const dpy = X11_attr.display;
      X11_attr.lock();
      XStoreName(dpy,_window,tmp);
      X11_attr.unlock();
      delete[] tmp;
      return *this;
    }

    template<typename T>
    CImgDisplay& display(const CImg<T>& img) {
      if (!img)
        throw CImgArgumentException(_cimgdisplay_instance
                                    "display(): Empty specified image.",
                                    cimgdisplay_instance);
      if (is_empty()) return assign(img);
      return render(img).paint(false);
    }

    CImgDisplay& paint(const bool wait_expose=true) {
      if (is_empty()) return *this;
      cimg::X11_attr &X11_attr = cimg::X11_attr::ref();
      X11_attr.lock();
      _paint(wait_expose);
      X11_attr.unlock();
      return *this;
    }

    template<typename T>
    CImgDisplay& render(const CImg<T>& img, const bool flag8=false) {
      if (!img)

View on GitHub (pinned to f788b534b4)