diff options
author | 2017-09-02 22:45:56 +0200 | |
---|---|---|
committer | 2017-09-02 22:46:14 +0200 | |
commit | 23d9d212503e2ba29ac69c1871234e5f71f19a59 (patch) | |
tree | 1c55734aaf368b1545a8360738b33dac64b2cc3e /src/lib/util/png.cpp | |
parent | f67038d5ad2a76038f4b204c2e869feb10d1df16 (diff) |
png: make verify_header public (nw)
Diffstat (limited to 'src/lib/util/png.cpp')
-rw-r--r-- | src/lib/util/png.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp index 54f943e3955..a62d08c8161 100644 --- a/src/lib/util/png.cpp +++ b/src/lib/util/png.cpp @@ -413,21 +413,6 @@ private: return ((samples[pnginfo.color_type] * pnginfo.bit_depth) + 7) >> 3; } - static png_error verify_header(util::core_file &fp) - { - uint8_t signature[8]; - - /* read 8 bytes */ - if (fp.read(signature, 8) != 8) - return PNGERR_FILE_TRUNCATED; - - /* return an error if we don't match */ - if (memcmp(signature, PNG_Signature, 8) != 0) - return PNGERR_BAD_SIGNATURE; - - return PNGERR_NONE; - } - static png_error read_chunk(util::core_file &fp, std::unique_ptr<std::uint8_t []> &data, std::uint32_t &type, std::uint32_t &length) { std::uint8_t tempbuff[4]; @@ -705,6 +690,21 @@ public: return PNGERR_NONE; } + png_error verify_header(util::core_file &fp) + { + uint8_t signature[8]; + + /* read 8 bytes */ + if (fp.read(signature, 8) != 8) + return PNGERR_FILE_TRUNCATED; + + /* return an error if we don't match */ + if (memcmp(signature, PNG_Signature, 8) != 0) + return PNGERR_BAD_SIGNATURE; + + return PNGERR_NONE; + } + png_error read_file(util::core_file &fp) { // initialize the data structures @@ -756,6 +756,17 @@ constexpr unsigned png_private::ADAM7_Y_OFFS[7]; /*------------------------------------------------- + verify_header - verify PNG file header from a + core stream +-------------------------------------------------*/ + +png_error png_info::verify_header(util::core_file &fp) +{ + return png_private(*this).verify_header(fp); +} + + +/*------------------------------------------------- read_file - read a PNG from a core stream -------------------------------------------------*/ |