| 523 | } |
| 524 | |
| 525 | Math::Size Image::GetSize(const String& name) |
| 526 | { |
| 527 | if (!name.EndsWith(U".png", String::Case::Insensitive)) |
| 528 | { |
| 529 | EXIT("unsupported format: %s\n", name.C_Str()); |
| 530 | } |
| 531 | |
| 532 | File f; |
| 533 | if (!f.Open(name, File::Mode::Read)) |
| 534 | { |
| 535 | EXIT("Can't open file %s\n", name.C_Str()); |
| 536 | } |
| 537 | |
| 538 | Math::Size s(0, 0); |
| 539 | uint32_t header = 0; |
| 540 | |
| 541 | f.Seek(12); |
| 542 | f.Read(&header, 4); |
| 543 | |
| 544 | if (header != 0x52444849) |
| 545 | { |
| 546 | EXIT("wrong png file: %s\n", name.C_Str()); |
| 547 | } |
| 548 | |
| 549 | f.ReadR(&s.width, 4); |
| 550 | f.ReadR(&s.height, 4); |
| 551 | |
| 552 | f.Close(); |
| 553 | |
| 554 | return s; |
| 555 | } |
| 556 | |
| 557 | } // namespace Kyty::Libs::Graphics |
| 558 |
no test coverage detected