| 405 | // ── PAA/PAC Image ────────────────────────────────────────────────────────── |
| 406 | |
| 407 | PF_API PF_HANDLE pf_image_load(const char* path) { |
| 408 | ClearError(); |
| 409 | if (!path) { SetError("null path"); return nullptr; } |
| 410 | try { |
| 411 | Poseidon::PAAInfo info; |
| 412 | if (!Poseidon::ReadPAAInfo(path, info)) { |
| 413 | SetError("Not a PAA/PAC file"); |
| 414 | return nullptr; |
| 415 | } |
| 416 | auto decoded = Poseidon::DecodePAAFile(path); |
| 417 | if (!decoded.valid()) { |
| 418 | SetError("Failed to decode image"); |
| 419 | return nullptr; |
| 420 | } |
| 421 | auto* wrapper = new PFImage(); |
| 422 | wrapper->image = std::move(decoded); |
| 423 | wrapper->formatName = info.formatName ? info.formatName : "unknown"; |
| 424 | return wrapper; |
| 425 | } catch (const std::exception& e) { |
| 426 | SetError(e.what()); |
| 427 | return nullptr; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | PF_API void pf_image_free(PF_HANDLE img) { |
| 432 | delete static_cast<PFImage*>(img); |
no test coverage detected