Delphi / Object Pascal · Exception
What does EInvalidGraphic Exception mean in Delphi / Object Pascal?
Raised when code tries to load a file into a TPicture, TBitmap, or other graphic object that isn't a recognized format for that class, has an unrecognized file extension, doesn't match the format requested from the clipboard, or sets a bitmap's PixelFormat to an unsupported value.
Raised when code tries to load a file into a TPicture, TBitmap, or other graphic object that isn't a recognized format for that class, has an unrecognized file extension, doesn't match the format requested from the clipboard, or sets a bitmap's PixelFormat to an unsupported value.
Validate the file extension/signature against the formats the target graphic class actually supports before loading, register any needed format handler unit (PNG/JPEG) in the uses clause so TPicture recognizes it, and catch this exception around user-supplied image loads instead of letting it reach a generic crash dialog.