summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2017-09-02 22:45:56 +0200
committer hap <happppp@users.noreply.github.com>2017-09-02 22:46:14 +0200
commit23d9d212503e2ba29ac69c1871234e5f71f19a59 (patch)
tree1c55734aaf368b1545a8360738b33dac64b2cc3e
parentf67038d5ad2a76038f4b204c2e869feb10d1df16 (diff)
png: make verify_header public (nw)
-rw-r--r--src/lib/util/png.cpp41
-rw-r--r--src/lib/util/png.h1
2 files changed, 27 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
-------------------------------------------------*/
diff --git a/src/lib/util/png.h b/src/lib/util/png.h
index d4805876215..3925f6e4032 100644
--- a/src/lib/util/png.h
+++ b/src/lib/util/png.h
@@ -57,6 +57,7 @@ public:
~png_info() { free_data(); }
+ png_error verify_header(util::core_file &fp);
png_error read_file(util::core_file &fp);
png_error copy_to_bitmap(bitmap_argb32 &bitmap, bool &hasalpha);
png_error expand_buffer_8bit();