[master] Imported from libpng-1.6.36.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 9fc9021..f1724c0 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,48 +1,77 @@
-Libpng 1.6.35 - July 15, 2018
+libpng 1.6.36 - December 1, 2018
+================================
 
 This is a public release of libpng, intended for use in production code.
 
-Files available for download:
+
+Files available for download
+----------------------------
 
 Source files with LF line endings (for Unix/Linux):
 
-   libpng-1.6.35.tar.xz (LZMA-compressed, recommended)
-   libpng-1.6.35.tar.gz
+ * libpng-1.6.36.tar.xz (LZMA-compressed, recommended)
+ * libpng-1.6.36.tar.gz
 
 Source files with CRLF line endings (for Windows):
 
-   lp1635.7z  (LZMA-compressed, recommended)
-   lp1635.zip
+ * lp1636.7z (LZMA-compressed, recommended)
+ * lp1636.zip
 
 Other information:
 
-   libpng-1.6.35-README.txt
-   libpng-1.6.35-LICENSE.txt
+ * README.md
+ * LICENSE.md
+ * AUTHORS.md
+ * TRADEMARK.md
 
-Changes since the last public release (1.6.34):
 
-  Restored 21 of the contrib/pngsuite/i*.png, which do not cause test
-    failures. Placed the remainder in contrib/pngsuite/interlaced/i*.png.
-  Added calls to png_set_*() transforms commonly used by browsers to
-    the fuzzer.
-  Removed some unnecessary brackets in pngrtran.c
-  Fixed miscellaneous typos (Patch by github user "luzpaz").
-  Change "ASM C" to "C ASM" in CMakeLists.txt
-  Fixed incorrect handling of bKGD chunk in sub-8-bit files (Cosmin)
-  Added hardware optimization directories to zip and 7z distributions.
-  Fixed incorrect bitmask for options.
-  Fixed many spelling typos.
-  Make png_get_iCCP consistent with man page (allow compression-type argument
-    to be NULL, bug report by Lenard Szolnoki).
-  Replaced the remaining uses of png_size_t with size_t (Cosmin)
-  Fixed the calculation of row_factor in png_check_chunk_length
-    (reported by Thuan Pham in SourceForge issue #278)
-  Added missing parentheses to a macro definition
-    (suggested by "irwir" in GitHub issue #216)
+IMPORTANT licensing update: libpng license v2
+---------------------------------------------
 
-Send comments/corrections/commendations to png-mng-implement at lists.sf.net
-(subscription required; visit
+The new libpng license comprises the terms and conditions from the zlib
+license, and the disclaimer from the Boost license.
+
+The legacy libpng license, used until libpng-1.6.35, is appended to the
+new license, following the precedent established in the Python Software
+Foundation License version 2.
+
+From now on, the list of contributing authors shall be maintained in a
+separate AUTHORS file.  The lists of previous contributing authors,
+mentioned in the legacy libpng license and considered to be an integral
+part of that license, are kept intact, with no further updates.
+
+
+Changes since the previous public release (version 1.6.35)
+----------------------------------------------------------
+
+ * Optimized png_do_expand_palette for ARM processors.
+   Improved performance by around 10-22% on a recent ARM Chromebook.
+   (Contributed by Richard Townsend, ARM Holdings)
+ * Fixed manipulation of machine-specific optimization options.
+   (Contributed by Vicki Pfau)
+ * Used memcpy instead of manual pointer arithmetic on Intel SSE2.
+   (Contributed by Samuel Williams)
+ * Fixed build errors with MSVC on ARM64.
+   (Contributed by Zhijie Liang)
+ * Fixed detection of libm in CMakeLists.
+   (Contributed by Cameron Cawley)
+ * Fixed incorrect creation of pkg-config file in CMakeLists.
+   (Contributed by Kyle Bentley)
+ * Fixed the CMake build on Windows MSYS by avoiding symlinks.
+ * Fixed a build warning on OpenBSD.
+   (Contributed by Theo Buehler)
+ * Fixed various typos in comments.
+   (Contributed by "luz.paz")
+ * Raised the minimum required CMake version from 3.0.2 to 3.1.
+ * Removed yet more of the vestigial support for pre-ANSI C compilers.
+ * Removed ancient makefiles for ancient systems that have been broken
+   across all previous libpng-1.6.x versions.
+ * Removed the Y2K compliance statement and the export control
+   information.
+ * Applied various code style and documentation fixes.
+
+
+Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
+Subscription is required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe).
-
-Glenn R-P
+to subscribe.
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..79a3d10
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,45 @@
+PNG REFERENCE LIBRARY AUTHORS
+=============================
+
+This is the list of PNG Reference Library ("libpng") Contributing
+Authors, for copyright and licensing purposes.
+
+ * Andreas Dilger
+ * Cosmin Truta
+ * Dave Martindale
+ * Eric S. Raymond
+ * Gilles Vollant
+ * Glenn Randers-Pehrson
+ * Greg Roelofs
+ * Guy Eric Schalnat
+ * James Yu
+ * John Bowler
+ * Kevin Bracey
+ * Magnus Holmgren
+ * Mandar Sahastrabuddhe
+ * Mans Rullgard
+ * Matt Sarett
+ * Mike Klein
+ * Paul Schmidt
+ * Sam Bushell
+ * Samuel Williams
+ * Simon-Pierre Cadieux
+ * Tim Wegner
+ * Tom Lane
+ * Tom Tanner
+ * Vadim Barkov
+ * Willem van Schaik
+ * Zhijie Liang
+ * Arm Holdings
+   - Richard Townsend
+ * Google Inc.
+   - Matt Sarett
+   - Mike Klein
+
+The build projects, the build scripts, the test scripts, and other
+files in the "projects", "scripts" and "tests" directories, have other
+copyright owners, but are released under the libpng license.
+
+Some files in the "contrib" directory, and some tools-generated files
+that are distributed with libpng, have other copyright owners, and are
+released under other open source licenses.
diff --git a/CHANGES b/CHANGES
index 0ed6a11..bdd4480 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6063,9 +6063,34 @@
   Added missing parentheses to a macro definition
     (suggested by "irwir" in GitHub issue #216)
 
+Version 1.6.36 [December 1, 2018]
+  Optimized png_do_expand_palette for ARM processors.
+  Improved performance by around 10-22% on a recent ARM Chromebook.
+  (Contributed by Richard Townsend, ARM Holdings)
+  Fixed manipulation of machine-specific optimization options.
+  (Contributed by Vicki Pfau)
+  Used memcpy instead of manual pointer arithmetic on Intel SSE2.
+  (Contributed by Samuel Williams)
+  Fixed build errors with MSVC on ARM64.
+  (Contributed by Zhijie Liang)
+  Fixed detection of libm in CMakeLists.
+  (Contributed by Cameron Cawley)
+  Fixed incorrect creation of pkg-config file in CMakeLists.
+  (Contributed by Kyle Bentley)
+  Fixed the CMake build on Windows MSYS by avoiding symlinks.
+  Fixed a build warning on OpenBSD.
+  (Contributed by Theo Buehler)
+  Fixed various typos in comments.
+  (Contributed by "luz.paz")
+  Raised the minimum required CMake version from 3.0.2 to 3.1.
+  Removed yet more of the vestigial support for pre-ANSI C compilers.
+  Removed ancient makefiles for ancient systems that have been broken
+  across all previous libpng-1.6.x versions.
+  Removed the Y2K compliance statement and the export control
+  information.
+  Applied various code style and documentation fixes.
+
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
 to subscribe).
-
-Glenn R-P
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4db9bb8..73044c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,42 +1,32 @@
 # CMakeLists.txt
 
+# Copyright (C) 2018 Cosmin Truta
 # Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson
 # Written by Christian Ehrlicher, 2007
 # Revised by Roger Lowman, 2009-2010
-# Revised by Clifford Yapp, 2011-2012
+# Revised by Clifford Yapp, 2011-2012,2017
 # Revised by Roger Leigh, 2016
 # Revised by Andreas Franek, 2016
+# Revised by Sam Serrels, 2017
+# Revised by Vadim Barkov, 2017
+# Revised by Vicky Pfau, 2018
+# Revised by Cameron Cawley, 2018
+# Revised by Cosmin Truta, 2018
+# Revised by Kyle Bentley, 2018
 
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
 # and license in png.h
 
-cmake_minimum_required(VERSION 3.0.2)
-cmake_policy(VERSION 3.0.2)
-
-# Set MacOSX @rpath usage globally.
-if (POLICY CMP0020)
-  cmake_policy(SET CMP0020 NEW)
-endif(POLICY CMP0020)
-if (POLICY CMP0042)
-  cmake_policy(SET CMP0042 NEW)
-endif(POLICY CMP0042)
-# Use new variable expansion policy.
-if (POLICY CMP0053)
-  cmake_policy(SET CMP0053 NEW)
-endif(POLICY CMP0053)
-if (POLICY CMP0054)
-  cmake_policy(SET CMP0054 NEW)
-endif(POLICY CMP0054)
-
-set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
+cmake_minimum_required(VERSION 3.1)
+cmake_policy(VERSION 3.1)
 
 project(libpng C ASM)
 enable_testing()
 
 set(PNGLIB_MAJOR 1)
 set(PNGLIB_MINOR 6)
-set(PNGLIB_RELEASE 35)
+set(PNGLIB_RELEASE 36)
 set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
 set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
 
@@ -44,25 +34,19 @@
 
 # needed packages
 
-#Allow users to specify location of Zlib,
-# Useful if zlib is being built alongside this as a sub-project
+# Allow users to specify location of Zlib.
+# Useful if zlib is being built alongside this as a sub-project.
 option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
 
-IF(NOT PNG_BUILD_ZLIB)
+if(NOT PNG_BUILD_ZLIB)
   find_package(ZLIB REQUIRED)
   include_directories(${ZLIB_INCLUDE_DIR})
-ENDIF(NOT PNG_BUILD_ZLIB)
+endif()
 
-if(NOT WIN32)
-  find_library(M_LIBRARY
-    NAMES m
-    PATHS /usr/lib /usr/local/lib
-  )
-  if(NOT M_LIBRARY)
-    message(STATUS "math lib 'libm' not found; floating point support disabled")
-  endif()
+if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
+  find_library(M_LIBRARY m)
 else()
-  # not needed on windows
+  # libm is not needed and/or not available
   set(M_LIBRARY "")
 endif()
 
@@ -73,16 +57,14 @@
 
 # Many more configuration options could be added here
 option(PNG_FRAMEWORK "Build OS X framework" OFF)
-option(PNG_DEBUG     "Build with debug output" OFF)
-option(PNGARG        "Disable ANSI-C prototypes" OFF)
-
-option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
-
+option(PNG_DEBUG "Build with debug output" OFF)
+option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
 
 set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
 set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
 
 if(PNG_HARDWARE_OPTIMIZATIONS)
+
 # set definitions and sources for arm
 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
   CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
@@ -96,12 +78,13 @@
   list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
   if(index EQUAL -1)
     message(FATAL_ERROR
-      " PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
-  elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
+            "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
+  elseif(NOT ${PNG_ARM_NEON} STREQUAL "off")
     set(libpng_arm_sources
       arm/arm_init.c
       arm/filter_neon.S
-      arm/filter_neon_intrinsics.c)
+      arm/filter_neon_intrinsics.c
+      arm/palette_neon_intrinsics.c)
 
     if(${PNG_ARM_NEON} STREQUAL "on")
       add_definitions(-DPNG_ARM_NEON_OPT=2)
@@ -115,7 +98,7 @@
 
 # set definitions and sources for powerpc
 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
-	CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
+   CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
   set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
   set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
      off: disable the optimizations.")
@@ -124,8 +107,8 @@
   list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
   if(index EQUAL -1)
     message(FATAL_ERROR
-      " PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
-  elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "no")
+            "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
+  elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off")
     set(libpng_powerpc_sources
       powerpc/powerpc_init.c
       powerpc/filter_vsx_intrinsics.c)
@@ -139,7 +122,7 @@
 
 # set definitions and sources for intel
 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
-	CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
+   CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
   set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
   set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
      off: disable the optimizations")
@@ -148,8 +131,8 @@
   list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
   if(index EQUAL -1)
     message(FATAL_ERROR
-      " PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
-  elseif(NOT ${PNG_INTEL_SSE} STREQUAL "no")
+            "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
+  elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off")
     set(libpng_intel_sources
       intel/intel_init.c
       intel/filter_sse2_intrinsics.c)
@@ -163,7 +146,7 @@
 
 # set definitions and sources for MIPS
 if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
-	CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
+   CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
   set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
   set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
      off: disable the optimizations")
@@ -172,8 +155,8 @@
   list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
   if(index EQUAL -1)
     message(FATAL_ERROR
-      " PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
-  elseif(NOT ${PNG_MIPS_MSA} STREQUAL "no")
+            "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
+  elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off")
     set(libpng_mips_sources
       mips/mips_init.c
       mips/filter_msa_intrinsics.c)
@@ -184,6 +167,33 @@
     add_definitions(-DPNG_MIPS_MSA_OPT=0)
   endif()
 endif()
+
+else(PNG_HARDWARE_OPTIMIZATIONS)
+
+# set definitions and sources for arm
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
+   CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
+  add_definitions(-DPNG_ARM_NEON_OPT=0)
+endif()
+
+# set definitions and sources for powerpc
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
+   CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
+  add_definitions(-DPNG_POWERPC_VSX_OPT=0)
+endif()
+
+# set definitions and sources for intel
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
+   CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
+  add_definitions(-DPNG_INTEL_SSE_OPT=0)
+endif()
+
+# set definitions and sources for MIPS
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
+   CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
+  add_definitions(-DPNG_MIPS_MSA_OPT=0)
+endif()
+
 endif(PNG_HARDWARE_OPTIMIZATIONS)
 
 # SET LIBNAME
@@ -241,17 +251,17 @@
   foreach(line ${OUT})
     string(REGEX MATCH "^PREFIX=" found_match "${line}")
     if(found_match)
-      STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
+      string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
       string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
       if(found_match)
-        STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
+        string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
       endif()
       set(SYMBOL_PREFIX "${prefix}")
     endif()
   endforeach()
 
-    message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
-    set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
+  message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
+  set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
 endfunction()
 
 if(UNIX)
@@ -276,11 +286,11 @@
     set(oneValueArgs INPUT OUTPUT)
     set(multiValueArgs DEPENDS)
     cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    if (NOT _GC_INPUT)
-      message(FATAL_ERROR "Invalid arguments.  generate_out requires input.")
+    if(NOT _GC_INPUT)
+      message(FATAL_ERROR "generate_chk: Missing INPUT argument")
     endif()
-    if (NOT _GC_OUTPUT)
-      message(FATAL_ERROR "Invalid arguments.  generate_out requires output.")
+    if(NOT _GC_OUTPUT)
+      message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
     endif()
 
     add_custom_command(OUTPUT "${_GC_OUTPUT}"
@@ -299,11 +309,11 @@
     set(oneValueArgs INPUT OUTPUT)
     set(multiValueArgs DEPENDS)
     cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    if (NOT _GO_INPUT)
-      message(FATAL_ERROR "Invalid arguments.  generate_out requires input.")
+    if(NOT _GO_INPUT)
+      message(FATAL_ERROR "generate_out: Missing INPUT argument")
     endif()
-    if (NOT _GO_OUTPUT)
-      message(FATAL_ERROR "Invalid arguments.  generate_out requires output.")
+    if(NOT _GO_OUTPUT)
+      message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
     endif()
 
     add_custom_command(OUTPUT "${_GO_OUTPUT}"
@@ -322,8 +332,8 @@
     set(oneValueArgs OUTPUT)
     set(multiValueArgs DEPENDS)
     cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    if (NOT _GSO_OUTPUT)
-      message(FATAL_ERROR "Invalid arguments.  generate_source requires output.")
+    if(NOT _GSO_OUTPUT)
+      message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
     endif()
 
     add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
@@ -505,7 +515,7 @@
 
 if(MSVC)
   add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
-endif(MSVC)
+endif()
 
 if(PNG_DEBUG)
   add_definitions(-DPNG_DEBUG)
@@ -585,7 +595,7 @@
   message(SEND_ERROR
     "No library variant selected to build. "
     "Please enable at least one of the following options: "
-    " PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
+    "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
 endif()
 
 if(PNG_SHARED AND WIN32)
@@ -598,11 +608,11 @@
   set(multiValueArgs OPTIONS FILES)
   cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
-  if (NOT _PAT_NAME)
-    message(FATAL_ERROR "Invalid arguments.  png_add_test requires name.")
+  if(NOT _PAT_NAME)
+    message(FATAL_ERROR "png_add_test: Missing NAME argument")
   endif()
-  if (NOT _PAT_COMMAND)
-    message(FATAL_ERROR "Invalid arguments.  png_add_test requires command.")
+  if(NOT _PAT_COMMAND)
+    message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
   endif()
 
   set(TEST_OPTIONS "${_PAT_OPTIONS}")
@@ -610,19 +620,11 @@
 
   configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
                  "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
-  if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
-    add_test(NAME "${_PAT_NAME}"
-             COMMAND "${CMAKE_COMMAND}"
-             "-DLIBPNG=$<TARGET_FILE:png>"
-             "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
-             -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
-  else() # old 2.x add_test; limited and won't work well on Windows
-    # Note LIBPNG is a dummy value as there are no generator expressions
-    add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
-             "-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
-             "-DTEST_COMMAND=./${_PAT_COMMAND}"
-             -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
-  endif()
+  add_test(NAME "${_PAT_NAME}"
+           COMMAND "${CMAKE_COMMAND}"
+           "-DLIBPNG=$<TARGET_FILE:png>"
+           "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
+           -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
 endfunction()
 
 if(PNG_TESTS AND PNG_SHARED)
@@ -687,11 +689,11 @@
         set(TEST_PNG_VALID TRUE)
 
         if(TEST_PNG_ALPHA)
-          if (NOT "${alpha_type}" STREQUAL "alpha")
+          if(NOT "${alpha_type}" STREQUAL "alpha")
             set(TEST_PNG_VALID FALSE)
           endif()
         else()
-          if ("${alpha_type}" STREQUAL "alpha")
+          if("${alpha_type}" STREQUAL "alpha")
             set(TEST_PNG_VALID FALSE)
           endif()
         endif()
@@ -760,51 +762,44 @@
 # copies if different.
 include(CMakeParseArguments)
 
-function(CREATE_SYMLINK DEST_FILE)
+function(create_symlink DEST_FILE)
 
   cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
 
   if(NOT S_TARGET AND NOT S_FILE)
-    message(FATAL_ERROR "Specify either a TARGET or a FILE for CREATE_SYMLINK to link to.")
-  endif(NOT S_TARGET AND NOT S_FILE)
+    message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument")
+  endif()
 
   if(S_TARGET AND S_FILE)
-    message(FATAL_ERROR "CREATE_SYMLINK called with both source file ${S_FILE} and build target ${S_TARGET} arguments - can only handle 1 type per call.")
-  endif(S_TARGET AND S_FILE)
+    message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.")
+  endif()
 
   if(S_FILE)
     # If we don't need to symlink something that's coming from a build target,
     # we can go ahead and symlink/copy at configure time.
-
-    if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+    if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
       execute_process(
-	COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
-	WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
-	)
-    else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+        COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
+        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+    else()
       execute_process(
-	COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
-	WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
-	)
-    endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
-  endif(S_FILE)
+        COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
+        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+    endif()
+  endif()
 
   if(S_TARGET)
     # We need to use generator expressions, which can be a bit tricky, so for
     # simplicity make the symlink a POST_BUILD step and use the TARGET
     # signature of add_custom_command.
-
-    if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+    if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
       add_custom_command(TARGET ${S_TARGET} POST_BUILD
-	COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
-	)
-    else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+        COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
+    else()
       add_custom_command(TARGET ${S_TARGET} POST_BUILD
-	COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
-	)
-    endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
-
-  endif(S_TARGET)
+        COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
+    endif()
+  endif()
 
 endfunction()
 
@@ -816,103 +811,95 @@
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
                ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
 
-
 # libpng is a library so default to 'lib'
 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
   set(CMAKE_INSTALL_LIBDIR lib)
-endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
+endif()
 
 # CREATE PKGCONFIG FILES
-# we use the same files like ./configure, so we have to set its vars
+# We use the same files like ./configure, so we have to set its vars.
 # Only do this on Windows for Cygwin - the files don't make much sense outside
-# a UNIX look alike
+# of a UNIX look-alike.
 if(NOT WIN32 OR CYGWIN OR MINGW)
   set(prefix      ${CMAKE_INSTALL_PREFIX})
   set(exec_prefix ${CMAKE_INSTALL_PREFIX})
-  set(libdir      ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
-  set(includedir  ${CMAKE_INSTALL_PREFIX}/include)
+  set(libdir      ${CMAKE_INSTALL_FULL_LIBDIR})
+  set(includedir  ${CMAKE_INSTALL_FULL_INCLUDEDIR})
   set(LIBS        "-lz -lm")
   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
     ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
-  CREATE_SYMLINK(libpng.pc FILE ${PNGLIB_NAME}.pc)
+  create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc)
 
   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
     ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
-  CREATE_SYMLINK(libpng-config FILE ${PNGLIB_NAME}-config)
-endif(NOT WIN32 OR CYGWIN OR MINGW)
+  create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
+endif()
 
 # SET UP LINKS
 if(PNG_SHARED)
   set_target_properties(png PROPERTIES
-#   VERSION 16.${PNGLIB_RELEASE}.1.6.35
+#   VERSION 16.${PNGLIB_RELEASE}.1.6.36
     VERSION 16.${PNGLIB_RELEASE}.0
     SOVERSION 16
     CLEAN_DIRECT_OUTPUT 1)
 endif()
 
-# If CMake > 2.4.x, we set a variable used below to export
-# targets to an export file.
-# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
-if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
-  set(PNG_EXPORT_RULE EXPORT libpng)
-elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
-  set(PNG_EXPORT_RULE EXPORT libpng)
-endif()
-
 # INSTALL
-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
+if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
   install(TARGETS ${PNG_LIB_TARGETS}
-      ${PNG_EXPORT_RULE}
-      RUNTIME DESTINATION bin
-      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-      FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
+          EXPORT libpng
+          RUNTIME DESTINATION bin
+          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+          FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
   if(PNG_SHARED)
     # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
     if(CYGWIN OR MINGW)
-      CREATE_SYMLINK(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
-      install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
-    endif(CYGWIN OR MINGW)
+      create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
+      install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
+              DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    endif()
 
     if(NOT WIN32)
-      CREATE_SYMLINK(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
-      install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
-    endif(NOT WIN32)
-  endif(PNG_SHARED)
+      create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
+      install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
+              DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    endif()
+  endif()
 
   if(PNG_STATIC)
     if(NOT WIN32 OR CYGWIN OR MINGW)
-      CREATE_SYMLINK( libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
-      install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
-    endif(NOT WIN32 OR CYGWIN OR MINGW)
- endif()
+      create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
+      install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
+              DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    endif()
+  endif()
 endif()
 
-if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
-  install(FILES ${libpng_public_hdrs}   DESTINATION include)
-  install(FILES ${libpng_public_hdrs}   DESTINATION include/${PNGLIB_NAME})
+if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
+  install(FILES ${libpng_public_hdrs} DESTINATION include)
+  install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
 endif()
-if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
+if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL)
   if(NOT WIN32 OR CYGWIN OR MINGW)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
-    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
-            DESTINATION bin)
-  endif(NOT WIN32 OR CYGWIN OR MINGW)
+    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
+  endif()
 endif()
 
-if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
+if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
   install(TARGETS ${PNG_BIN_TARGETS}
-      RUNTIME DESTINATION bin)
+          RUNTIME DESTINATION bin)
 endif()
 
-if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
+if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
   # Install man pages
   if(NOT PNG_MAN_DIR)
     set(PNG_MAN_DIR "share/man")
   endif()
-  install(FILES libpng.3 libpngpf.3      DESTINATION ${PNG_MAN_DIR}/man3)
-  install(FILES png.5                    DESTINATION ${PNG_MAN_DIR}/man5)
+  install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
+  install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
   # Install pkg-config files
   if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
@@ -923,12 +910,11 @@
             DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
             DESTINATION bin)
-  endif(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
+  endif()
 endif()
 
-# On versions of CMake that support it, create an export file CMake
-# users can include() to import our targets
-if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
+# Create an export file that CMake users can include() to import our targets.
+if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
   install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
 endif()
 
diff --git a/LICENSE b/LICENSE
index 6ee9c8f..62ab8e4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,14 +1,43 @@
+COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
+=========================================
 
-This copy of the libpng notices is provided for your convenience.  In case of
-any discrepancy between this copy and the notices in the file png.h that is
-included in the libpng distribution, the latter shall prevail.
+PNG Reference Library License version 2
+---------------------------------------
 
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+ * Copyright (c) 1995-2018 The PNG Reference Library Authors.
+ * Copyright (c) 2018 Cosmin Truta.
+ * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
+ * Copyright (c) 1996-1997 Andreas Dilger.
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
 
-If you modify libpng you may insert additional notices immediately following
-this sentence.
+The software is supplied "as is", without warranty of any kind,
+express or implied, including, without limitation, the warranties
+of merchantability, fitness for a particular purpose, title, and
+non-infringement.  In no even shall the Copyright owners, or
+anyone distributing the software, be liable for any damages or
+other liability, whether in contract, tort or otherwise, arising
+from, out of, or in connection with the software, or the use or
+other dealings in the software, even if advised of the possibility
+of such damage.
 
-This code is released under the libpng license.
+Permission is hereby granted to use, copy, modify, and distribute
+this software, or portions hereof, for any purpose, without fee,
+subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you
+    must not claim that you wrote the original software.  If you
+    use this software in a product, an acknowledgment in the product
+    documentation would be appreciated, but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must
+    not be misrepresented as being the original software.
+
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
+
+
+PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
+-----------------------------------------------------------------------
 
 libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
 Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
@@ -16,38 +45,38 @@
 disclaimer and license as libpng-1.0.6 with the following individuals
 added to the list of Contributing Authors:
 
-   Simon-Pierre Cadieux
-   Eric S. Raymond
-   Mans Rullgard
-   Cosmin Truta
-   Gilles Vollant
-   James Yu
-   Mandar Sahastrabuddhe
-   Google Inc.
-   Vadim Barkov
+    Simon-Pierre Cadieux
+    Eric S. Raymond
+    Mans Rullgard
+    Cosmin Truta
+    Gilles Vollant
+    James Yu
+    Mandar Sahastrabuddhe
+    Google Inc.
+    Vadim Barkov
 
 and with the following additions to the disclaimer:
 
-   There is no warranty against interference with your enjoyment of the
-   library or against infringement.  There is no warranty that our
-   efforts or the library will fulfill any of your particular purposes
-   or needs.  This library is provided with all faults, and the entire
-   risk of satisfactory quality, performance, accuracy, and effort is with
-   the user.
+    There is no warranty against interference with your enjoyment of
+    the library or against infringement.  There is no warranty that our
+    efforts or the library will fulfill any of your particular purposes
+    or needs.  This library is provided with all faults, and the entire
+    risk of satisfactory quality, performance, accuracy, and effort is
+    with the user.
 
 Some files in the "contrib" directory and some configure-generated
-files that are distributed with libpng have other copyright owners and
+files that are distributed with libpng have other copyright owners, and
 are released under other open source licenses.
 
 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
 Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
 libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the list
-of Contributing Authors:
+license as libpng-0.96, with the following individuals added to the
+list of Contributing Authors:
 
-   Tom Lane
-   Glenn Randers-Pehrson
-   Willem van Schaik
+    Tom Lane
+    Glenn Randers-Pehrson
+    Willem van Schaik
 
 libpng versions 0.89, June 1996, through 0.96, May 1997, are
 Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
@@ -55,14 +84,14 @@
 libpng-0.88, with the following individuals added to the list of
 Contributing Authors:
 
-   John Bowler
-   Kevin Bracey
-   Sam Bushell
-   Magnus Holmgren
-   Greg Roelofs
-   Tom Tanner
+    John Bowler
+    Kevin Bracey
+    Sam Bushell
+    Magnus Holmgren
+    Greg Roelofs
+    Tom Tanner
 
-Some files in the "scripts" directory have other copyright owners
+Some files in the "scripts" directory have other copyright owners,
 but are released under this license.
 
 libpng versions 0.5, May 1995, through 0.88, January 1996, are
@@ -71,63 +100,35 @@
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
 
-   Andreas Dilger
-   Dave Martindale
-   Guy Eric Schalnat
-   Paul Schmidt
-   Tim Wegner
+    Andreas Dilger
+    Dave Martindale
+    Guy Eric Schalnat
+    Paul Schmidt
+    Tim Wegner
 
-The PNG Reference Library is supplied "AS IS".  The Contributing Authors
-and Group 42, Inc. disclaim all warranties, expressed or implied,
-including, without limitation, the warranties of merchantability and of
-fitness for any purpose.  The Contributing Authors and Group 42, Inc.
-assume no liability for direct, indirect, incidental, special, exemplary,
-or consequential damages, which may result from the use of the PNG
-Reference Library, even if advised of the possibility of such damage.
+The PNG Reference Library is supplied "AS IS".  The Contributing
+Authors and Group 42, Inc. disclaim all warranties, expressed or
+implied, including, without limitation, the warranties of
+merchantability and of fitness for any purpose.  The Contributing
+Authors and Group 42, Inc. assume no liability for direct, indirect,
+incidental, special, exemplary, or consequential damages, which may
+result from the use of the PNG Reference Library, even if advised of
+the possibility of such damage.
 
 Permission is hereby granted to use, copy, modify, and distribute this
 source code, or portions hereof, for any purpose, without fee, subject
 to the following restrictions:
 
-  1. The origin of this source code must not be misrepresented.
+ 1. The origin of this source code must not be misrepresented.
 
-  2. Altered versions must be plainly marked as such and must not
-     be misrepresented as being the original source.
+ 2. Altered versions must be plainly marked as such and must not
+    be misrepresented as being the original source.
 
-  3. This Copyright notice may not be removed or altered from any
-     source or altered source distribution.
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
 
-The Contributing Authors and Group 42, Inc. specifically permit, without
-fee, and encourage the use of this source code as a component to
-supporting the PNG file format in commercial products.  If you use this
-source code in a product, acknowledgment is not required but would be
-appreciated.
-
-END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
-
-TRADEMARK:
-
-The name "libpng" has not been registered by the Copyright owner
-as a trademark in any jurisdiction.  However, because libpng has
-been distributed and maintained world-wide, continually since 1995,
-the Copyright owner claims "common-law trademark protection" in any
-jurisdiction where common-law trademark is recognized.
-
-OSI CERTIFICATION:
-
-Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
-a certification mark of the Open Source Initiative. OSI has not addressed
-the additional disclaimers inserted at version 1.0.7.
-
-EXPORT CONTROL:
-
-The Copyright owner believes that the Export Control Classification
-Number (ECCN) for libpng is EAR99, which means not subject to export
-controls or International Traffic in Arms Regulations (ITAR) because
-it is open source, publicly available software, that does not contain
-any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
-734.7(b).
-
-Glenn Randers-Pehrson
-glennrp at users.sourceforge.net
-July 15, 2018
+The Contributing Authors and Group 42, Inc. specifically permit,
+without fee, and encourage the use of this source code as a component
+to supporting the PNG file format in commercial products.  If you use
+this source code in a product, acknowledgment is not required but would
+be appreciated.
diff --git a/Makefile.am b/Makefile.am
index 08db3e5..4f621aa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 # Makefile.am, the source file for Makefile.in (and hence Makefile), is
 #
+# Copyright (c) 2018 Cosmin Truta
 # Copyright (c) 2004-2016 Glenn Randers-Pehrson
-# Last changed in libpng 1.6.25 [September 1, 2016]
 #
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -95,7 +95,8 @@
 
 if PNG_ARM_NEON
 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
-	arm/filter_neon.S arm/filter_neon_intrinsics.c
+	arm/filter_neon.S arm/filter_neon_intrinsics.c \
+	arm/palette_neon_intrinsics.c
 endif
 
 if PNG_MIPS_MSA
@@ -147,7 +148,7 @@
 # from those directories being included.  This only works if the configure is
 # not done in the source directory!
 EXTRA_DIST= \
-	ANNOUNCE CHANGES INSTALL LICENSE README TODO \
+	ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
 	pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
 	${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
 	$(TESTS) $(XFAIL_TESTS) tests/pngstest \
diff --git a/Makefile.in b/Makefile.in
index 79d2b88..81ac1c8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16,8 +16,8 @@
 
 # Makefile.am, the source file for Makefile.in (and hence Makefile), is
 #
+# Copyright (c) 2018 Cosmin Truta
 # Copyright (c) 2004-2016 Glenn Randers-Pehrson
-# Last changed in libpng 1.6.25 [September 1, 2016]
 #
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -106,7 +106,8 @@
 @HAVE_CLOCK_GETTIME_TRUE@am__append_1 = timepng
 bin_PROGRAMS = pngfix$(EXEEXT) png-fix-itxt$(EXEEXT)
 @PNG_ARM_NEON_TRUE@am__append_2 = arm/arm_init.c\
-@PNG_ARM_NEON_TRUE@	arm/filter_neon.S arm/filter_neon_intrinsics.c
+@PNG_ARM_NEON_TRUE@	arm/filter_neon.S arm/filter_neon_intrinsics.c \
+@PNG_ARM_NEON_TRUE@	arm/palette_neon_intrinsics.c
 
 @PNG_MIPS_MSA_TRUE@am__append_3 = mips/mips_init.c\
 @PNG_MIPS_MSA_TRUE@	mips/filter_msa_intrinsics.c
@@ -183,12 +184,14 @@
 	pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \
 	pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \
 	arm/filter_neon.S arm/filter_neon_intrinsics.c \
-	mips/mips_init.c mips/filter_msa_intrinsics.c \
-	intel/intel_init.c intel/filter_sse2_intrinsics.c \
-	powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c
+	arm/palette_neon_intrinsics.c mips/mips_init.c \
+	mips/filter_msa_intrinsics.c intel/intel_init.c \
+	intel/filter_sse2_intrinsics.c powerpc/powerpc_init.c \
+	powerpc/filter_vsx_intrinsics.c
 am__dirstamp = $(am__leading_dot)dirstamp
 @PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \
-@PNG_ARM_NEON_TRUE@	arm/filter_neon_intrinsics.lo
+@PNG_ARM_NEON_TRUE@	arm/filter_neon_intrinsics.lo \
+@PNG_ARM_NEON_TRUE@	arm/palette_neon_intrinsics.lo
 @PNG_MIPS_MSA_TRUE@am__objects_2 = mips/mips_init.lo \
 @PNG_MIPS_MSA_TRUE@	mips/filter_msa_intrinsics.lo
 @PNG_INTEL_SSE_TRUE@am__objects_3 = intel/intel_init.lo \
@@ -266,6 +269,7 @@
 	./$(DEPDIR)/pngwtran.Plo ./$(DEPDIR)/pngwutil.Plo \
 	arm/$(DEPDIR)/arm_init.Plo arm/$(DEPDIR)/filter_neon.Plo \
 	arm/$(DEPDIR)/filter_neon_intrinsics.Plo \
+	arm/$(DEPDIR)/palette_neon_intrinsics.Plo \
 	contrib/libtests/$(DEPDIR)/pngimage.Po \
 	contrib/libtests/$(DEPDIR)/pngstest.Po \
 	contrib/libtests/$(DEPDIR)/pngunknown.Po \
@@ -530,7 +534,7 @@
 	$(TEST_LOG_FLAGS)
 am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \
 	$(srcdir)/config.h.in $(srcdir)/libpng-config.in \
-	$(srcdir)/libpng.pc.in INSTALL README TODO compile \
+	$(srcdir)/libpng.pc.in AUTHORS INSTALL README TODO compile \
 	config.guess config.sub depcomp install-sh ltmain.sh missing \
 	test-driver
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -780,7 +784,7 @@
 # from those directories being included.  This only works if the configure is
 # not done in the source directory!
 EXTRA_DIST = \
-	ANNOUNCE CHANGES INSTALL LICENSE README TODO \
+	ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
 	pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
 	${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
 	$(TESTS) $(XFAIL_TESTS) tests/pngstest \
@@ -972,6 +976,8 @@
 arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp)
 arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \
 	arm/$(DEPDIR)/$(am__dirstamp)
+arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \
+	arm/$(DEPDIR)/$(am__dirstamp)
 mips/$(am__dirstamp):
 	@$(MKDIR_P) mips
 	@: > mips/$(am__dirstamp)
@@ -1140,6 +1146,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/arm_init.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon_intrinsics.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/palette_neon_intrinsics.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngimage.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngstest.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngunknown.Po@am__quote@ # am--include-marker
@@ -2076,6 +2083,7 @@
 	-rm -f arm/$(DEPDIR)/arm_init.Plo
 	-rm -f arm/$(DEPDIR)/filter_neon.Plo
 	-rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo
+	-rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo
 	-rm -f contrib/libtests/$(DEPDIR)/pngimage.Po
 	-rm -f contrib/libtests/$(DEPDIR)/pngstest.Po
 	-rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po
@@ -2160,6 +2168,7 @@
 	-rm -f arm/$(DEPDIR)/arm_init.Plo
 	-rm -f arm/$(DEPDIR)/filter_neon.Plo
 	-rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo
+	-rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo
 	-rm -f contrib/libtests/$(DEPDIR)/pngimage.Po
 	-rm -f contrib/libtests/$(DEPDIR)/pngstest.Po
 	-rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po
diff --git a/README b/README
index f098b27..e41e0f5 100644
--- a/README
+++ b/README
@@ -1,15 +1,16 @@
-README for libpng version 1.6.35 - July 15, 2018 (shared library 16.0)
-See the note about version numbers near the top of png.h
+README for libpng version 1.6.36 - December 1, 2018
+===================================================
 
+See the note about version numbers near the top of png.h.
 See INSTALL for instructions on how to install libpng.
 
 Libpng comes in several distribution formats.  Get libpng-*.tar.gz or
-libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
-or lpng*.7z or lpng*.zip if you want DOS-style line endings.
+libpng-*.tar.xz or if you want UNIX-style line endings in the text
+files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
 
 Version 0.89 was the first official release of libpng.  Don't let the
-fact that it's the first release fool you.  The libpng library has been in
-extensive use and testing since mid-1995.  By late 1997 it had
+fact that it's the first release fool you.  The libpng library has been
+in extensive use and testing since mid-1995.  By late 1997 it had
 finally gotten to the stage where there hadn't been significant
 changes to the API in some time, and people have a bad feeling about
 libraries with versions < 1.0.  Version 1.0.0 was released in
@@ -60,59 +61,37 @@
 to set different actions based on whether the CRC error occurred in a
 critical or an ancillary chunk.
 
-The changes made to the library, and bugs fixed are based on discussions
-on the PNG-implement mailing list and not on material submitted
-privately to Guy, Andreas, or Glenn.  They will forward any good
-suggestions to the list.
-
-For a detailed description on using libpng, read libpng-manual.txt.  For
-examples of libpng in a program, see example.c and pngtest.c.  For usage
-information and restrictions (what little they are) on libpng, see
-png.h.  For a description on using zlib (the compression library used by
-libpng) and zlib's restrictions, see zlib.h
+For a detailed description on using libpng, read libpng-manual.txt.
+For examples of libpng in a program, see example.c and pngtest.c.  For
+usage information and restrictions (what little they are) on libpng,
+see png.h.  For a description on using zlib (the compression library
+used by libpng) and zlib's restrictions, see zlib.h
 
 I have included a general makefile, as well as several machine and
-compiler specific ones, but you may have to modify one for your own needs.
+compiler specific ones, but you may have to modify one for your own
+needs.
 
 You should use zlib 1.0.4 or later to run this, but it MAY work with
 versions as old as zlib 0.95.  Even so, there are bugs in older zlib
 versions which can cause the output of invalid compression streams for
-some images.  You will definitely need zlib 1.0.4 or later if you are
-taking advantage of the MS-DOS "far" structure allocation for the small
-and medium memory models.  You should also note that zlib is a
-compression library that is useful for more things than just PNG files.
-You can use zlib as a drop-in replacement for fread() and fwrite() if
-you are so inclined.
+some images.
 
-zlib should be available at the same place that libpng is, or at zlib.net.
+You should also note that zlib is a compression library that is useful
+for more things than just PNG files.  You can use zlib as a drop-in
+replacement for fread() and fwrite(), if you are so inclined.
+
+zlib should be available at the same place that libpng is, or at
+https://zlib.net.
 
 You may also want a copy of the PNG specification.  It is available
 as an RFC, a W3C Recommendation, and an ISO/IEC Standard.  You can find
 these at http://www.libpng.org/pub/png/pngdocs.html .
 
 This code is currently being archived at libpng.sourceforge.io in the
-[DOWNLOAD] area, and at http://libpng.download/src .  If you
-can't find it in any of those places, e-mail me, and I'll help you find it.
+[DOWNLOAD] area, and at http://libpng.download/src .
 
-I am not a lawyer, but I believe that the Export Control Classification
-Number (ECCN) for libpng is EAR99, which means not subject to export
-controls or International Traffic in Arms Regulations (ITAR) because it
-is open source, publicly available software, that does not contain any
-encryption software.  See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
-
-If you have any code changes, requests, problems, etc., please e-mail
-them to me.  Also, I'd appreciate any make files or project files,
-and any modifications you needed to make to get libpng to compile,
-along with a #define variable to tell what compiler/system you are on.
-If you needed to add transformations to libpng, or wish libpng would
-provide the image in a different way, drop me a note (and code, if
-possible), so I can consider supporting the transformation.
-Finally, if you get any warning messages when compiling libpng
-(note: not zlib), and they are easy to fix, I'd appreciate the
-fix.  Please mention "libpng" somewhere in the subject line.  Thanks.
-
-This release was created and will be supported by myself (of course
-based in a large way on Guy's and Andreas' earlier work), and the PNG
+This release, based in a large way on Glenn's, Guy's and Andreas'
+earlier work, was created and will be supported by myself and the PNG
 development group.
 
 Send comments/corrections/commendations to png-mng-implement at
@@ -120,34 +99,21 @@
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
 to subscribe).
 
-You can't reach Guy, the original libpng author, at the addresses
-given in previous versions of this document.  He and Andreas will
-read mail addressed to the png-implement list, however.
-
-Please do not send general questions about PNG.  Send them to
-png-mng-misc at lists.sf.net (subscription required; visit
+Send general questions about the PNG specification to png-mng-misc
+at lists.sourceforge.net (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
-subscribe).  If you have a question about something
-in the PNG specification that is related to using libpng, send it
-to me.  Send me any questions that start with "I was using libpng,
-and ...".  If in doubt, send questions to me.  I'll bounce them
-to others, if necessary.
-
-Please do not send suggestions on how to change PNG.  We have
-been discussing PNG for twenty years now, and it is official and
-finished.  If you have suggestions for libpng, however, I'll
-gladly listen.  Even if your suggestion is not used immediately,
-it may be used later.
+subscribe).
 
 Files in this distribution:
 
       ANNOUNCE      =>  Announcement of this version, with recent changes
+      AUTHORS       =>  List of contributing authors
       CHANGES       =>  Description of changes between libpng versions
       KNOWNBUG      =>  List of known bugs and deficiencies
       LICENSE       =>  License to use and redistribute libpng
       README        =>  This file
       TODO          =>  Things not implemented in the current library
-      Y2KINFO       =>  Statement of Y2K compliance
+      TRADEMARK     =>  Trademark information
       example.c     =>  Example code for using libpng functions
       libpng.3      =>  manual page for libpng (includes libpng-manual.txt)
       libpng-manual.txt  =>  Description of libpng and its functions
@@ -208,15 +174,10 @@
       scripts       =>  Directory containing scripts for building libpng:
                             (see scripts/README.txt for the list of scripts)
 
-Good luck, and happy coding.
+Good luck, and happy coding!
 
--Glenn Randers-Pehrson (current maintainer, since 1998)
- Internet: glennrp at users.sourceforge.net
-
--Andreas Eric Dilger (former maintainer, 1996-1997)
- Internet: adilger at enel.ucalgary.ca
- Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
-
--Guy Eric Schalnat (original author and former maintainer, 1995-1996)
- (formerly of Group 42, Inc)
- Internet: gschal at infinet.com
+ * Cosmin Truta (current maintainer, since 2018)
+ * Glenn Randers-Pehrson (former maintainer, 1998-2018)
+ * Andreas Eric Dilger (former maintainer, 1996-1997)
+ * Guy Eric Schalnat (original author and former maintainer, 1995-1996)
+   (formerly of Group 42, Inc.)
diff --git a/TODO b/TODO
index 36d6092..562dab0 100644
--- a/TODO
+++ b/TODO
@@ -1,30 +1,23 @@
-/*
 TODO - list of things to do for libpng:
 
-Final bug fixes.
-Better C++ wrapper/full C++ implementation?
-Fix problem with C++ and EXTERN "C".
-cHRM transformation.
-Remove setjmp/longjmp usage in favor of returning error codes. As a start on
-  this, minimize the use of png_error(), replacing them with
-  png_warning(); return(0); or similar.
-Palette creation.
-Add "grayscale->palette" transformation and "palette->grayscale" detection.
-Improved dithering.
-Multi-lingual error and warning message support.
-Complete sRGB transformation (presently it simply uses gamma=0.45455).
-Man pages for function calls.
-Better documentation.
-Better filter selection
-   (counting huffman bits/precompression?  filter inertia?  filter costs?).
-Histogram creation.
-Text conversion between different code pages (Latin-1 -> Mac and DOS).
-Avoid building gamma tables whenever possible.
-Use greater precision when changing to linear gamma for compositing against
-  background and doing rgb-to-gray transformation.
-Investigate pre-incremented loop counters and other loop constructions.
-Add interpolated method of handling interlacing.
-Extend pngvalid.c to validate more of the libpng transformations.
-Refactor preprocessor conditionals to compile entire statements
-
-*/
+* Fix all defects (duh!)
+* Better C++ wrapper / full C++ implementation (?)
+* Fix the problems with C++ and 'extern "C"'.
+* cHRM transformation.
+* Palette creation.
+* "grayscale->palette" transformation and "palette->grayscale" detection.
+* Improved dithering.
+* Multi-lingual error and warning message support.
+* Complete sRGB transformation.  (Currently it simply uses gamma=0.45455.)
+* Man pages for function calls.
+* Better documentation.
+* Better filter selection
+  (e.g., counting huffman bits/precompression; filter inertia; filter costs).
+* Histogram creation.
+* Text conversion between different code pages (e.g., Latin-1 -> Mac).
+* Avoid building gamma tables whenever possible.
+* Greater precision in changing to linear gamma for compositing against
+  background, and in doing rgb-to-gray transformations.
+* Investigate pre-incremented loop counters and other loop constructions.
+* Interpolated method of handling interlacing.
+* More validations for libpng transformations.
diff --git a/TRADEMARK b/TRADEMARK
new file mode 100644
index 0000000..ac66718
--- /dev/null
+++ b/TRADEMARK
@@ -0,0 +1,8 @@
+TRADEMARK
+=========
+
+The name "libpng" has not been registered by the Copyright owners
+as a trademark in any jurisdiction.  However, because libpng has
+been distributed and maintained world-wide, continually since 1995,
+the Copyright owners claim "common-law trademark protection" in any
+jurisdiction where common-law trademark is recognized.
diff --git a/arm/arm_init.c b/arm/arm_init.c
index 02df812..a34ecdb 100644
--- a/arm/arm_init.c
+++ b/arm/arm_init.c
@@ -1,14 +1,15 @@
 
 /* arm_init.c - NEON optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2014,2016 Glenn Randers-Pehrson
  * Written by Mans Rullgard, 2011.
- * Last changed in libpng 1.6.22 [May 26, 2016]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  */
+
 /* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
  * called.
  */
diff --git a/arm/filter_neon.S b/arm/filter_neon.S
index 000764c..2308aad 100644
--- a/arm/filter_neon.S
+++ b/arm/filter_neon.S
@@ -1,9 +1,9 @@
 
 /* filter_neon.S - NEON optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2014,2017 Glenn Randers-Pehrson
  * Written by Mans Rullgard, 2011.
- * Last changed in libpng 1.6.31 [July 27, 2017]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/arm/filter_neon_intrinsics.c b/arm/filter_neon_intrinsics.c
index ea7e356..553c0be 100644
--- a/arm/filter_neon_intrinsics.c
+++ b/arm/filter_neon_intrinsics.c
@@ -1,12 +1,11 @@
 
 /* filter_neon_intrinsics.c - NEON optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2014,2016 Glenn Randers-Pehrson
  * Written by James Yu <james.yu at linaro.org>, October 2013.
  * Based on filter_neon.S, written by Mans Rullgard, 2011.
  *
- * Last changed in libpng 1.6.22 [May 26, 2016]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
@@ -19,7 +18,11 @@
 /* This code requires -mfpu=neon on the command line: */
 #if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
 
-#include <arm_neon.h>
+#if defined(_MSC_VER) && defined(_M_ARM64)
+#  include <arm64_neon.h>
+#else
+#  include <arm_neon.h>
+#endif
 
 /* libpng row pointers are not necessarily aligned to any particular boundary,
  * however this code will only work with appropriate alignment.  arm/arm_init.c
@@ -33,6 +36,11 @@
  * 'type'.  This is written this way just to hide the GCC strict aliasing
  * warning; note that the code is safe because there never is an alias between
  * the input and output pointers.
+ *
+ * When compiling with MSVC ARM64, the png_ldr macro can't be passed directly
+ * to vst4_lane_u32, because of an internal compiler error inside MSVC.
+ * To avoid this compiler bug, we use a temporary variable (vdest_val) to store
+ * the result of png_ldr.
  */
 #define png_ldr(type,pointer)\
    (temp_pointer = png_ptr(type,pointer), *temp_pointer)
@@ -125,12 +133,15 @@
       uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
       uint8x8x4_t vrp = *vrpt;
       uint32x2x4_t *temp_pointer;
+      uint32x2x4_t vdest_val;
 
       vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
       vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
       vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
       vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
-      vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
+
+      vdest_val = png_ldr(uint32x2x4_t, &vdest);
+      vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
    }
 
    PNG_UNUSED(prev_row)
@@ -223,6 +234,7 @@
       uint8x8x4_t *vrpt, *vppt;
       uint8x8x4_t vrp, vpp;
       uint32x2x4_t *temp_pointer;
+      uint32x2x4_t vdest_val;
 
       vtmp = vld4_u32(png_ptr(uint32_t,rp));
       vrpt = png_ptr(uint8x8x4_t,&vtmp);
@@ -240,7 +252,8 @@
       vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
       vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
 
-      vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
+      vdest_val = png_ldr(uint32x2x4_t, &vdest);
+      vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
    }
 }
 
@@ -359,6 +372,7 @@
       uint8x8x4_t *vrpt, *vppt;
       uint8x8x4_t vrp, vpp;
       uint32x2x4_t *temp_pointer;
+      uint32x2x4_t vdest_val;
 
       vtmp = vld4_u32(png_ptr(uint32_t,rp));
       vrpt = png_ptr(uint8x8x4_t,&vtmp);
@@ -378,7 +392,8 @@
 
       vlast = vpp.val[3];
 
-      vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
+      vdest_val = png_ldr(uint32x2x4_t, &vdest);
+      vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
    }
 }
 
diff --git a/arm/palette_neon_intrinsics.c b/arm/palette_neon_intrinsics.c
new file mode 100644
index 0000000..fa02d6a
--- /dev/null
+++ b/arm/palette_neon_intrinsics.c
@@ -0,0 +1,149 @@
+
+/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
+ *
+ * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
+ * Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ */
+
+#include "../pngpriv.h"
+
+#if PNG_ARM_NEON_IMPLEMENTATION == 1
+
+#if defined(_MSC_VER) && defined(_M_ARM64)
+#  include <arm64_neon.h>
+#else
+#  include <arm_neon.h>
+#endif
+
+/* Build an RGBA palette from the RGB and separate alpha palettes. */
+void
+png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info)
+{
+   png_const_colorp palette = png_ptr->palette;
+   png_bytep riffled_palette = png_ptr->riffled_palette;
+   png_const_bytep trans_alpha = png_ptr->trans_alpha;
+   int num_trans = png_ptr->num_trans;
+   int i;
+
+   /* Initially black, opaque. */
+   uint8x16x4_t w = {{
+      vdupq_n_u8(0x00),
+      vdupq_n_u8(0x00),
+      vdupq_n_u8(0x00),
+      vdupq_n_u8(0xff),
+   }};
+
+   if (row_info->bit_depth != 8)
+   {
+      png_error(png_ptr, "bit_depth must be 8 for png_riffle_palette_rgba");
+      return;
+   }
+
+   /* First, riffle the RGB colours into a RGBA palette, the A value is
+    * set to opaque for now.
+    */
+   for (i = 0; i < (1 << row_info->bit_depth); i += 16)
+   {
+      uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
+      w.val[0] = v.val[0];
+      w.val[1] = v.val[1];
+      w.val[2] = v.val[2];
+      vst4q_u8(riffled_palette + (i << 2), w);
+   }
+
+   /* Fix up the missing transparency values. */
+   for (i = 0; i < num_trans; i++)
+      riffled_palette[(i << 2) + 3] = trans_alpha[i];
+}
+
+/* Expands a palettized row into RGBA. */
+int
+png_do_expand_palette_neon_rgba(png_structrp png_ptr, png_row_infop row_info,
+    png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
+{
+   png_uint_32 row_width = row_info->width;
+   const png_uint_32 *riffled_palette =
+      (const png_uint_32 *)png_ptr->riffled_palette;
+   const png_int_32 pixels_per_chunk = 4;
+   int i;
+
+   if (row_width < pixels_per_chunk)
+      return 0;
+
+   /* This function originally gets the last byte of the output row.
+    * The NEON part writes forward from a given position, so we have
+    * to seek this back by 4 pixels x 4 bytes.
+    */
+   *ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
+
+   for (i = 0; i < row_width; i += pixels_per_chunk)
+   {
+      uint32x4_t cur;
+      png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
+      cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
+      cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
+      cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
+      cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
+      vst1q_u32((void *)dp, cur);
+   }
+   if (i != row_width)
+   {
+      /* Remove the amount that wasn't processed. */
+      i -= pixels_per_chunk;
+   }
+
+   /* Decrement output pointers. */
+   *ssp = *ssp - i;
+   *ddp = *ddp - (i << 2);
+   return i;
+}
+
+/* Expands a palettized row into RGB format. */
+int
+png_do_expand_palette_neon_rgb(png_structrp png_ptr, png_row_infop row_info,
+    png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
+{
+   png_uint_32 row_width = row_info->width;
+   png_const_bytep palette = (png_const_bytep)png_ptr->palette;
+   const png_uint_32 pixels_per_chunk = 8;
+   int i;
+
+   if (row_width <= pixels_per_chunk)
+      return 0;
+
+   /* Seeking this back by 8 pixels x 3 bytes. */
+   *ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
+
+   for (i = 0; i < row_width; i += pixels_per_chunk)
+   {
+      uint8x8x3_t cur;
+      png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
+      cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
+      cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
+      vst3_u8((void *)dp, cur);
+   }
+
+   if (i != row_width)
+   {
+      /* Remove the amount that wasn't processed. */
+      i -= pixels_per_chunk;
+   }
+
+   /* Decrement output pointers. */
+   *ssp = *ssp - i;
+   *ddp = *ddp - ((i << 1) + i);
+   return i;
+}
+
+#endif /* PNG_ARM_NEON_IMPLEMENTATION */
diff --git a/config.h.in b/config.h.in
index a0ec9bc..2931048 100644
--- a/config.h.in
+++ b/config.h.in
@@ -18,9 +18,6 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define to 1 if you have the `memset' function. */
-#undef HAVE_MEMSET
-
 /* Define to 1 if you have the `pow' function. */
 #undef HAVE_POW
 
diff --git a/configure b/configure
index 984f3e4..4c8a35e 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libpng 1.6.35.
+# Generated by GNU Autoconf 2.69 for libpng 1.6.36.
 #
 # Report bugs to <png-mng-implement@lists.sourceforge.net>.
 #
@@ -590,8 +590,8 @@
 # Identity of this package.
 PACKAGE_NAME='libpng'
 PACKAGE_TARNAME='libpng'
-PACKAGE_VERSION='1.6.35'
-PACKAGE_STRING='libpng 1.6.35'
+PACKAGE_VERSION='1.6.36'
+PACKAGE_STRING='libpng 1.6.36'
 PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -1372,7 +1372,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libpng 1.6.35 to adapt to many kinds of systems.
+\`configure' configures libpng 1.6.36 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1442,7 +1442,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libpng 1.6.35:";;
+     short | recursive ) echo "Configuration of libpng 1.6.36:";;
    esac
   cat <<\_ACEOF
 
@@ -1622,7 +1622,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libpng configure 1.6.35
+libpng configure 1.6.36
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1954,7 +1954,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libpng $as_me 1.6.35, which was
+It was created by libpng $as_me 1.6.36, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2825,7 +2825,7 @@
 
 # Define the identity of the package.
  PACKAGE='libpng'
- VERSION='1.6.35'
+ VERSION='1.6.36'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2946,10 +2946,10 @@
 
 
 
-PNGLIB_VERSION=1.6.35
+PNGLIB_VERSION=1.6.36
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=6
-PNGLIB_RELEASE=35
+PNGLIB_RELEASE=36
 
 
 
@@ -13066,19 +13066,6 @@
 
 fi
 
-for ac_func in memset
-do :
-  ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset"
-if test "x$ac_cv_func_memset" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_MEMSET 1
-_ACEOF
-
-else
-  as_fn_error $? "memset not found in libc" "$LINENO" 5
-fi
-done
-
 for ac_func in pow
 do :
   ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow"
@@ -14367,7 +14354,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libpng $as_me 1.6.35, which was
+This file was extended by libpng $as_me 1.6.36, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14433,7 +14420,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libpng config.status 1.6.35
+libpng config.status 1.6.36
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index d1787c5..1ed63ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 # configure.ac
 
+# Copyright (c) 2018 Cosmin Truta
 # Copyright (c) 2004-2016 Glenn Randers-Pehrson
-# Last changed in libpng 1.6.25 [September 1, 2016]
 
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -25,7 +25,7 @@
 
 dnl Version number stuff here:
 
-AC_INIT([libpng],[1.6.35],[png-mng-implement@lists.sourceforge.net])
+AC_INIT([libpng],[1.6.36],[png-mng-implement@lists.sourceforge.net])
 AC_CONFIG_MACRO_DIR([scripts])
 
 # libpng does not follow GNU file name conventions (hence 'foreign')
@@ -46,10 +46,10 @@
 dnl AM_PREREQ([1.11.2])
 dnl stop configure from automagically running automake
 
-PNGLIB_VERSION=1.6.35
+PNGLIB_VERSION=1.6.36
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=6
-PNGLIB_RELEASE=35
+PNGLIB_RELEASE=36
 
 dnl End of version number stuff
 
@@ -144,7 +144,6 @@
 
 # Checks for library functions.
 AC_FUNC_STRTOD
-AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
 AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
 
 # Some later POSIX 1003.1 functions are required for test programs, failure here
diff --git a/contrib/conftest/pngcp.dfa b/contrib/conftest/pngcp.dfa
index acf200d..31c411d 100644
--- a/contrib/conftest/pngcp.dfa
+++ b/contrib/conftest/pngcp.dfa
@@ -52,6 +52,6 @@
 option USER_LIMITS on
 option SET_USER_LIMITS on
 
-# these are are just required for specific customizations
+# these are just required for specific customizations
 option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
 option WRITE_CUSTOMIZE_COMPRESSION on
diff --git a/contrib/examples/pngpixel.c b/contrib/examples/pngpixel.c
index f762379..9185d51 100644
--- a/contrib/examples/pngpixel.c
+++ b/contrib/examples/pngpixel.c
@@ -42,7 +42,7 @@
    png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
    png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
 
-   row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
+   row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi);
    row += bit_offset_lo >> 3;
    bit_offset_lo &= 0x07;
 
@@ -73,7 +73,7 @@
 print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
    png_uint_32 x)
 {
-   PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
+   unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
 
    switch (png_get_color_type(png_ptr, info_ptr))
    {
@@ -87,7 +87,7 @@
        */
       case PNG_COLOR_TYPE_PALETTE:
          {
-            PNG_CONST int index = component(row, x, 0, bit_depth, 1);
+            int index = component(row, x, 0, bit_depth, 1);
             png_colorp palette = NULL;
             int num_palette = 0;
 
diff --git a/contrib/gregbook/readpng2.c b/contrib/gregbook/readpng2.c
index 5d13e15..610b3cd 100644
--- a/contrib/gregbook/readpng2.c
+++ b/contrib/gregbook/readpng2.c
@@ -146,7 +146,7 @@
         /* These byte strings were copied from png.h.  If a future version
          * of readpng2.c recognizes more chunks, add them to this list.
          */
-        static PNG_CONST png_byte chunks_to_process[] = {
+        static const png_byte chunks_to_process[] = {
             98,  75,  71,  68, '\0',  /* bKGD */
            103,  65,  77,  65, '\0',  /* gAMA */
            115,  82,  71,  66, '\0',  /* sRGB */
diff --git a/contrib/libtests/makepng.c b/contrib/libtests/makepng.c
index e58a61d..312062b 100644
--- a/contrib/libtests/makepng.c
+++ b/contrib/libtests/makepng.c
@@ -661,7 +661,7 @@
       {
          case 1:
             {
-               const png_uint_32 luma = colors[1];
+               png_uint_32 luma = colors[1];
                png_uint_32 x;
 
                for (x=0; x<=size_max; ++x)
@@ -672,8 +672,8 @@
 
          case 2:
             {
-               const png_uint_32 luma = colors[1];
-               const png_uint_32 alpha = colors[2];
+               png_uint_32 luma = colors[1];
+               png_uint_32 alpha = colors[2];
                png_uint_32 x;
 
                for (x=0; x<size_max; ++x)
@@ -688,9 +688,9 @@
 
          case 3:
             {
-               const png_uint_32 red = colors[1];
-               const png_uint_32 green = colors[2];
-               const png_uint_32 blue = colors[3];
+               png_uint_32 red = colors[1];
+               png_uint_32 green = colors[2];
+               png_uint_32 blue = colors[3];
                png_uint_32 x;
 
                for (x=0; x<=size_max; ++x)
@@ -707,10 +707,10 @@
 
          case 4:
             {
-               const png_uint_32 red = colors[1];
-               const png_uint_32 green = colors[2];
-               const png_uint_32 blue = colors[3];
-               const png_uint_32 alpha = colors[4];
+               png_uint_32 red = colors[1];
+               png_uint_32 green = colors[2];
+               png_uint_32 blue = colors[3];
+               png_uint_32 alpha = colors[4];
                png_uint_32 x;
 
                for (x=0; x<=size_max; ++x)
@@ -812,7 +812,7 @@
       png_error(png_ptr, "OOM allocating info structure");
 
    {
-      const unsigned int size =
+      unsigned int size =
          image_size_of_type(color_type, bit_depth, colors, small);
       unsigned int ysize;
       png_fixed_point real_gamma = 45455; /* For sRGB */
@@ -824,7 +824,7 @@
        */
       if (small)
       {
-         const unsigned int pixel_depth =
+         unsigned int pixel_depth =
             pixel_depth_of_type(color_type, bit_depth);
 
          if (pixel_depth <= 8U)
@@ -1378,10 +1378,10 @@
 insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
       png_charpp params)
 {
-   const int ct = png_get_color_type(png_ptr, info_ptr);
-   const int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
+   int ct = png_get_color_type(png_ptr, info_ptr);
+   int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
       (ct & PNG_COLOR_MASK_ALPHA ? 1 : 0);
-   const unsigned int maxval =
+   unsigned int maxval =
       ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
    png_color_8 sBIT;
 
@@ -1856,7 +1856,7 @@
 
    /* Check the colors */
    {
-      const unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
+      unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
          (1U<<bit_depth)-1);
       unsigned int i;
 
diff --git a/contrib/libtests/pngimage.c b/contrib/libtests/pngimage.c
index 998d58c..f130c04 100644
--- a/contrib/libtests/pngimage.c
+++ b/contrib/libtests/pngimage.c
@@ -1446,7 +1446,7 @@
        * unsigned, because some transforms are negative on a 16-bit system.
        */
       unsigned int active = dp->active_transforms;
-      const int exhaustive = (dp->options & EXHAUSTIVE) != 0;
+      int exhaustive = (dp->options & EXHAUSTIVE) != 0;
       unsigned int current = first_transform(active);
       unsigned int bad_transforms = 0;
       unsigned int bad_combo = ~0U;    /* bitwise AND of failing transforms */
@@ -1572,7 +1572,7 @@
 }
 
 int
-main(const int argc, const char * const * const argv)
+main(int argc, char **argv)
 {
    /* For each file on the command line test it with a range of transforms */
    int option_end, ilog = 0;
@@ -1674,7 +1674,7 @@
          /* Here on any return, including failures, except user/internal issues
           */
          {
-            const int pass = (d.options & STRICT) ?
+            int pass = (d.options & STRICT) ?
                RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
 
             if (!pass)
diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c
index 74c8d10..a368bf0 100644
--- a/contrib/libtests/pngstest.c
+++ b/contrib/libtests/pngstest.c
@@ -372,7 +372,7 @@
  */
 #define FORMAT_COUNT 64
 #define FORMAT_MASK 0x3f
-static PNG_CONST char * PNG_CONST format_names[FORMAT_COUNT] =
+static const char * const format_names[FORMAT_COUNT] =
 {
    "sRGB-gray",
    "sRGB-gray+alpha",
@@ -2346,8 +2346,8 @@
 logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y,
    const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason)
 {
-   const png_uint_32 in_format = transform->in_image->image.format;
-   const png_uint_32 out_format = transform->out_image->image.format;
+   png_uint_32 in_format = transform->in_image->image.format;
+   png_uint_32 out_format = transform->out_image->image.format;
 
    png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA;
    const char *via_linear = "";
@@ -2602,12 +2602,12 @@
    ptrdiff_t strideb = b->stride;
    png_const_bytep rowa = a->buffer+16;
    png_const_bytep rowb = b->buffer+16;
-   const png_uint_32 width = a->image.width;
-   const png_uint_32 height = a->image.height;
-   const png_uint_32 formata = a->image.format;
-   const png_uint_32 formatb = b->image.format;
-   const unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
-   const unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
+   png_uint_32 width = a->image.width;
+   png_uint_32 height = a->image.height;
+   png_uint_32 formata = a->image.format;
+   png_uint_32 formatb = b->image.format;
+   unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
+   unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
    int alpha_added, alpha_removed;
    int bchannels;
    png_uint_32 y;
@@ -2726,7 +2726,7 @@
                result = 0;
          }
 
-         /* If reqested copy the error values back from the Transform. */
+         /* If requested, copy the error values back from the Transform. */
          if (a->opts & ACCUMULATE)
          {
             tr.error_ptr[0] = tr.error[0];
@@ -2790,8 +2790,7 @@
       (formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR)))
    {
       /* Was an alpha channel changed? */
-      const png_uint_32 alpha_changed = (formata ^ formatb) &
-         PNG_FORMAT_FLAG_ALPHA;
+      png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA;
 
       /* Was an alpha channel removed?  (The third test.)  If so the direct
        * comparison is only possible if the input alpha is opaque.
@@ -2932,7 +2931,7 @@
       }
    }
 
-   /* If reqested copy the error values back from the Transform. */
+   /* If requested, copy the error values back from the Transform. */
    if (a->opts & ACCUMULATE)
    {
       tr.error_ptr[0] = tr.error[0];
@@ -3627,7 +3626,7 @@
 
          if (arg[0] == '-')
          {
-            const int term = (arg[1] == '0' ? 0 : '\n');
+            int term = (arg[1] == '0' ? 0 : '\n');
             unsigned int ich = 0;
 
             /* Loop reading files, use a static buffer to simplify this and just
diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c
index d9cc448..05bdd83 100644
--- a/contrib/libtests/pngunknown.c
+++ b/contrib/libtests/pngunknown.c
@@ -56,7 +56,7 @@
    defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
 
 #if PNG_LIBPNG_VER < 10500
-/* This deliberately lacks the PNG_CONST. */
+/* This deliberately lacks the const. */
 typedef png_byte *png_const_bytep;
 
 /* This is copied from 1.5.1 png.h: */
diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c
index e66f2fa..d800110 100644
--- a/contrib/libtests/pngvalid.c
+++ b/contrib/libtests/pngvalid.c
@@ -21,6 +21,7 @@
 #define _POSIX_SOURCE 1
 #define _ISOC99_SOURCE 1 /* For floating point */
 #define _GNU_SOURCE 1 /* For the floating point exception extension */
+#define _BSD_SOURCE 1 /* For the floating point exception extension */
 
 #include <signal.h>
 #include <stdio.h>
@@ -961,7 +962,7 @@
    return b; /* 0..32 */
 }
 
-/* Main interface to file storeage, after writing a new PNG file (see the API
+/* Main interface to file storage, after writing a new PNG file (see the API
  * below) call store_storefile to store the result with the given name and id.
  */
 static void
@@ -2589,7 +2590,7 @@
     * rounding and 'do_round' should be 1, if it is 0 the digitized value will
     * be truncated.
     */
-   const unsigned int digitization_factor = (1U << depth) -1;
+   unsigned int digitization_factor = (1U << depth) - 1;
 
    /* Limiting the range is done as a convenience to the caller - it's easier to
     * do it once here than every time at the call site.
@@ -3687,8 +3688,8 @@
 
 #ifdef PNG_WRITE_tRNS_SUPPORTED
 static void
-set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
-   const int bit_depth)
+set_random_tRNS(png_structp pp, png_infop pi, png_byte colour_type,
+   int bit_depth)
 {
    /* To make this useful the tRNS color needs to match at least one pixel.
     * Random values are fine for gray, including the 16-bit case where we know
@@ -3696,7 +3697,7 @@
     * method as only 65536 different RGB values are generated.
     */
    png_color_16 tRNS;
-   const png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1);
+   png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1);
 
    R8(tRNS); /* makes unset fields random */
 
@@ -4337,7 +4338,7 @@
 
       /* Make a name and get an appropriate id for the store: */
       char name[FILE_NAME_SIZE];
-      const png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
+      png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
          interlace_type, w, h, do_interlace);
 
       standard_name_from_id(name, sizeof name, 0, id);
@@ -4413,7 +4414,7 @@
          for (pass=0; pass<npasses; ++pass)
          {
             /* The following two are for checking the macros: */
-            const png_uint_32 wPass = PNG_PASS_COLS(w, pass);
+            png_uint_32 wPass = PNG_PASS_COLS(w, pass);
 
             /* If do_interlace is set we don't call png_write_row for every
              * row because some of them are empty.  In fact, for a 1x1 image,
@@ -4645,7 +4646,7 @@
    Try
    {
       png_infop pi;
-      const png_structp pp = set_store_for_write(ps, &pi, name);
+      png_structp pp = set_store_for_write(ps, &pi, name);
       png_uint_32 w, h;
       gnu_volatile(pp)
 
@@ -4705,7 +4706,7 @@
       else
       {
          /* Now write the whole image, just to make sure that the detected, or
-          * undetected, errro has not created problems inside libpng.  This
+          * undetected, error has not created problems inside libpng.  This
           * doesn't work if there was a png_error in png_write_info because that
           * can abort before PLTE was written.
           */
@@ -5468,14 +5469,14 @@
 
 static void
 sequential_row(standard_display *dp, png_structp pp, png_infop pi,
-    const int iImage, const int iDisplay)
+    int iImage, int iDisplay)
 {
-   const int         npasses = dp->npasses;
-   const int         do_interlace = dp->do_interlace &&
+   int npasses = dp->npasses;
+   int do_interlace = dp->do_interlace &&
       dp->interlace_type == PNG_INTERLACE_ADAM7;
-   const png_uint_32 height = standard_height(pp, dp->id);
-   const png_uint_32 width = standard_width(pp, dp->id);
-   const png_store*  ps = dp->ps;
+   png_uint_32 height = standard_height(pp, dp->id);
+   png_uint_32 width = standard_width(pp, dp->id);
+   const png_store* ps = dp->ps;
    int pass;
 
    for (pass=0; pass<npasses; ++pass)
@@ -5869,7 +5870,7 @@
     */
    static const png_byte hinc[] = {1, 3, 11, 1, 5};
    static const png_byte winc[] = {1, 9, 5, 7, 1};
-   const int save_bdlo = bdlo;
+   int save_bdlo = bdlo;
 
    for (; bdlo <= bdhi; ++bdlo)
    {
@@ -6077,12 +6078,12 @@
     png_byte bit_depth, png_uint_32 x, store_palette palette,
     const image_pixel *format /*from pngvalid transform of input*/)
 {
-   const png_byte sample_depth = (png_byte)(colour_type ==
-      PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth);
-   const unsigned int max = (1U<<sample_depth)-1;
-   const int swap16 = (format != 0 && format->swap16);
-   const int littleendian = (format != 0 && format->littleendian);
-   const int sig_bits = (format != 0 && format->sig_bits);
+   png_byte sample_depth =
+      (png_byte)(colour_type == PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth);
+   unsigned int max = (1U<<sample_depth)-1;
+   int swap16 = (format != 0 && format->swap16);
+   int littleendian = (format != 0 && format->littleendian);
+   int sig_bits = (format != 0 && format->sig_bits);
 
    /* Initially just set everything to the same number and the alpha to opaque.
     * Note that this currently assumes a simple palette where entry x has colour
@@ -6100,7 +6101,7 @@
       /* This permits the caller to default to the sample value. */
       if (palette != 0)
       {
-         const unsigned int i = this->palette_index;
+         unsigned int i = this->palette_index;
 
          this->red = palette[i].red;
          this->green = palette[i].green;
@@ -6431,8 +6432,8 @@
 image_transform_mod_end(const image_transform *this, image_pixel *that,
     png_const_structp pp, const transform_display *display)
 {
-   const unsigned int scale = (1U<<that->sample_depth)-1;
-   const int sig_bits = that->sig_bits;
+   unsigned int scale = (1U<<that->sample_depth)-1;
+   int sig_bits = that->sig_bits;
 
    UNUSED(this)
    UNUSED(pp)
@@ -6755,19 +6756,19 @@
 {
    /* Constants for the loop below: */
    const png_store* const ps = dp->this.ps;
-   const png_byte in_ct = dp->this.colour_type;
-   const png_byte in_bd = dp->this.bit_depth;
-   const png_uint_32 w = dp->this.w;
-   const png_uint_32 h = dp->this.h;
-   const png_byte out_ct = dp->output_colour_type;
-   const png_byte out_bd = dp->output_bit_depth;
-   const png_byte sample_depth = (png_byte)(out_ct ==
-      PNG_COLOR_TYPE_PALETTE ? 8 : out_bd);
-   const png_byte red_sBIT = dp->this.red_sBIT;
-   const png_byte green_sBIT = dp->this.green_sBIT;
-   const png_byte blue_sBIT = dp->this.blue_sBIT;
-   const png_byte alpha_sBIT = dp->this.alpha_sBIT;
-   const int have_tRNS = dp->this.is_transparent;
+   png_byte in_ct = dp->this.colour_type;
+   png_byte in_bd = dp->this.bit_depth;
+   png_uint_32 w = dp->this.w;
+   png_uint_32 h = dp->this.h;
+   png_byte out_ct = dp->output_colour_type;
+   png_byte out_bd = dp->output_bit_depth;
+   png_byte sample_depth =
+      (png_byte)(out_ct == PNG_COLOR_TYPE_PALETTE ? 8 : out_bd);
+   png_byte red_sBIT = dp->this.red_sBIT;
+   png_byte green_sBIT = dp->this.green_sBIT;
+   png_byte blue_sBIT = dp->this.blue_sBIT;
+   png_byte alpha_sBIT = dp->this.alpha_sBIT;
+   int have_tRNS = dp->this.is_transparent;
    double digitization_error;
 
    store_palette out_palette;
@@ -6928,7 +6929,7 @@
 
 /* A single test run. */
 static void
-transform_test(png_modifier *pmIn, const png_uint_32 idIn,
+transform_test(png_modifier *pmIn, png_uint_32 idIn,
     const image_transform* transform_listIn, const char * const name)
 {
    transform_display d;
@@ -7763,7 +7764,7 @@
 image_transform_png_set_rgb_to_gray_set(const image_transform *this,
     transform_display *that, png_structp pp, png_infop pi)
 {
-   const int error_action = 1; /* no error, no defines in png.h */
+   int error_action = 1; /* no error, no defines in png.h */
 
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
       png_set_rgb_to_gray(pp, error_action, data.red_to_set, data.green_to_set);
@@ -7904,10 +7905,10 @@
 #  if DIGITIZE
       {
          png_modifier *pm = display->pm;
-         const unsigned int sample_depth = that->sample_depth;
-         const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
+         unsigned int sample_depth = that->sample_depth;
+         unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
             sample_depth);
-         const unsigned int gamma_depth =
+         unsigned int gamma_depth =
             (sample_depth == 16 ?
                display->max_gamma_8 :
                (pm->assume_16_bit_calculations ?
@@ -8001,7 +8002,7 @@
             b * data.blue_coefficient;
 
          {
-            const int do_round = data.gamma != 1 || calc_depth == 16;
+            int do_round = data.gamma != 1 || calc_depth == 16;
             const double ce = 2. / 32768;
 
             graylo = DD(rlo * (data.red_coefficient-ce) +
@@ -8625,7 +8626,7 @@
        (that->colour_type == PNG_COLOR_TYPE_RGB ||
         that->colour_type == PNG_COLOR_TYPE_GRAY))
    {
-      const unsigned int max = (1U << that->bit_depth)-1;
+      unsigned int max = (1U << that->bit_depth)-1;
       that->alpha = data.filler & max;
       that->alphaf = ((double)that->alpha) / max;
       that->alphae = 0;
@@ -8692,7 +8693,7 @@
        (that->colour_type == PNG_COLOR_TYPE_RGB ||
         that->colour_type == PNG_COLOR_TYPE_GRAY))
    {
-      const unsigned int max = (1U << that->bit_depth)-1;
+      unsigned int max = (1U << that->bit_depth)-1;
       that->alpha = data.filler & max;
       that->alphaf = ((double)that->alpha) / max;
       that->alphae = 0;
@@ -8883,7 +8884,7 @@
     * field is randomized independently.  This acts as a check that
     * libpng does use the correct field.
     */
-   const unsigned int depth = that->this.bit_depth;
+   unsigned int depth = that->this.bit_depth;
 
    data.red = (png_byte)/*SAFE*/(random_mod(depth)+1);
    data.green = (png_byte)/*SAFE*/(random_mod(depth)+1);
@@ -9298,12 +9299,12 @@
          int mode = dp->do_background - ALPHA_MODE_OFFSET;
 
          /* The gamma value is the output gamma, and is in the standard,
-          * non-inverted, represenation.  It provides a default for the PNG file
+          * non-inverted, representation.  It provides a default for the PNG file
           * gamma, but since the file has a gAMA chunk this does not matter.
           */
          const double sg = dp->screen_gamma;
 #        ifndef PNG_FLOATING_POINT_SUPPORTED
-            const png_fixed_point g = fix(sg);
+            png_fixed_point g = fix(sg);
 #        endif
 
 #        ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -9351,7 +9352,7 @@
           */
          const double bg = dp->background_gamma;
 #        ifndef PNG_FLOATING_POINT_SUPPORTED
-            const png_fixed_point g = fix(bg);
+            png_fixed_point g = fix(bg);
 #        endif
 
 #        ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -9425,7 +9426,7 @@
 init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp,
     int in_depth, int out_depth)
 {
-   const unsigned int outmax = (1U<<out_depth)-1;
+   unsigned int outmax = (1U<<out_depth)-1;
 
    vi->pp = pp;
    vi->dp = dp;
@@ -9587,14 +9588,14 @@
 /* This API returns the encoded *input* component, in the range 0..1 */
 static double
 gamma_component_validate(const char *name, const validate_info *vi,
-    const unsigned int id, const unsigned int od,
+    unsigned int id, unsigned int od,
     const double alpha /* <0 for the alpha channel itself */,
     const double background /* component background value */)
 {
-   const unsigned int isbit = id >> vi->isbit_shift;
-   const unsigned int sbit_max = vi->sbit_max;
-   const unsigned int outmax = vi->outmax;
-   const int do_background = vi->do_background;
+   unsigned int isbit = id >> vi->isbit_shift;
+   unsigned int sbit_max = vi->sbit_max;
+   unsigned int outmax = vi->outmax;
+   int do_background = vi->do_background;
 
    double i;
 
@@ -10160,13 +10161,13 @@
 {
    /* Get some constants derived from the input and output file formats: */
    const png_store* const ps = dp->this.ps;
-   const png_byte in_ct = dp->this.colour_type;
-   const png_byte in_bd = dp->this.bit_depth;
-   const png_uint_32 w = dp->this.w;
-   const png_uint_32 h = dp->this.h;
+   png_byte in_ct = dp->this.colour_type;
+   png_byte in_bd = dp->this.bit_depth;
+   png_uint_32 w = dp->this.w;
+   png_uint_32 h = dp->this.h;
    const size_t cbRow = dp->this.cbRow;
-   const png_byte out_ct = png_get_color_type(pp, pi);
-   const png_byte out_bd = png_get_bit_depth(pp, pi);
+   png_byte out_ct = png_get_color_type(pp, pi);
+   png_byte out_bd = png_get_bit_depth(pp, pi);
 
    /* There are three sources of error, firstly the quantization in the
     * file encoding, determined by sbit and/or the file depth, secondly
@@ -10207,11 +10208,11 @@
     * The basic tests below do not do this, however if 'use_input_precision'
     * is set a subsequent test is performed above.
     */
-   const unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
+   unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
    int processing;
    png_uint_32 y;
    const store_palette_entry *in_palette = dp->this.palette;
-   const int in_is_transparent = dp->this.is_transparent;
+   int in_is_transparent = dp->this.is_transparent;
    int process_tRNS;
    int out_npalette = -1;
    int out_is_transparent = 0; /* Just refers to the palette case */
@@ -10259,9 +10260,9 @@
             double alpha = 1; /* serves as a flag value */
 
             /* Record the palette index for index images. */
-            const unsigned int in_index =
+            unsigned int in_index =
                in_ct == 3 ? sample(std, 3, in_bd, x, 0, 0, 0) : 256;
-            const unsigned int out_index =
+            unsigned int out_index =
                out_ct == 3 ? sample(std, 3, out_bd, x, 0, 0, 0) : 256;
 
             /* Handle input alpha - png_set_background will cause the output
@@ -10270,7 +10271,7 @@
             if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 ||
                 (in_ct == 3 && in_is_transparent))
             {
-               const unsigned int input_alpha = in_ct == 3 ?
+               unsigned int input_alpha = in_ct == 3 ?
                   dp->this.palette[in_index].alpha :
                   sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0);
 
@@ -10395,14 +10396,14 @@
  * maxpc:  maximum percentage error (as a percentage)
  */
 static void
-gamma_test(png_modifier *pmIn, const png_byte colour_typeIn,
-    const png_byte bit_depthIn, const int palette_numberIn,
-    const int interlace_typeIn,
+gamma_test(png_modifier *pmIn, png_byte colour_typeIn,
+    png_byte bit_depthIn, int palette_numberIn,
+    int interlace_typeIn,
     const double file_gammaIn, const double screen_gammaIn,
-    const png_byte sbitIn, const int threshold_testIn,
+    png_byte sbitIn, int threshold_testIn,
     const char *name,
-    const int use_input_precisionIn, const int scale16In,
-    const int expand16In, const int do_backgroundIn,
+    int use_input_precisionIn, int scale16In,
+    int expand16In, int do_backgroundIn,
     const png_color_16 *bkgd_colorIn, double bkgd_gammaIn)
 {
    gamma_display d;
@@ -10606,11 +10607,11 @@
 }
 
 static void gamma_transform_test(png_modifier *pm,
-   const png_byte colour_type, const png_byte bit_depth,
-   const int palette_number,
-   const int interlace_type, const double file_gamma,
-   const double screen_gamma, const png_byte sbit,
-   const int use_input_precision, const int scale16)
+   png_byte colour_type, png_byte bit_depth,
+   int palette_number,
+   int interlace_type, const double file_gamma,
+   const double screen_gamma, png_byte sbit,
+   int use_input_precision, int scale16)
 {
    size_t pos = 0;
    char name[64];
@@ -10767,12 +10768,12 @@
 #if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
    defined(PNG_READ_ALPHA_MODE_SUPPORTED)
 static void gamma_composition_test(png_modifier *pm,
-   const png_byte colour_type, const png_byte bit_depth,
-   const int palette_number,
-   const int interlace_type, const double file_gamma,
+   png_byte colour_type, png_byte bit_depth,
+   int palette_number,
+   int interlace_type, const double file_gamma,
    const double screen_gamma,
-   const int use_input_precision, const int do_background,
-   const int expand_16)
+   int use_input_precision, int do_background,
+   int expand_16)
 {
    size_t pos = 0;
    png_const_charp base;
diff --git a/contrib/libtests/tarith.c b/contrib/libtests/tarith.c
index c95226f..c03f05a 100644
--- a/contrib/libtests/tarith.c
+++ b/contrib/libtests/tarith.c
@@ -331,8 +331,8 @@
     */
    size_t index = 0;
    const char test = (char)ch;
-   const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
-   const int character_accepted = (index == 1);
+   int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
+   int character_accepted = (index == 1);
 
    if (c.check_state != exponent && isdigit(ch) && ch != '0')
       c.is_zero = 0;
diff --git a/contrib/powerpc-vsx/linux_aux.c b/contrib/powerpc-vsx/linux_aux.c
index 796922d..7828aca 100644
--- a/contrib/powerpc-vsx/linux_aux.c
+++ b/contrib/powerpc-vsx/linux_aux.c
@@ -23,14 +23,12 @@
 static int
 png_have_vsx(png_structp png_ptr)
 {
-
-   const unsigned long auxv = getauxval( AT_HWCAP );
+   unsigned long auxv = getauxval(AT_HWCAP);
 
    PNG_UNUSED(png_ptr)
 
-   if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX ))
+   if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX))
       return 1;
    else
       return 0;
 }
-
diff --git a/contrib/tools/makesRGB.c b/contrib/tools/makesRGB.c
index e66c9f1..d0c0ca9 100644
--- a/contrib/tools/makesRGB.c
+++ b/contrib/tools/makesRGB.c
@@ -388,7 +388,7 @@
 
    if (!test_only)
    {
-      printf("PNG_CONST png_uint_16 png_sRGB_table[256] =\n{\n   ");
+      printf("const png_uint_16 png_sRGB_table[256] =\n{\n   ");
       for (i=0; i<255; )
       {
          do
@@ -401,7 +401,7 @@
       printf("%d\n};\n\n", png_sRGB_table[i]);
 
 
-      printf("PNG_CONST png_uint_16 png_sRGB_base[512] =\n{\n   ");
+      printf("const png_uint_16 png_sRGB_base[512] =\n{\n   ");
       for (i=0; i<511; )
       {
          do
@@ -413,7 +413,7 @@
       }
       printf("%d\n};\n\n", png_sRGB_base[i]);
 
-      printf("PNG_CONST png_byte png_sRGB_delta[512] =\n{\n   ");
+      printf("const png_byte png_sRGB_delta[512] =\n{\n   ");
       for (i=0; i<511; )
       {
          do
diff --git a/contrib/tools/pngcp.c b/contrib/tools/pngcp.c
index f6a0d50..16d4e7f 100644
--- a/contrib/tools/pngcp.c
+++ b/contrib/tools/pngcp.c
@@ -735,7 +735,7 @@
 static int
 get_option(struct display *dp, const char *opt, int *value)
 {
-   const png_byte i = option_index(dp, opt, strlen(opt));
+   png_byte i = option_index(dp, opt, strlen(opt));
 
    if (dp->entry[i]) /* option was set on command line */
    {
@@ -789,7 +789,7 @@
     * numerical value.
     */
 {
-   const unsigned int sp = dp->csp; /* stack entry of next searched option */
+   unsigned int sp = dp->csp; /* stack entry of next searched option */
 
    if (sp >= dp->tsp)
    {
@@ -797,7 +797,7 @@
        * searched entry or the start of the dp->curr buffer if there is nothing
        * on the stack yet (sp == 0).
        */
-      const int offset = set_opt_string_(dp, sp, opt, entry_name);
+      int offset = set_opt_string_(dp, sp, opt, entry_name);
 
       if (sp > 0)
          dp->stack[sp-1].opt_string_end = offset;
@@ -1222,7 +1222,7 @@
 }
 
 static int
-getallopts_(struct display *dp, const png_byte opt, int *value, int record)
+getallopts_(struct display *dp, png_byte opt, int *value, int record)
    /* Like getop but iterate over all the values if the option was set to "all".
     */
 {
@@ -1259,7 +1259,7 @@
    /* As above except that if the option was not set try a search */
 {
    png_byte istrat;
-   const png_byte opt = option_index(dp, opt_str, strlen(opt_str));
+   png_byte opt = option_index(dp, opt_str, strlen(opt_str));
    int record = options[opt].search;
    const char *entry_name;
 
@@ -2220,7 +2220,7 @@
    strcpy(dp->best, dp->curr);
    dp->best_size = dp->write_size;
 
-   if (dp->nsp > 0) /* interating over lists */
+   if (dp->nsp > 0) /* iterating over lists */
    {
       char *tmpname, tmpbuf[(sizeof dp->namebuf) + 4];
       assert(dp->curr[0] == ' ' && dp->tsp > 0);
@@ -2302,7 +2302,7 @@
 }
 
 int
-main(const int argc, const char * const * const argv)
+main(int argc, char **argv)
 {
    /* For each file on the command line test it with a range of transforms */
    int option_end;
@@ -2379,7 +2379,7 @@
          /* Here on any return, including failures, except user/internal issues
           */
          {
-            const int pass = (d.options & STRICT) ?
+            int pass = (d.options & STRICT) ?
                RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
 
             if (!pass)
diff --git a/contrib/tools/pngfix.c b/contrib/tools/pngfix.c
index f494230..2fa5d13 100644
--- a/contrib/tools/pngfix.c
+++ b/contrib/tools/pngfix.c
@@ -772,7 +772,7 @@
          return 0;
 
       /* Chunks that specify gamma encoding which should therefore only be
-       * removed the the user insists:
+       * removed if the user insists:
        */
       case png_gAMA: case png_sRGB:
          if (global->skip >= SKIP_ALL)
@@ -2514,7 +2514,7 @@
        */
       for (;;)
       {
-         const unsigned int count = list->count;
+         unsigned int count = list->count;
          unsigned int i;
 
          for (i = 0; i<count; ++i)
@@ -2791,7 +2791,7 @@
     * to read_chunk.
     */
 {
-   const png_uint_32 type = file->type;
+   png_uint_32 type = file->type;
 
    if (file->global->verbose > 1)
    {
@@ -3152,7 +3152,7 @@
       }
    }
 
-   /* Control gets to here if the the stream seems invalid or damaged in some
+   /* Control gets to here if the stream seems invalid or damaged in some
     * way.  Either there was a problem reading all the expected data (this
     * chunk's data, its CRC and the length and type of the next chunk) or the
     * next chunk length/type are invalid.  Notice that the cases that end up
@@ -3710,7 +3710,7 @@
 "            practice most programs will ignore it.",
 "        bKGD [transform]: This is used by libpng transforms."
 "    --max=<number>:",
-"      Use IDAT chunks sized <number>.  If no number is given the the IDAT",
+"      Use IDAT chunks sized <number>.  If no number is given the IDAT",
 "      chunks will be the maximum size permitted; 2^31-1 bytes.  If the option",
 "      is omitted the original chunk sizes will not be changed.  When the",
 "      option is given --strip=unsafe is set automatically. This may be",
diff --git a/example.c b/example.c
index 34ecfde..2e2afaa 100644
--- a/example.c
+++ b/example.c
@@ -2,19 +2,20 @@
 #if 0 /* in case someone actually tries to compile this */
 
 /* example.c - an example of using libpng
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ *
  * Maintained 2018 Cosmin Truta
  * Maintained 1998-2016 Glenn Randers-Pehrson
- * Maintained 1996, 1997 Andreas Dilger)
- * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Maintained 1996-1997 Andreas Dilger
+ * Written 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+ *
  * To the extent possible under law, the authors have waived
  * all copyright and related or neighboring rights to this file.
  * This work is published from: United States, Canada.
  */
 
 /* This is an example of how to use libpng to read and write PNG files.
- * The file libpng-manual.txt is much more verbose then this.  If you have not
- * read it, do so first.  This was designed to be a starting point of an
+ * The file libpng-manual.txt is much more verbose then this.  If you have
+ * not read it, do so first.  This was designed to be a starting point of an
  * implementation.  This is not officially part of libpng, is hereby placed
  * in the public domain, and therefore does not require a copyright notice.
  *
@@ -25,16 +26,17 @@
  * see also the programs in the contrib directory.
  */
 
-/* The simple, but restricted, approach to reading a PNG file or data stream
- * just requires two function calls, as in the following complete program.
- * Writing a file just needs one function call, so long as the data has an
+/* The simple, but restricted approach to reading a PNG file or data stream
+ * requires just two function calls, as in the following complete program.
+ * Writing a file needs just one function call, so long as the data has an
  * appropriate layout.
  *
  * The following code reads PNG image data from a file and writes it, in a
- * potentially new format, to a new file.  While this code will compile there is
- * minimal (insufficient) error checking; for a more realistic version look at
- * contrib/examples/pngtopng.c
+ * potentially new format, to a new file.  While this code will compile, there
+ * is minimal (insufficient) error checking.  For a more realistic version,
+ * see contrib/examples/pngtopng.c
  */
+
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
@@ -69,28 +71,28 @@
           */
          buffer = malloc(PNG_IMAGE_SIZE(image));
 
-         /* If enough memory was available read the image in the desired format
-          * then write the result out to the new file.  'background' is not
-          * necessary when reading the image because the alpha channel is
+         /* If enough memory was available, read the image in the desired
+          * format, then write the result out to the new file.  'background' is
+          * not necessary when reading the image, because the alpha channel is
           * preserved; if it were to be removed, for example if we requested
           * PNG_FORMAT_RGB, then either a solid background color would have to
-          * be supplied or the output buffer would have to be initialized to the
-          * actual background of the image.
+          * be supplied, or the output buffer would have to be initialized to
+          * the actual background of the image.
           *
           * The fourth argument to png_image_finish_read is the 'row_stride' -
           * this is the number of components allocated for the image in each
           * row.  It has to be at least as big as the value returned by
           * PNG_IMAGE_ROW_STRIDE, but if you just allocate space for the
-          * default, minimum, size using PNG_IMAGE_SIZE as above you can pass
+          * default, minimum size, using PNG_IMAGE_SIZE as above, you can pass
           * zero.
           *
           * The final argument is a pointer to a buffer for the colormap;
-          * colormaps have exactly the same format as a row of image pixels (so
-          * you choose what format to make the colormap by setting
+          * colormaps have exactly the same format as a row of image pixels
+          * (so you choose what format to make the colormap by setting
           * image.format).  A colormap is only returned if
           * PNG_FORMAT_FLAG_COLORMAP is also set in image.format, so in this
           * case NULL is passed as the final argument.  If you do want to force
-          * all images into an index/color-mapped format then you can use:
+          * all images into an index/color-mapped format, then you can use:
           *
           *    PNG_IMAGE_COLORMAP_SIZE(image)
           *
@@ -112,17 +114,15 @@
                exit(0);
             }
          }
-
          else
          {
             /* Calling png_image_free is optional unless the simplified API was
-             * not run to completion.  In this case if there wasn't enough
-             * memory for 'buffer' we didn't complete the read, so we must free
-             * the image:
+             * not run to completion.  In this case, if there wasn't enough
+             * memory for 'buffer', we didn't complete the read, so we must
+             * free the image:
              */
             if (buffer == NULL)
                png_image_free(&image);
-
             else
                free(buffer);
       }
@@ -131,65 +131,67 @@
        * textual message in the 'png_image' structure:
        */
       fprintf(stderr, "pngtopng: error: %s\n", image.message);
-      exit (1);
+      exit(1);
    }
 
    fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n");
-   exit(1);
+   exit(2);
 }
 
 /* That's it ;-)  Of course you probably want to do more with PNG files than
  * just converting them all to 32-bit RGBA PNG files; you can do that between
  * the call to png_image_finish_read and png_image_write_to_file.  You can also
- * ask for the image data to be presented in a number of different formats.  You
- * do this by simply changing the 'format' parameter set before allocating the
- * buffer.
+ * ask for the image data to be presented in a number of different formats.
+ * You do this by simply changing the 'format' parameter set before allocating
+ * the buffer.
  *
  * The format parameter consists of five flags that define various aspects of
- * the image, you can simply add these together to get the format or you can use
- * one of the predefined macros from png.h (as above):
+ * the image.  You can simply add these together to get the format, or you can
+ * use one of the predefined macros from png.h (as above):
  *
- * PNG_FORMAT_FLAG_COLOR: if set the image will have three color components per
- *    pixel (red, green and blue), if not set the image will just have one
+ * PNG_FORMAT_FLAG_COLOR: if set, the image will have three color components
+ *    per pixel (red, green and blue); if not set, the image will just have one
  *    luminance (grayscale) component.
  *
- * PNG_FORMAT_FLAG_ALPHA: if set each pixel in the image will have an additional
- *    alpha value; a linear value that describes the degree the image pixel
- *    covers (overwrites) the contents of the existing pixel on the display.
+ * PNG_FORMAT_FLAG_ALPHA: if set, each pixel in the image will have an
+ *    additional alpha value; a linear value that describes the degree the
+ *    image pixel covers (overwrites) the contents of the existing pixel on the
+ *    display.
  *
- * PNG_FORMAT_FLAG_LINEAR: if set the components of each pixel will be returned
- *    as a series of 16-bit linear values, if not set the components will be
- *    returned as a series of 8-bit values encoded according to the 'sRGB'
- *    standard.  The 8-bit format is the normal format for images intended for
- *    direct display, because almost all display devices do the inverse of the
- *    sRGB transformation to the data they receive.  The 16-bit format is more
- *    common for scientific data and image data that must be further processed;
- *    because it is linear simple math can be done on the component values.
- *    Regardless of the setting of this flag the alpha channel is always linear,
- *    although it will be 8 bits or 16 bits wide as specified by the flag.
+ * PNG_FORMAT_FLAG_LINEAR: if set, the components of each pixel will be
+ *    returned as a series of 16-bit linear values; if not set, the components
+ *    will be returned as a series of 8-bit values encoded according to the
+ *    sRGB standard.  The 8-bit format is the normal format for images intended
+ *    for direct display, because almost all display devices do the inverse of
+ *    the sRGB transformation to the data they receive.  The 16-bit format is
+ *    more common for scientific data and image data that must be further
+ *    processed; because it is linear, simple math can be done on the component
+ *    values.  Regardless of the setting of this flag, the alpha channel is
+ *    always linear, although it will be 8 bits or 16 bits wide as specified by
+ *    the flag.
  *
- * PNG_FORMAT_FLAG_BGR: if set the components of a color pixel will be returned
- *    in the order blue, then green, then red.  If not set the pixel components
- *    are in the order red, then green, then blue.
+ * PNG_FORMAT_FLAG_BGR: if set, the components of a color pixel will be
+ *    returned in the order blue, then green, then red.  If not set, the pixel
+ *    components are in the order red, then green, then blue.
  *
- * PNG_FORMAT_FLAG_AFIRST: if set the alpha channel (if present) precedes the
- *    color or grayscale components.  If not set the alpha channel follows the
+ * PNG_FORMAT_FLAG_AFIRST: if set, the alpha channel (if present) precedes the
+ *    color or grayscale components.  If not set, the alpha channel follows the
  *    components.
  *
  * You do not have to read directly from a file.  You can read from memory or,
  * on systems that support it, from a <stdio.h> FILE*.  This is controlled by
- * the particular png_image_read_from_ function you call at the start.  Likewise
- * on write you can write to a FILE* if your system supports it.  Check the
- * macro PNG_STDIO_SUPPORTED to see if stdio support has been included in your
- * libpng build.
+ * the particular png_image_read_from_ function you call at the start.
+ * Likewise, on write, you can write to a FILE* if your system supports it.
+ * Check the macro PNG_STDIO_SUPPORTED to see if stdio support has been
+ * included in your libpng build.
  *
- * If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data you may need to write it in
- * the 8-bit format for display.  You do this by setting the convert_to_8bit
+ * If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data, you may need to write it
+ * in the 8-bit format for display.  You do this by setting the convert_to_8bit
  * flag to 'true'.
  *
  * Don't repeatedly convert between the 8-bit and 16-bit forms.  There is
- * significant data loss when 16-bit data is converted to the 8-bit encoding and
- * the current libpng implementation of conversion to 16-bit is also
+ * significant data loss when 16-bit data is converted to the 8-bit encoding,
+ * and the current libpng implementation of conversion to 16-bit is also
  * significantly lossy.  The latter will be fixed in the future, but the former
  * is unavoidable - the 8-bit format just doesn't have enough resolution.
  */
@@ -200,10 +202,10 @@
  * interfaces.
  *
  * All these interfaces require that you do your own error handling - your
- * program must be able to arrange for control to return to your own code any
- * time libpng encounters a problem.  There are several ways to do this, but the
- * standard way is to use the ANSI-C (C90) <setjmp.h> interface to establish a
- * return point within your own code.  You must do this if you do not use the
+ * program must be able to arrange for control to return to your own code, any
+ * time libpng encounters a problem.  There are several ways to do this, but
+ * the standard way is to use the <setjmp.h> interface to establish a return
+ * point within your own code.  You must do this if you do not use the
  * simplified interface (above).
  *
  * The first step is to include the header files you need, including the libpng
@@ -215,7 +217,7 @@
  /* The png_jmpbuf() macro, used in error handling, became available in
   * libpng version 1.0.6.  If you want to be able to run your code with older
   * versions of libpng, you must define the macro yourself (but only if it
-  * is not already defined by libpng!).
+  * is not already defined by libpng!)
   */
 
 #ifndef png_jmpbuf
@@ -223,10 +225,10 @@
 #endif
 
 /* Check to see if a file is a PNG file using png_sig_cmp().  png_sig_cmp()
- * returns zero if the image is a PNG and nonzero if it isn't a PNG.
+ * returns zero if the image is a PNG, and nonzero otherwise.
  *
  * The function check_if_png() shown here, but not used, returns nonzero (true)
- * if the file can be opened and is a PNG, 0 (false) otherwise.
+ * if the file can be opened and is a PNG, and 0 (false) otherwise.
  *
  * If this call is successful, and you are going to keep the file open,
  * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
@@ -239,7 +241,7 @@
  *
  * Many applications already read the first 2 or 4 bytes from the start
  * of the image to determine the file type, so it would be easiest just
- * to pass the bytes to png_sig_cmp() or even skip that if you know
+ * to pass the bytes to png_sig_cmp(), or even skip that if you know
  * you have a PNG file, and call png_set_sig_bytes().
  */
 #define PNG_BYTES_TO_CHECK 4
@@ -251,13 +253,13 @@
    if ((*fp = fopen(file_name, "rb")) == NULL)
       return 0;
 
-   /* Read in some of the signature bytes */
+   /* Read in some of the signature bytes. */
    if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
       return 0;
 
    /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
-      Return nonzero (true) if they match */
-
+    * Return nonzero (true) if they match.
+    */
    return(!png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK));
 }
 
@@ -268,7 +270,7 @@
  * some or all of the magic bytes read - see comments above).
  */
 #ifdef open_file /* prototype 1 */
-void read_png(char *file_name)  /* We need to open the file */
+void read_png(char *file_name) /* We need to open the file */
 {
    png_structp png_ptr;
    png_infop info_ptr;
@@ -281,7 +283,7 @@
       return (ERROR);
 
 #else no_open_file /* prototype 2 */
-void read_png(FILE *fp, int sig_read)  /* File is already open */
+void read_png(FILE *fp, int sig_read) /* File is already open */
 {
    png_structp png_ptr;
    png_infop info_ptr;
@@ -293,7 +295,7 @@
     * functions.  If you want to use the default stderr and longjump method,
     * you can supply NULL for the last three parameters.  We also supply the
     * the compiler header file version, so that we know if the application
-    * was compiled with a compatible version of the library.  REQUIRED
+    * was compiled with a compatible version of the library.  REQUIRED.
     */
    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
        png_voidp user_error_ptr, user_error_fn, user_warning_fn);
@@ -317,35 +319,33 @@
     * the normal method of doing things with libpng).  REQUIRED unless you
     * set up your own error handlers in the png_create_read_struct() earlier.
     */
-
    if (setjmp(png_jmpbuf(png_ptr)))
    {
-      /* Free all of the memory associated with the png_ptr and info_ptr */
+      /* Free all of the memory associated with the png_ptr and info_ptr. */
       png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
       fclose(fp);
-      /* If we get here, we had a problem reading the file */
+      /* If we get here, we had a problem reading the file. */
       return (ERROR);
    }
 
-   /* One of the following I/O initialization methods is REQUIRED */
+   /* One of the following I/O initialization methods is REQUIRED. */
 #ifdef streams /* PNG file I/O method 1 */
-   /* Set up the input control if you are using standard C streams */
+   /* Set up the input control if you are using standard C streams. */
    png_init_io(png_ptr, fp);
 
 #else no_streams /* PNG file I/O method 2 */
    /* If you are using replacement read functions, instead of calling
-    * png_init_io() here you would call:
+    * png_init_io(), you would call:
     */
    png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
-   /* where user_io_ptr is a structure you want available to the callbacks */
+   /* where user_io_ptr is a structure you want available to the callbacks. */
 #endif no_streams /* Use only one I/O method! */
 
    /* If we have already read some of the signature */
    png_set_sig_bytes(png_ptr, sig_read);
 
 #ifdef hilevel
-   /*
-    * If you have enough memory to read in the entire image at once,
+   /* If you have enough memory to read in the entire image at once,
     * and you need to specify only transforms that can be controlled
     * with one of the PNG_TRANSFORM_* bits (this presently excludes
     * quantizing, filling, setting background, and doing gamma
@@ -355,10 +355,10 @@
    png_read_png(png_ptr, info_ptr, png_transforms, NULL);
 
 #else
-   /* OK, you're doing it the hard way, with the lower-level functions */
+   /* OK, you're doing it the hard way, with the lower-level functions. */
 
    /* The call to png_read_info() gives us all of the information from the
-    * PNG file before the first IDAT (image data chunk).  REQUIRED
+    * PNG file before the first IDAT (image data chunk).  REQUIRED.
     */
    png_read_info(png_ptr, info_ptr);
 
@@ -386,20 +386,21 @@
     */
    png_set_strip_alpha(png_ptr);
 
-   /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
+   /* Extract multiple pixels with bit depths of 1, 2 or 4 from a single
     * byte into separate bytes (useful for paletted and grayscale images).
     */
    png_set_packing(png_ptr);
 
    /* Change the order of packed pixels to least significant bit first
-    * (not useful if you are using png_set_packing). */
+    * (not useful if you are using png_set_packing).
+    */
    png_set_packswap(png_ptr);
 
-   /* Expand paletted colors into true RGB triplets */
+   /* Expand paletted colors into true RGB triplets. */
    if (color_type == PNG_COLOR_TYPE_PALETTE)
       png_set_palette_to_rgb(png_ptr);
 
-   /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
+   /* Expand grayscale images to the full 8 bits from 1, 2 or 4 bits/pixel. */
    if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
       png_set_expand_gray_1_2_4_to_8(png_ptr);
 
@@ -410,12 +411,11 @@
       png_set_tRNS_to_alpha(png_ptr);
 
    /* Set the background color to draw transparent and alpha images over.
-    * It is possible to set the red, green, and blue components directly
-    * for paletted images instead of supplying a palette index.  Note that
+    * It is possible to set the red, green and blue components directly
+    * for paletted images, instead of supplying a palette index.  Note that,
     * even if the PNG file supplies a background, you are not required to
     * use it - you should use the (solid) application background if it has one.
     */
-
    png_color_16 my_background, *image_background;
 
    if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0)
@@ -425,32 +425,29 @@
       png_set_background(png_ptr, &my_background,
           PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
 
-   /* Some suggestions as to how to get a screen gamma value
+   /* Some suggestions as to how to get a screen gamma value.
     *
     * Note that screen gamma is the display_exponent, which includes
-    * the CRT_exponent and any correction for viewing conditions
+    * the CRT_exponent and any correction for viewing conditions.
     */
    if (/* We have a user-defined screen gamma value */)
-   {
       screen_gamma = user-defined screen_gamma;
-   }
-   /* This is one way that applications share the same screen gamma value */
+   /* This is one way that applications share the same screen gamma value. */
    else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
-   {
       screen_gamma = atof(gamma_str);
-   }
    /* If we don't have another value */
    else
    {
-      screen_gamma = PNG_DEFAULT_sRGB;  /* A good guess for a PC monitor
-                                           in a dimly lit room */
-      screen_gamma = PNG_GAMMA_MAC_18 or 1.0; /* Good guesses for Mac systems */
+      screen_gamma = PNG_DEFAULT_sRGB; /* A good guess for a PC monitor
+                                          in a dimly lit room */
+      screen_gamma = PNG_GAMMA_MAC_18 or 1.0; /* Good guesses for Mac
+                                                 systems */
    }
 
    /* Tell libpng to handle the gamma conversion for you.  The final call
     * is a good guess for PC generated images, but it should be configurable
-    * by the user at run time by the user.  It is strongly suggested that
-    * your application support gamma correction.
+    * by the user at run time.  Gamma correction support in your application
+    * is strongly recommended.
     */
 
    int intent;
@@ -467,7 +464,7 @@
    }
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
-   /* Quantize RGB files down to 8-bit palette or reduce palettes
+   /* Quantize RGB files down to 8-bit palette, or reduce palettes
     * to the number of colors available on your screen.
     */
    if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
@@ -475,29 +472,26 @@
       int num_palette;
       png_colorp palette;
 
-      /* This reduces the image to the application supplied palette */
+      /* This reduces the image to the application-supplied palette. */
       if (/* We have our own palette */)
       {
-         /* An array of colors to which the image should be quantized */
+         /* An array of colors to which the image should be quantized. */
          png_color std_color_cube[MAX_SCREEN_COLORS];
-
          png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
              MAX_SCREEN_COLORS, NULL, 0);
       }
-      /* This reduces the image to the palette supplied in the file */
+      /* This reduces the image to the palette supplied in the file. */
       else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0)
       {
          png_uint_16p histogram = NULL;
-
          png_get_hIST(png_ptr, info_ptr, &histogram);
-
          png_set_quantize(png_ptr, palette, num_palette,
              max_screen_colors, histogram, 0);
       }
    }
 #endif /* READ_QUANTIZE */
 
-   /* Invert monochrome files to have 0 as white and 1 as black */
+   /* Invert monochrome files to have 0 as white and 1 as black. */
    png_set_invert_mono(png_ptr);
 
    /* If you want to shift the pixel values from the range [0,255] or
@@ -507,22 +501,21 @@
    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT) != 0)
    {
       png_color_8p sig_bit_p;
-
       png_get_sBIT(png_ptr, info_ptr, &sig_bit_p);
       png_set_shift(png_ptr, sig_bit_p);
    }
 
-   /* Flip the RGB pixels to BGR (or RGBA to BGRA) */
+   /* Flip the RGB pixels to BGR (or RGBA to BGRA). */
    if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
       png_set_bgr(png_ptr);
 
-   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
+   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR). */
    png_set_swap_alpha(png_ptr);
 
-   /* Swap bytes of 16-bit files to least significant byte first */
+   /* Swap bytes of 16-bit files to least significant byte first. */
    png_set_swap(png_ptr);
 
-   /* Add filler (or alpha) byte (before/after each RGB triplet) */
+   /* Add filler (or alpha) byte (before/after each RGB triplet). */
    png_set_filler(png_ptr, 0xffff, PNG_FILLER_AFTER);
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
@@ -535,40 +528,31 @@
    number_passes = 1;
 #endif /* READ_INTERLACING */
 
-
    /* Optional call to gamma correct and add the background to the palette
     * and update info structure.  REQUIRED if you are expecting libpng to
-    * update the palette for you (ie you selected such a transform above).
+    * update the palette for you (i.e. you selected such a transform above).
     */
    png_read_update_info(png_ptr, info_ptr);
 
    /* Allocate the memory to hold the image using the fields of info_ptr. */
-
-   /* The easiest way to read the image: */
    png_bytep row_pointers[height];
-
-   /* Clear the pointer array */
    for (row = 0; row < height; row++)
-      row_pointers[row] = NULL;
-
+      row_pointers[row] = NULL; /* Clear the pointer array */
    for (row = 0; row < height; row++)
       row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
           info_ptr));
 
-   /* Now it's time to read the image.  One of these methods is REQUIRED */
+   /* Now it's time to read the image.  One of these methods is REQUIRED. */
 #ifdef entire /* Read the entire image in one go */
    png_read_image(png_ptr, row_pointers);
 
 #else no_entire /* Read the image one or more scanlines at a time */
    /* The other way to read images - deal with interlacing: */
-
    for (pass = 0; pass < number_passes; pass++)
    {
 #ifdef single /* Read the image a single row at a time */
       for (y = 0; y < height; y++)
-      {
          png_read_rows(png_ptr, &row_pointers[y], NULL, 1);
-      }
 
 #else no_single /* Read the image several rows at a time */
       for (y = 0; y < height; y += number_of_rows)
@@ -582,24 +566,24 @@
 #endif no_sparkle /* Use only one of these two methods */
       }
 
-      /* If you want to display the image after every pass, do so here */
+      /* If you want to display the image after every pass, do so here. */
 #endif no_single /* Use only one of these two methods */
    }
 #endif no_entire /* Use only one of these two methods */
 
-   /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
+   /* Read rest of file, and get additional chunks in info_ptr.  REQUIRED. */
    png_read_end(png_ptr, info_ptr);
 #endif hilevel
 
-   /* At this point you have read the entire image */
+   /* At this point you have read the entire image. */
 
-   /* Clean up after the read, and free any memory allocated - REQUIRED */
+   /* Clean up after the read, and free any memory allocated.  REQUIRED. */
    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
 
-   /* Close the file */
+   /* Close the file. */
    fclose(fp);
 
-   /* That's it */
+   /* That's it! */
    return (OK);
 }
 
@@ -611,34 +595,30 @@
    /* Create and initialize the png_struct with the desired error handler
     * functions.  If you want to use the default stderr and longjump method,
     * you can supply NULL for the last three parameters.  We also check that
-    * the library version is compatible in case we are using dynamically
+    * the library version is compatible, in case we are using dynamically
     * linked libraries.
     */
    *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
         png_voidp user_error_ptr, user_error_fn, user_warning_fn);
-
    if (*png_ptr == NULL)
    {
       *info_ptr = NULL;
       return (ERROR);
    }
-
    *info_ptr = png_create_info_struct(png_ptr);
-
    if (*info_ptr == NULL)
    {
       png_destroy_read_struct(png_ptr, info_ptr, NULL);
       return (ERROR);
    }
-
    if (setjmp(png_jmpbuf((*png_ptr))))
    {
       png_destroy_read_struct(png_ptr, info_ptr, NULL);
       return (ERROR);
    }
 
-   /* This one's new.  You will need to provide all three
-    * function callbacks, even if you aren't using them all.
+   /* You will need to provide all three function callbacks,
+    * even if you aren't using all of them.
     * If you aren't using all functions, you can specify NULL
     * parameters.  Even when all three functions are NULL,
     * you need to call png_set_progressive_read_fn().
@@ -651,7 +631,6 @@
     */
    png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
        info_callback, row_callback, end_callback);
-
    return (OK);
 }
 
@@ -661,18 +640,18 @@
 {
    if (setjmp(png_jmpbuf((*png_ptr))))
    {
-      /* Free the png_ptr and info_ptr memory on error */
+      /* Free the png_ptr and info_ptr memory on error. */
       png_destroy_read_struct(png_ptr, info_ptr, NULL);
       return (ERROR);
    }
 
-   /* This one's new also.  Simply give it chunks of data as
-    * they arrive from the data stream (in order, of course).
+   /* Give chunks of data as they arrive from the data stream
+    * (in order, of course).
     * On segmented machines, don't give it any more than 64K.
     * The library seems to run fine with sizes of 4K, although
-    * you can give it much less if necessary (I assume you can
+    * you can give it much less if necessary. (I assume you can
     * give it chunks of 1 byte, but I haven't tried with less
-    * than 256 bytes yet).  When this function returns, you may
+    * than 256 bytes yet.)  When this function returns, you may
     * want to display any rows that were generated in the row
     * callback, if you aren't already displaying them there.
     */
@@ -694,8 +673,7 @@
 row_callback(png_structp png_ptr, png_bytep new_row,
     png_uint_32 row_num, int pass)
 {
-   /*
-    * This function is called for every row in the image.  If the
+   /* This function is called for every row in the image.  If the
     * image is interlaced, and you turned on the interlace handler,
     * this function will be called for every row in every pass.
     *
@@ -706,25 +684,22 @@
     * The new row data pointer "new_row" may be NULL, indicating there is
     * no new data to be replaced (in cases of interlace loading).
     *
-    * If new_row is not NULL then you need to call
-    * png_progressive_combine_row() to replace the corresponding row as
+    * If new_row is not NULL, then you need to call
+    * png_progressive_combine_row(), to replace the corresponding row as
     * shown below:
     */
 
-   /* Get pointer to corresponding row in our
-    * PNG read buffer.
-    */
+   /* Get pointer to corresponding row in our PNG read buffer. */
    png_bytep old_row = ((png_bytep *)our_data)[row_num];
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
-   /* If both rows are allocated then copy the new row
+   /* If both rows are allocated, then copy the new row
     * data to the corresponding row data.
     */
-   if ((old_row != NULL) && (new_row != NULL))
-   png_progressive_combine_row(png_ptr, old_row, new_row);
+   if (old_row != NULL && new_row != NULL)
+      png_progressive_combine_row(png_ptr, old_row, new_row);
 
-   /*
-    * The rows and passes are called in order, so you don't really
+   /* The rows and passes are called in order, so you don't really
     * need the row_num and pass, but I'm supplying them because it
     * may make your life easier.
     *
@@ -735,7 +710,6 @@
     * (it just does the memcpy for you) if it will make the code
     * easier.  Thus, you can just do this for all cases:
     */
-
    png_progressive_combine_row(png_ptr, old_row, new_row);
 
    /* where old_row is what was displayed for previous rows.  Note
@@ -782,14 +756,13 @@
     */
    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
        png_voidp user_error_ptr, user_error_fn, user_warning_fn);
-
    if (png_ptr == NULL)
    {
       fclose(fp);
       return (ERROR);
    }
 
-   /* Allocate/initialize the image information data.  REQUIRED */
+   /* Allocate/initialize the image information data.  REQUIRED. */
    info_ptr = png_create_info_struct(png_ptr);
    if (info_ptr == NULL)
    {
@@ -798,30 +771,30 @@
       return (ERROR);
    }
 
-   /* Set error handling.  REQUIRED if you aren't supplying your own
+   /* Set up error handling.  REQUIRED if you aren't supplying your own
     * error handling functions in the png_create_write_struct() call.
     */
    if (setjmp(png_jmpbuf(png_ptr)))
    {
-      /* If we get here, we had a problem writing the file */
+      /* If we get here, we had a problem writing the file. */
       fclose(fp);
       png_destroy_write_struct(&png_ptr, &info_ptr);
       return (ERROR);
    }
 
-   /* One of the following I/O initialization functions is REQUIRED */
+   /* One of the following I/O initialization functions is REQUIRED. */
 
 #ifdef streams /* I/O initialization method 1 */
-   /* Set up the output control if you are using standard C streams */
+   /* Set up the output control if you are using standard C streams. */
    png_init_io(png_ptr, fp);
 
 #else no_streams /* I/O initialization method 2 */
    /* If you are using replacement write functions, instead of calling
-    * png_init_io() here you would call
+    * png_init_io(), you would call:
     */
    png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
        user_IO_flush_function);
-   /* where user_io_ptr is a structure you want available to the callbacks */
+   /* where user_io_ptr is a structure you want available to the callbacks. */
 #endif no_streams /* Only use one initialization method */
 
 #ifdef hilevel
@@ -832,30 +805,32 @@
    png_write_png(png_ptr, info_ptr, png_transforms, NULL);
 
 #else
-   /* This is the hard way */
+   /* This is the hard way. */
 
    /* Set the image information here.  Width and height are up to 2^31,
-    * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
-    * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
+    * bit_depth is one of 1, 2, 4, 8 or 16, but valid values also depend on
+    * the color_type selected.  color_type is one of PNG_COLOR_TYPE_GRAY,
     * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
     * or PNG_COLOR_TYPE_RGB_ALPHA.  interlace is either PNG_INTERLACE_NONE or
     * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
-    * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
+    * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
+    * REQUIRED.
     */
-   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
-       PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
+       PNG_COLOR_TYPE_???, PNG_INTERLACE_????,
+       PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
 
-   /* Set the palette if there is one.  REQUIRED for indexed-color images */
-   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
-             * (sizeof (png_color)));
+   /* Set the palette if there is one.  REQUIRED for indexed-color images. */
+   palette = (png_colorp)png_malloc(png_ptr,
+       PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)));
    /* ... Set palette colors ... */
    png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
-   /* You must not free palette here, because png_set_PLTE only makes a link to
-    * the palette that you malloced.  Wait until you are about to destroy
+   /* You must not free palette here, because png_set_PLTE only makes a link
+    * to the palette that you allocated.  Wait until you are about to destroy
     * the png structure.
     */
 
-   /* Optional significant bit (sBIT) chunk */
+   /* Optional significant bit (sBIT) chunk. */
    png_color_8 sig_bit;
 
    /* If we are dealing with a grayscale image then */
@@ -871,18 +846,17 @@
 
    png_set_sBIT(png_ptr, info_ptr, &sig_bit);
 
-
    /* Optional gamma chunk is strongly suggested if you have any guess
     * as to the correct gamma of the image.
     */
    png_set_gAMA(png_ptr, info_ptr, gamma);
 
-   /* Optionally write comments into the image */
+   /* Optionally write comments into the image. */
    {
       png_text text_ptr[3];
 
-      char key0[]="Title";
-      char text0[]="Mona Lisa";
+      char key0[] = "Title";
+      char text0[] = "Mona Lisa";
       text_ptr[0].key = key0;
       text_ptr[0].text = text0;
       text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
@@ -890,8 +864,8 @@
       text_ptr[0].lang = NULL;
       text_ptr[0].lang_key = NULL;
 
-      char key1[]="Author";
-      char text1[]="Leonardo DaVinci";
+      char key1[] = "Author";
+      char text1[] = "Leonardo DaVinci";
       text_ptr[1].key = key1;
       text_ptr[1].text = text1;
       text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
@@ -899,8 +873,8 @@
       text_ptr[1].lang = NULL;
       text_ptr[1].lang_key = NULL;
 
-      char key2[]="Description";
-      char text2[]="<long text>";
+      char key2[] = "Description";
+      char text2[] = "<long text>";
       text_ptr[2].key = key2;
       text_ptr[2].text = text2;
       text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
@@ -911,14 +885,14 @@
       png_set_text(write_ptr, write_info_ptr, text_ptr, 3);
    }
 
-   /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
+   /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs. */
 
-   /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored
+   /* Note that if sRGB is present, the gAMA and cHRM chunks must be ignored
     * on read and, if your application chooses to write them, they must
-    * be written in accordance with the sRGB profile
+    * be written in accordance with the sRGB profile.
     */
 
-   /* Write the file header information.  REQUIRED */
+   /* Write the file header information.  REQUIRED. */
    png_write_info(png_ptr, info_ptr);
 
    /* If you want, you can write the info in two steps, in case you need to
@@ -942,7 +916,7 @@
     * all optional.  Only call them if you want them.
     */
 
-   /* Invert monochrome pixels */
+   /* Invert monochrome pixels. */
    png_set_invert_mono(png_ptr);
 
    /* Shift the pixels up to a legal bit depth and fill in
@@ -950,30 +924,29 @@
     */
    png_set_shift(png_ptr, &sig_bit);
 
-   /* Pack pixels into bytes */
+   /* Pack pixels into bytes. */
    png_set_packing(png_ptr);
 
-   /* Swap location of alpha bytes from ARGB to RGBA */
+   /* Swap location of alpha bytes from ARGB to RGBA. */
    png_set_swap_alpha(png_ptr);
 
    /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
-    * RGB (4 channels -> 3 channels). The second parameter is not used.
+    * RGB (4 channels -> 3 channels).  The second parameter is not used.
     */
    png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
 
-   /* Flip BGR pixels to RGB */
+   /* Flip BGR pixels to RGB. */
    png_set_bgr(png_ptr);
 
-   /* Swap bytes of 16-bit files to most significant byte first */
+   /* Swap bytes of 16-bit files to most significant byte first. */
    png_set_swap(png_ptr);
 
-   /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */
+   /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats. */
    png_set_packswap(png_ptr);
 
-   /* Turn on interlace handling if you are not using png_write_image() */
+   /* Turn on interlace handling if you are not using png_write_image(). */
    if (interlacing != 0)
       number_passes = png_set_interlace_handling(png_ptr);
-
    else
       number_passes = 1;
 
@@ -983,29 +956,28 @@
     */
    png_uint_32 k, height, width;
 
-   /* In this example, "image" is a one-dimensional array of bytes */
+   /* In this example, "image" is a one-dimensional array of bytes. */
 
-   /* Guard against integer overflow */
-   if (height > PNG_SIZE_MAX/(width*bytes_per_pixel)) {
-      png_error(png_ptr, "Image_data buffer would be too large");
-   }
-   png_byte image[height*width*bytes_per_pixel];
+   /* Guard against integer overflow. */
+   if (height > PNG_SIZE_MAX / (width * bytes_per_pixel))
+      png_error(png_ptr, "Image data buffer would be too large");
 
+   png_byte image[height * width * bytes_per_pixel];
    png_bytep row_pointers[height];
 
-   if (height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
-      png_error (png_ptr, "Image is too tall to process in memory");
+   if (height > PNG_UINT_32_MAX / (sizeof (png_bytep)))
+      png_error(png_ptr, "Image is too tall to process in memory");
 
-   /* Set up pointers into your "image" byte array */
+   /* Set up pointers into your "image" byte array. */
    for (k = 0; k < height; k++)
-      row_pointers[k] = image + k*width*bytes_per_pixel;
+      row_pointers[k] = image + k * width * bytes_per_pixel;
 
-   /* One of the following output methods is REQUIRED */
+   /* One of the following output methods is REQUIRED. */
 
 #ifdef entire /* Write out the entire image data in one call */
    png_write_image(png_ptr, row_pointers);
 
-   /* The other way to write the image - deal with interlacing */
+   /* The other way to write the image - deal with interlacing. */
 
 #else no_entire /* Write out the image data by one or more scanlines */
 
@@ -1017,27 +989,27 @@
       /* Write a few rows at a time. */
       png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
 
-      /* If you are only writing one row at a time, this works */
+      /* If you are only writing one row at a time, this works. */
       for (y = 0; y < height; y++)
          png_write_rows(png_ptr, &row_pointers[y], 1);
    }
 #endif no_entire /* Use only one output method */
 
    /* You can write optional chunks like tEXt, zTXt, and tIME at the end
-    * as well.  Shouldn't be necessary in 1.2.0 and up as all the public
-    * chunks are supported and you can use png_set_unknown_chunks() to
+    * as well.  Shouldn't be necessary in 1.2.0 and up, as all the public
+    * chunks are supported, and you can use png_set_unknown_chunks() to
     * register unknown chunks into the info structure to be written out.
     */
 
-   /* It is REQUIRED to call this to finish writing the rest of the file */
+   /* It is REQUIRED to call this to finish writing the rest of the file. */
    png_write_end(png_ptr, info_ptr);
 #endif hilevel
 
-   /* If you png_malloced a palette, free it here (don't free info_ptr->palette,
-    * as recommended in versions 1.0.5m and earlier of this example; if
-    * libpng mallocs info_ptr->palette, libpng will free it).  If you
-    * allocated it with malloc() instead of png_malloc(), use free() instead
-    * of png_free().
+   /* If you png_malloced a palette, free it here.
+    * (Don't free info_ptr->palette, as shown in versions 1.0.5m and earlier of
+    * this example; if libpng mallocs info_ptr->palette, libpng will free it).
+    * If you allocated it with malloc() instead of png_malloc(), use free()
+    * instead of png_free().
     */
    png_free(png_ptr, palette);
    palette = NULL;
@@ -1048,19 +1020,20 @@
     */
    png_free(png_ptr, trans);
    trans = NULL;
-   /* Whenever you use png_free() it is a good idea to set the pointer to
+
+   /* Whenever you use png_free(), it is a good idea to set the pointer to
     * NULL in case your application inadvertently tries to png_free() it
-    * again.  When png_free() sees a NULL it returns without action, thus
-    * avoiding the double-free security problem.
+    * again.  When png_free() sees a NULL it returns without action, avoiding
+    * the double-free problem.
     */
 
-   /* Clean up after the write, and free any memory allocated */
+   /* Clean up after the write, and free any allocated memory. */
    png_destroy_write_struct(&png_ptr, &info_ptr);
 
-   /* Close the file */
+   /* Close the file. */
    fclose(fp);
 
-   /* That's it */
+   /* That's it! */
    return (OK);
 }
 
diff --git a/intel/filter_sse2_intrinsics.c b/intel/filter_sse2_intrinsics.c
index ef1fc7d..f52aaa8 100644
--- a/intel/filter_sse2_intrinsics.c
+++ b/intel/filter_sse2_intrinsics.c
@@ -1,12 +1,11 @@
 
 /* filter_sse2_intrinsics.c - SSE2 optimized filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2016-2017 Glenn Randers-Pehrson
  * Written by Mike Klein and Matt Sarett
  * Derived from arm/filter_neon_intrinsics.c
  *
- * Last changed in libpng 1.6.31 [July 27, 2017]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
@@ -29,39 +28,25 @@
  */
 
 static __m128i load4(const void* p) {
-   return _mm_cvtsi32_si128(*(const int*)p);
+   int tmp;
+   memcpy(&tmp, p, sizeof(tmp));
+   return _mm_cvtsi32_si128(tmp);
 }
 
 static void store4(void* p, __m128i v) {
-   *(int*)p = _mm_cvtsi128_si32(v);
+   int tmp = _mm_cvtsi128_si32(v);
+   memcpy(p, &tmp, sizeof(int));
 }
 
 static __m128i load3(const void* p) {
-   /* We'll load 2 bytes, then 1 byte,
-    * then mask them together, and finally load into SSE.
-    */
-   const png_uint_16* p01 = (png_const_uint_16p)p;
-   const png_byte*    p2  = (const png_byte*)(p01+1);
-
-   png_uint_32 v012 = (png_uint_32)(*p01)
-                    | (png_uint_32)(*p2) << 16;
-   return load4(&v012);
+   png_uint_32 tmp = 0;
+   memcpy(&tmp, p, 3);
+   return _mm_cvtsi32_si128(tmp);
 }
 
 static void store3(void* p, __m128i v) {
-   /* We'll pull from SSE as a 32-bit int, then write
-    * its bottom two bytes, then its third byte.
-    */
-   png_uint_32 v012;
-   png_uint_16* p01;
-   png_byte*    p2;
-
-   store4(&v012, v);
-
-   p01 = (png_uint_16p)p;
-   p2  = (png_byte*)(p01+1);
-   *p01 = (png_uint_16)v012;
-   *p2  = (png_byte)(v012 >> 16);
+   int tmp = _mm_cvtsi128_si32(v);
+   memcpy(p, &tmp, 3);
 }
 
 void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
diff --git a/intel/intel_init.c b/intel/intel_init.c
index 8f08baf..2f8168b 100644
--- a/intel/intel_init.c
+++ b/intel/intel_init.c
@@ -1,12 +1,11 @@
 
 /* intel_init.c - SSE2 optimized filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2016-2017 Glenn Randers-Pehrson
  * Written by Mike Klein and Matt Sarett, Google, Inc.
  * Derived from arm/arm_init.c
  *
- * Last changed in libpng 1.6.29 [March 16, 2017]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
diff --git a/libpng-manual.txt b/libpng-manual.txt
index b14a534..19cfed2 100644
--- a/libpng-manual.txt
+++ b/libpng-manual.txt
@@ -1,7 +1,6 @@
 libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.6.35 - July 15, 2018
- Updated and distributed by Glenn Randers-Pehrson
+ Copyright (c) 2018 Cosmin Truta
  Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
  This document is released under the libpng license.
@@ -10,9 +9,13 @@
 
  Based on:
 
+ libpng version 1.6.36 - December 1, 2018
+ Updated and distributed by Cosmin Truta
+ Copyright (c) 2018 Cosmin Truta
+
  libpng versions 0.97, January 1998, through 1.6.35 - July 15, 2018
  Updated and distributed by Glenn Randers-Pehrson
- Copyright (c) 1998-2017 Glenn Randers-Pehrson
+ Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
  libpng 1.0 beta 6 - version 0.96 - May 28, 1997
  Updated and distributed by Andreas Dilger
@@ -44,7 +47,6 @@
  XIII. Detecting libpng
   XIV. Source code repository
    XV. Coding style
-  XVI. Y2K Compliance in libpng
 
 I. Introduction
 
@@ -65,7 +67,7 @@
 
 The PNG specification (second edition), November 2003, is available as
 a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
-<https://www.w3.org/TR/2003/REC-PNG-20031110/
+<https://www.w3.org/TR/2003/REC-PNG-20031110/>.
 The W3C and ISO documents have identical technical content.
 
 The PNG-1.2 specification is available at
@@ -73,9 +75,9 @@
 It is technically equivalent
 to the PNG specification (second edition) but has some additional material.
 
-The PNG-1.0 specification is available as RFC 2083
+The PNG-1.0 specification is available as RFC 2083 at
 <https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
-W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
+W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
 
 Some additional chunks are described in the special-purpose public chunks
 documents at <http://www.libpng.org/pub/png/spec/register/>
@@ -4054,7 +4056,7 @@
 the 'flags' field of png_image.
 
   PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
-    This indicates the the RGB values of the in-memory bitmap do not
+    This indicates that the RGB values of the in-memory bitmap do not
     correspond to the red, green and blue end-points defined by sRGB.
 
   PNG_IMAGE_FLAG_FAST == 0x02
@@ -4520,7 +4522,7 @@
 having level = 0 will be printed.  There aren't any such statements in
 this version of libpng, but if you insert some they will be printed.
 
-VII.  MNG support
+VII. MNG support
 
 The MNG specification (available at http://www.libpng.org/pub/mng) allows
 certain extensions to PNG for PNG images that are embedded in MNG datastreams.
@@ -4547,7 +4549,7 @@
 them.  You may wish to consider using libmng (available at
 https://www.libmng.com/) instead.
 
-VIII.  Changes to Libpng from version 0.88
+VIII. Changes to Libpng from version 0.88
 
 It should be noted that versions of libpng later than 0.96 are not
 distributed by the original libpng author, Guy Schalnat, nor by
@@ -4602,7 +4604,7 @@
 
    png_uint_32 application_vn = PNG_LIBPNG_VER;
 
-IX.  Changes to Libpng from version 1.0.x to 1.2.x
+IX. Changes to Libpng from version 1.0.x to 1.2.x
 
 Support for user memory management was enabled by default.  To
 accomplish this, the functions png_create_read_struct_2(),
@@ -4699,7 +4701,7 @@
     png_set_expand_gray_1_2_4_to_8()
 which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
 
-X.  Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
+X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
 
 Private libpng prototypes and macro definitions were moved from
 png.h and pngconf.h into a new pngpriv.h header file.
@@ -4809,7 +4811,7 @@
 
 We removed the trailing '.' from the warning and error messages.
 
-XI.  Changes to Libpng from version 1.4.x to 1.5.x
+XI. Changes to Libpng from version 1.4.x to 1.5.x
 
 From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
 function) incorrectly returned a value of type png_uint_32.
@@ -4872,7 +4874,7 @@
 There are changes of form in png.h, including new and changed macros to
 declare parts of the API.  Some API functions with arguments that are
 pointers to data not modified within the function have been corrected to
-declare these arguments with PNG_CONST.
+declare these arguments with const.
 
 Much of the internal use of C macros to control the library build has also
 changed and some of this is visible in the exported header files, in
@@ -5067,7 +5069,7 @@
 to choose at app buildtime whether or not to use macros (previously
 impossible because the functions weren't in the default build.)
 
-XII.  Changes to Libpng from version 1.5.x to 1.6.x
+XII. Changes to Libpng from version 1.5.x to 1.6.x
 
 A "simplified API" has been added (see documentation in png.h and a simple
 example in contrib/examples/pngtopng.c).  The new publicly visible API
@@ -5230,7 +5232,7 @@
 containing the profile to the calling application which must do its own
 decoding.
 
-XIII.  Detecting libpng
+XIII. Detecting libpng
 
 The png_get_io_ptr() function has been present since libpng-0.88, has never
 changed, and is unaffected by conditional compilation macros.  It is the
@@ -5255,7 +5257,7 @@
     https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
 
 Patches can be sent to png-mng-implement at lists.sourceforge.net or
-you can upload them to the libpng bug tracker at
+uploaded to the libpng bug tracker at
 
     https://libpng.sourceforge.io/
 
@@ -5405,58 +5407,3 @@
 Lines do not exceed 80 characters.
 
 Other rules can be inferred by inspecting the libpng source.
-
-XVI. Y2K Compliance in libpng
-
-Since the PNG Development group is an ad-hoc body, we can't make
-an official declaration.
-
-This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.6.35 are Y2K compliant.  It is my belief that earlier
-versions were also Y2K compliant.
-
-Libpng only has two year fields.  One is a 2-byte unsigned integer
-that will hold years up to 65535.  The other, which is deprecated,
-holds the date in text format, and will hold years up to 9999.
-
-The integer is
-    "png_uint_16 year" in png_time_struct.
-
-The string is
-    "char time_buffer[29]" in png_struct.  This is no longer used
-in libpng-1.6.x and will be removed from libpng-1.7.0.
-
-There are seven time-related functions:
-
-    png_convert_to_rfc_1123_buffer() in png.c
-      (formerly png_convert_to_rfc_1152() in error, and
-      also formerly png_convert_to_rfc_1123())
-    png_convert_from_struct_tm() in pngwrite.c, called
-      in pngwrite.c
-    png_convert_from_time_t() in pngwrite.c
-    png_get_tIME() in pngget.c
-    png_handle_tIME() in pngrutil.c, called in pngread.c
-    png_set_tIME() in pngset.c
-    png_write_tIME() in pngwutil.c, called in pngwrite.c
-
-All appear to handle dates properly in a Y2K environment.  The
-png_convert_from_time_t() function calls gmtime() to convert from system
-clock time, which returns (year - 1900), which we properly convert to
-the full 4-digit year.  There is a possibility that applications using
-libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
-function, or that they are incorrectly passing only a 2-digit year
-instead of "year - 1900" into the png_convert_from_struct_tm() function,
-but this is not under our control.  The libpng documentation has always
-stated that it works with 4-digit years, and the APIs have been
-documented as such.
-
-The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
-integer to hold the year, and can hold years as large as 65535.
-
-zlib, upon which libpng depends, is also Y2K compliant.  It contains
-no date-related code.
-
-
-   Glenn Randers-Pehrson
-   libpng maintainer
-   PNG Development Group
diff --git a/libpng.3 b/libpng.3
index 01cd905..9757deb 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,11 +1,11 @@
-.TH LIBPNG 3 "July 15, 2018"
+.TH LIBPNG 3 "December 1, 2018"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
-.SH SYNOPSIS
-\fB
-#include <png.h>\fP
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.36
 
-\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
+.SH SYNOPSIS
+\fB#include <png.h>\fP
+
+\fBpng_uint_32 png_access_version_number (void);\fP
 
 \fBvoid png_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
 
@@ -35,7 +35,7 @@
 
 \fBpng_structp png_create_write_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
 
-\fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask)\fP\fB);\fP
+\fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask\fP\fB);\fP
 
 \fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
 
@@ -233,9 +233,9 @@
 
 \fBint png_image_write_to_file (png_imagep \fP\fIimage\fP\fB, const char \fP\fI*file\fP\fB, int \fP\fIconvert_to_8bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, void \fI*colormap\fP\fB);\fP
 
-\fBint png_image_write_to_memory (png_imagep \fP\fIimage\fP\fB, void \fP\fI*memory\fP\fB, png_alloc_size_t * PNG_RESTRICT \fP\fImemory_bytes\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, const void \fI*colormap)\fP\fB);\fP
+\fBint png_image_write_to_memory (png_imagep \fP\fIimage\fP\fB, void \fP\fI*memory\fP\fB, png_alloc_size_t * PNG_RESTRICT \fP\fImemory_bytes\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, const void \fI*colormap\fP\fB);\fP
 
-\fBint png_image_write_to_stdio (png_imagep \fP\fIimage\fP\fB, FILE \fP\fI*file\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, void \fI*colormap)\fP\fB);\fP
+\fBint png_image_write_to_stdio (png_imagep \fP\fIimage\fP\fB, FILE \fP\fI*file\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, void \fI*colormap\fP\fB);\fP
 
 \fBvoid png_info_init_3 (png_infopp \fP\fIinfo_ptr\fP\fB, size_t \fIpng_info_struct_size\fP\fB);\fP
 
@@ -253,9 +253,9 @@
 
 \fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, size_t \fIbuffer_size\fP\fB);\fP
 
-\fBsize_t png_process_data_pause \fP\fI(png_structp\fP\fB, int \fIsave\fP\fB);\fP
+\fBsize_t png_process_data_pause (png_structp \fP\fIpng_ptr\fP\fB, int \fIsave\fP\fB);\fP
 
-\fBpng_uint_32 png_process_data_skip \fI(png_structp\fP\fB);\fP
+\fBpng_uint_32 png_process_data_skip (png_structp \fP\fIpng_ptr\fP\fB);\fP
 
 \fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP
 
@@ -297,7 +297,7 @@
 
 \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP
 
-\fBvoid png_set_check_for_invalid_index(png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
+\fBvoid png_set_check_for_invalid_index (png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
 
 \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
 
@@ -353,7 +353,7 @@
 
 \fBvoid png_set_eXIf (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fIexif\fP\fB);\fP
 
-\fBvoid png_set_eXIf_1 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, const png_uint_32 \fP\fInum_exif\fP\fB, png_bytep \fIexif\fP\fB);\fP
+\fBvoid png_set_eXIf_1 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fInum_exif\fP\fB, png_bytep \fIexif\fP\fB);\fP
 
 \fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP
 
@@ -453,7 +453,7 @@
 
 \fBvoid png_set_text_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
 
-\fBvoid \fP\fIpng_set_text_compression_method\fP\fB, (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod)\fP\fB);\fP
+\fBvoid png_set_text_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
 
 \fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
 
@@ -515,11 +515,11 @@
 .IR zlib(3)
 compression library.
 Following is a copy of the libpng-manual.txt file that accompanies libpng.
+
 .SH LIBPNG.TXT
 libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.6.35 - July 15, 2018
- Updated and distributed by Glenn Randers-Pehrson
+ Copyright (c) 2018 Cosmin Truta
  Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
  This document is released under the libpng license.
@@ -528,9 +528,13 @@
 
  Based on:
 
+ libpng version 1.6.36 - December 1, 2018
+ Updated and distributed by Cosmin Truta
+ Copyright (c) 2018 Cosmin Truta
+
  libpng versions 0.97, January 1998, through 1.6.35 - July 15, 2018
  Updated and distributed by Glenn Randers-Pehrson
- Copyright (c) 1998-2017 Glenn Randers-Pehrson
+ Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
  libpng 1.0 beta 6 - version 0.96 - May 28, 1997
  Updated and distributed by Andreas Dilger
@@ -562,7 +566,6 @@
  XIII. Detecting libpng
   XIV. Source code repository
    XV. Coding style
-  XVI. Y2K Compliance in libpng
 
 .SH I. Introduction
 
@@ -583,7 +586,7 @@
 
 The PNG specification (second edition), November 2003, is available as
 a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
-<https://www.w3.org/TR/2003/REC-PNG-20031110/
+<https://www.w3.org/TR/2003/REC-PNG-20031110/>.
 The W3C and ISO documents have identical technical content.
 
 The PNG-1.2 specification is available at
@@ -591,9 +594,9 @@
 It is technically equivalent
 to the PNG specification (second edition) but has some additional material.
 
-The PNG-1.0 specification is available as RFC 2083
+The PNG-1.0 specification is available as RFC 2083 at
 <https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
-W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
+W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
 
 Some additional chunks are described in the special-purpose public chunks
 documents at <http://www.libpng.org/pub/png/spec/register/>
@@ -4572,7 +4575,7 @@
 the 'flags' field of png_image.
 
   PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
-    This indicates the the RGB values of the in-memory bitmap do not
+    This indicates that the RGB values of the in-memory bitmap do not
     correspond to the red, green and blue end-points defined by sRGB.
 
   PNG_IMAGE_FLAG_FAST == 0x02
@@ -5038,7 +5041,7 @@
 having level = 0 will be printed.  There aren't any such statements in
 this version of libpng, but if you insert some they will be printed.
 
-.SH VII.  MNG support
+.SH VII. MNG support
 
 The MNG specification (available at http://www.libpng.org/pub/mng) allows
 certain extensions to PNG for PNG images that are embedded in MNG datastreams.
@@ -5065,7 +5068,7 @@
 them.  You may wish to consider using libmng (available at
 https://www.libmng.com/) instead.
 
-.SH VIII.  Changes to Libpng from version 0.88
+.SH VIII. Changes to Libpng from version 0.88
 
 It should be noted that versions of libpng later than 0.96 are not
 distributed by the original libpng author, Guy Schalnat, nor by
@@ -5120,7 +5123,7 @@
 
    png_uint_32 application_vn = PNG_LIBPNG_VER;
 
-.SH IX.  Changes to Libpng from version 1.0.x to 1.2.x
+.SH IX. Changes to Libpng from version 1.0.x to 1.2.x
 
 Support for user memory management was enabled by default.  To
 accomplish this, the functions png_create_read_struct_2(),
@@ -5217,7 +5220,7 @@
     png_set_expand_gray_1_2_4_to_8()
 which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
 
-.SH X.  Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
+.SH X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
 
 Private libpng prototypes and macro definitions were moved from
 png.h and pngconf.h into a new pngpriv.h header file.
@@ -5327,7 +5330,7 @@
 
 We removed the trailing '.' from the warning and error messages.
 
-.SH XI.  Changes to Libpng from version 1.4.x to 1.5.x
+.SH XI. Changes to Libpng from version 1.4.x to 1.5.x
 
 From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
 function) incorrectly returned a value of type png_uint_32.
@@ -5390,7 +5393,7 @@
 There are changes of form in png.h, including new and changed macros to
 declare parts of the API.  Some API functions with arguments that are
 pointers to data not modified within the function have been corrected to
-declare these arguments with PNG_CONST.
+declare these arguments with const.
 
 Much of the internal use of C macros to control the library build has also
 changed and some of this is visible in the exported header files, in
@@ -5585,7 +5588,7 @@
 to choose at app buildtime whether or not to use macros (previously
 impossible because the functions weren't in the default build.)
 
-.SH XII.  Changes to Libpng from version 1.5.x to 1.6.x
+.SH XII. Changes to Libpng from version 1.5.x to 1.6.x
 
 A "simplified API" has been added (see documentation in png.h and a simple
 example in contrib/examples/pngtopng.c).  The new publicly visible API
@@ -5748,7 +5751,7 @@
 containing the profile to the calling application which must do its own
 decoding.
 
-.SH XIII.  Detecting libpng
+.SH XIII. Detecting libpng
 
 The png_get_io_ptr() function has been present since libpng-0.88, has never
 changed, and is unaffected by conditional compilation macros.  It is the
@@ -5924,61 +5927,6 @@
 
 Other rules can be inferred by inspecting the libpng source.
 
-.SH XVI. Y2K Compliance in libpng
-
-Since the PNG Development group is an ad-hoc body, we can't make
-an official declaration.
-
-This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.6.35 are Y2K compliant.  It is my belief that earlier
-versions were also Y2K compliant.
-
-Libpng only has two year fields.  One is a 2-byte unsigned integer
-that will hold years up to 65535.  The other, which is deprecated,
-holds the date in text format, and will hold years up to 9999.
-
-The integer is
-    "png_uint_16 year" in png_time_struct.
-
-The string is
-    "char time_buffer[29]" in png_struct.  This is no longer used
-in libpng-1.6.x and will be removed from libpng-1.7.0.
-
-There are seven time-related functions:
-
-    png_convert_to_rfc_1123_buffer() in png.c
-      (formerly png_convert_to_rfc_1152() in error, and
-      also formerly png_convert_to_rfc_1123())
-    png_convert_from_struct_tm() in pngwrite.c, called
-      in pngwrite.c
-    png_convert_from_time_t() in pngwrite.c
-    png_get_tIME() in pngget.c
-    png_handle_tIME() in pngrutil.c, called in pngread.c
-    png_set_tIME() in pngset.c
-    png_write_tIME() in pngwutil.c, called in pngwrite.c
-
-All appear to handle dates properly in a Y2K environment.  The
-png_convert_from_time_t() function calls gmtime() to convert from system
-clock time, which returns (year - 1900), which we properly convert to
-the full 4-digit year.  There is a possibility that applications using
-libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
-function, or that they are incorrectly passing only a 2-digit year
-instead of "year - 1900" into the png_convert_from_struct_tm() function,
-but this is not under our control.  The libpng documentation has always
-stated that it works with 4-digit years, and the APIs have been
-documented as such.
-
-The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
-integer to hold the year, and can hold years as large as 65535.
-
-zlib, upon which libpng depends, is also Y2K compliant.  It contains
-no date-related code.
-
-
-   Glenn Randers-Pehrson
-   libpng maintainer
-   PNG Development Group
-
 .SH NOTE
 
 Note about libpng version numbers:
@@ -5989,9 +5937,9 @@
 The following table summarizes matters since version 0.89c, which was
 the first widely used release:
 
- source             png.h  png.h  shared-lib
- version            string   int  version
- -------            ------  ----- ----------
+ source               png.h    png.h  shared-lib
+ version              string   int    version
+ -------              ------   -----  ----------
  0.89c "1.0 beta 3"     0.89      89  1.0.89
  0.90  "1.0 beta 4"     0.90      90  0.90  [should have been 2.0.90]
  0.95  "1.0 beta 5"     0.95      95  0.95  [should have been 2.0.95]
@@ -6026,23 +5974,25 @@
  1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
  1.0.7                    1    10007  (still compatible)
  ...
- 1.0.19                  10    10019  10.so.0.19[.0]
+ 1.0.69                  10    10069  10.so.0.69[.0]
  ...
  1.2.59                  13    10259  12.so.0.59[.0]
  ...
+ 1.4.20                  14    10420  14.so.0.20[.0]
+ ...
  1.5.30                  15    10530  15.so.15.30[.0]
  ...
  1.6.35                  16    10635  16.so.16.35[.0]
 
-Henceforth the source version will match the shared-library minor
-and patch numbers; the shared-library major version number will be
-used for changes in backward compatibility, as it is intended.  The
-PNG_PNGLIB_VER macro, which is not used within libpng but is available
-for applications, is an unsigned integer of the form xyyzz corresponding
-to the source version x.y.z (leading zeros in y and z).  Beta versions
-were given the previous public release number plus a letter, until
-version 1.0.6j; from then on they were given the upcoming public
-release number plus "betaNN" or "rcNN".
+Henceforth the source version will match the shared-library minor and
+patch numbers; the shared-library major version number will be used for
+changes in backward compatibility, as it is intended.
+The PNG_PNGLIB_VER macro, which is not used within libpng but is
+available for applications, is an unsigned integer of the form XYYZZ
+corresponding to the source version X.Y.Z (leading zeros in Y and Z).
+Beta versions were given the previous public release number plus a
+letter, until version 1.0.6j; from then on they were given the upcoming
+public release number plus "betaNN" or "rcNN".
 
 .SH "SEE ALSO"
 .IR libpngpf(3) ", " png(5)
@@ -6079,8 +6029,9 @@
 and this library, the specification takes precedence.
 
 .SH AUTHORS
-This man page: Glenn Randers-Pehrson
-<glennrp at users.sourceforge.net>
+This man page:
+Initially created by Glenn Randers-Pehrson.
+Maintained by Cosmin Truta.
 
 The contributing authors would like to thank all those who helped
 with testing, bug fixes, and patience.  This wouldn't have been
@@ -6088,9 +6039,9 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.6.35 - July 15, 2018:
+Libpng:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
-Maintained by Glenn Randers-Pehrson.
+Maintained by Cosmin Truta.
 
 Supported by the PNG development group
 .br
@@ -6100,146 +6051,4 @@
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
 to subscribe).
 
-.SH NOTICES:
-
-This copy of the libpng notices is provided for your convenience.  In case of
-any discrepancy between this copy and the notices in the file png.h that is
-included in the libpng distribution, the latter shall prevail.
-
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
-
-If you modify libpng you may insert additional notices immediately following
-this sentence.
-
-This code is released under the libpng license.
-
-libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
-Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
-derived from libpng-1.0.6, and are distributed according to the same
-disclaimer and license as libpng-1.0.6 with the following individuals
-added to the list of Contributing Authors:
-
-   Simon-Pierre Cadieux
-   Eric S. Raymond
-   Mans Rullgard
-   Cosmin Truta
-   Gilles Vollant
-   James Yu
-   Mandar Sahastrabuddhe
-   Google Inc.
-   Vadim Barkov
-
-and with the following additions to the disclaimer:
-
-   There is no warranty against interference with your enjoyment of the
-   library or against infringement.  There is no warranty that our
-   efforts or the library will fulfill any of your particular purposes
-   or needs.  This library is provided with all faults, and the entire
-   risk of satisfactory quality, performance, accuracy, and effort is with
-   the user.
-
-Some files in the "contrib" directory and some configure-generated
-files that are distributed with libpng have other copyright owners and
-are released under other open source licenses.
-
-libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
-Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
-libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the list
-of Contributing Authors:
-
-   Tom Lane
-   Glenn Randers-Pehrson
-   Willem van Schaik
-
-libpng versions 0.89, June 1996, through 0.96, May 1997, are
-Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
-and are distributed according to the same disclaimer and license as
-libpng-0.88, with the following individuals added to the list of
-Contributing Authors:
-
-   John Bowler
-   Kevin Bracey
-   Sam Bushell
-   Magnus Holmgren
-   Greg Roelofs
-   Tom Tanner
-
-Some files in the "scripts" directory have other copyright owners
-but are released under this license.
-
-libpng versions 0.5, May 1995, through 0.88, January 1996, are
-Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
-
-For the purposes of this copyright and license, "Contributing Authors"
-is defined as the following set of individuals:
-
-   Andreas Dilger
-   Dave Martindale
-   Guy Eric Schalnat
-   Paul Schmidt
-   Tim Wegner
-
-The PNG Reference Library is supplied "AS IS".  The Contributing Authors
-and Group 42, Inc. disclaim all warranties, expressed or implied,
-including, without limitation, the warranties of merchantability and of
-fitness for any purpose.  The Contributing Authors and Group 42, Inc.
-assume no liability for direct, indirect, incidental, special, exemplary,
-or consequential damages, which may result from the use of the PNG
-Reference Library, even if advised of the possibility of such damage.
-
-Permission is hereby granted to use, copy, modify, and distribute this
-source code, or portions hereof, for any purpose, without fee, subject
-to the following restrictions:
-
-  1. The origin of this source code must not be misrepresented.
-
-  2. Altered versions must be plainly marked as such and must not
-     be misrepresented as being the original source.
-
-  3. This Copyright notice may not be removed or altered from any
-     source or altered source distribution.
-
-The Contributing Authors and Group 42, Inc. specifically permit, without
-fee, and encourage the use of this source code as a component to
-supporting the PNG file format in commercial products.  If you use this
-source code in a product, acknowledgment is not required but would be
-appreciated.
-
-END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
-
-TRADEMARK:
-
-The name "libpng" has not been registered by the Copyright owner
-as a trademark in any jurisdiction.  However, because libpng has
-been distributed and maintained world-wide, continually since 1995,
-the Copyright owner claims "common-law trademark protection" in any
-jurisdiction where common-law trademark is recognized.
-
-OSI CERTIFICATION:
-
-Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
-a certification mark of the Open Source Initiative. OSI has not addressed
-the additional disclaimers inserted at version 1.0.7.
-
-EXPORT CONTROL:
-
-The Copyright owner believes that the Export Control Classification
-Number (ECCN) for libpng is EAR99, which means not subject to export
-controls or International Traffic in Arms Regulations (ITAR) because
-it is open source, publicly available software, that does not contain
-any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
-734.7(b).
-
-A "png_get_copyright" function is available, for convenient use in "about"
-boxes and the like:
-
-   printf("%s", png_get_copyright(NULL));
-
-Also, the PNG logo (in PNG format, of course) is supplied in the
-files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
-
-Glenn Randers-Pehrson
-July 15, 2018
-
 .\" end of man page
diff --git a/libpngpf.3 b/libpngpf.3
index ed371a4..b736d82 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,7 +1,8 @@
-.TH LIBPNGPF 3 "July 15, 2018"
+.TH LIBPNGPF 3 "December 1, 2018"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.36
 (private functions)
+
 .SH SYNOPSIS
 \fB#include \fI"pngpriv.h"
 
@@ -16,7 +17,8 @@
 available for use by applications.  They are not "exported" to applications
 using shared libraries.
 
-.SH SEE ALSO
+.SH "SEE ALSO"
 .BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
-.SH AUTHOR
-Glenn Randers-Pehrson
+
+.SH AUTHORS
+Cosmin Truta, Glenn Randers-Pehrson
diff --git a/mips/filter_msa_intrinsics.c b/mips/filter_msa_intrinsics.c
index 5705628..a579179 100644
--- a/mips/filter_msa_intrinsics.c
+++ b/mips/filter_msa_intrinsics.c
@@ -1,14 +1,15 @@
 
 /* filter_msa_intrinsics.c - MSA optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2016 Glenn Randers-Pehrson
  * Written by Mandar Sahastrabuddhe, August 2016.
- * Last changed in libpng 1.6.25 [September 1, 2016]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  */
+
 #include <stdio.h>
 #include <stdint.h>
 #include "../pngpriv.h"
diff --git a/mips/mips_init.c b/mips/mips_init.c
index 0bfb7a3..8dd283d 100644
--- a/mips/mips_init.c
+++ b/mips/mips_init.c
@@ -1,14 +1,15 @@
 
 /* mips_init.c - MSA optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2016 Glenn Randers-Pehrson
  * Written by Mandar Sahastrabuddhe, 2016.
- * Last changed in libpng 1.6.25 [September 1, 2016]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  */
+
 /* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
  * called.
  */
diff --git a/png.5 b/png.5
index b0cbd2c..2077d1f 100644
--- a/png.5
+++ b/png.5
@@ -1,47 +1,49 @@
-.TH PNG 5 "April 1, 2017"
+.TH PNG 5 "December 1, 2018"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
+
 .SH DESCRIPTION
 PNG (Portable Network Graphics) is an extensible file format for the
-lossless, portable, well-compressed storage of raster images. PNG provides
-a patent-free replacement for GIF and can also replace many
+lossless, portable, well-compressed storage of raster images.  PNG
+provides a patent-free replacement for GIF, and can also replace many
 common uses of TIFF. Indexed-color, grayscale, and truecolor images are
-supported, plus an optional alpha channel. Sample depths range from
+supported, plus an optional alpha channel.  Sample depths range from
 1 to 16 bits.
 .br
-
-PNG is designed to work well in online viewing applications, such as the
-World Wide Web, so it is fully streamable with a progressive display
-option. PNG is robust, providing both full file integrity checking and
-fast, simple detection of common transmission errors. Also, PNG can store
-gamma and chromaticity data for improved color matching on heterogeneous
-platforms.
+PNG is designed to work well in online viewing applications, such
+as the World Wide Web, so it is fully streamable with a progressive
+display option.  PNG is robust, providing both full file integrity
+checking and fast, simple detection of common transmission errors.
+Also, PNG can store gamma and chromaticity data for improved color
+matching on heterogeneous platforms.
 
 .SH "SEE ALSO"
 .BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
 .LP
-PNG specification (second edition), November 2003:
+PNG Specification (Second Edition), November 2003:
 .IP
 .br
-  <https://www.w3.org/TR/2003/REC-PNG-20031110/
-PNG 1.2 specification, July 1999:
+https://www.w3.org/TR/2003/REC-PNG-20031110/
+.LP
+PNG 1.2 Specification, July 1999:
 .IP
 .br
 https://png-mng.sourceforge.io/pub/png/spec/1.2/
 .LP
-PNG 1.0 specification, October 1996:
+PNG 1.0 Specification, October 1996:
 .IP
 .br
 RFC 2083
-.IP
 .br
 https://www.ietf.org/rfc/rfc2083.txt
+.IP
 .br
-or (as a W3C Recommendation) at
+or W3C Recommendation
 .br
 https://www.w3.org/TR/REC-png-961001
+
 .SH AUTHORS
-This man page: Glenn Randers-Pehrson
+This man page: Cosmin Truta, Glenn Randers-Pehrson
 .LP
 Portable Network Graphics (PNG) Specification (Second Edition)
 Information technology - Computer graphics and image processing -
@@ -53,22 +55,30 @@
 .LP
 Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
 Thomas Boutell and others (png-list).
-.LP
 
-
-.SH COPYRIGHT NOTICE
+.SH COPYRIGHT
 .LP
-This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson.  See png.h
-for conditions of use and distribution.
+This man page is
+.br
+Copyright (c) 2018 Cosmin Truta.
+.br
+Copyright (c) 1998-2006 Glenn Randers-Pehrson.
+.br
+See png.h for conditions of use and distribution.
 .LP
 The PNG Specification (Second Edition) is
+.br
 Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
 .LP
-The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
+The PNG-1.2 Specification is
+.br
+Copyright (c) 1999 Glenn Randers-Pehrson.
+.br
 See the specification for conditions of use and distribution.
 .LP
-The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of
-Technology.  See the specification for conditions of use and distribution.
-.LP
+The PNG-1.0 Specification is
+.br
+Copyright (c) 1996 Massachusetts Institute of Technology.
+.br
+See the specification for conditions of use and distribution.
 .\" end of man page
-
diff --git a/png.c b/png.c
index a25afeb..3dce191 100644
--- a/png.c
+++ b/png.c
@@ -1,10 +1,10 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -14,7 +14,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_35 Your_png_h_is_not_version_1_6_35;
+typedef png_libpng_version_1_6_36 Your_png_h_is_not_version_1_6_36;
 
 #ifdef __GNUC__
 /* The version tests may need to be added to, but the problem warning has
@@ -736,7 +736,7 @@
 int PNGAPI
 png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
 {
-   static PNG_CONST char short_months[12][4] =
+   static const char short_months[12][4] =
         {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
 
@@ -814,20 +814,14 @@
 #ifdef PNG_STRING_COPYRIGHT
    return PNG_STRING_COPYRIGHT
 #else
-#  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-      "libpng version 1.6.35 - July 15, 2018" PNG_STRING_NEWLINE \
+      "libpng version 1.6.36" PNG_STRING_NEWLINE \
+      "Copyright (c) 2018 Cosmin Truta" PNG_STRING_NEWLINE \
       "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
       PNG_STRING_NEWLINE \
       "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
       "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
       PNG_STRING_NEWLINE;
-#  else
-   return "libpng version 1.6.35 - July 15, 2018\
-      Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson\
-      Copyright (c) 1996-1997 Andreas Dilger\
-      Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
-#  endif
 #endif
 }
 
@@ -1121,7 +1115,7 @@
     png_colorspacerp colorspace, png_fixed_point gAMA)
 {
    /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
-    * occur.  Since the fixed point representation is asymetrical it is
+    * occur.  Since the fixed point representation is asymmetrical it is
     * possible for 1/gamma to overflow the limit of 21474 and this means the
     * gamma value must be at least 5/100000 and hence at most 20000.0.  For
     * safety the limits here are a little narrower.  The values are 0.00016 to
@@ -3134,11 +3128,11 @@
             /* The total output count (max) is now 4+precision */
 
             /* Check for an exponent, if we don't need one we are
-             * done and just need to terminate the string.  At
-             * this point exp_b10==(-1) is effectively a flag - it got
-             * to '-1' because of the decrement after outputting
-             * the decimal point above (the exponent required is
-             * *not* -1!)
+             * done and just need to terminate the string.  At this
+             * point, exp_b10==(-1) is effectively a flag: it got
+             * to '-1' because of the decrement, after outputting
+             * the decimal point above. (The exponent required is
+             * *not* -1.)
              */
             if (exp_b10 >= (-1) && exp_b10 <= 2)
             {
@@ -3976,18 +3970,18 @@
  */
 static void
 png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
-    PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
+    unsigned int shift, png_fixed_point gamma_val)
 {
    /* Various values derived from 'shift': */
-   PNG_CONST unsigned int num = 1U << (8U - shift);
+   unsigned int num = 1U << (8U - shift);
 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
    /* CSE the division and work round wacky GCC warnings (see the comments
     * in png_gamma_8bit_correct for where these come from.)
     */
-   PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
+   double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1);
 #endif
-   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
-   PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
+   unsigned int max = (1U << (16U - shift)) - 1U;
+   unsigned int max_by_2 = 1U << (15U - shift);
    unsigned int i;
 
    png_uint_16pp table = *ptable =
@@ -4053,10 +4047,10 @@
  */
 static void
 png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
-    PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
+    unsigned int shift, png_fixed_point gamma_val)
 {
-   PNG_CONST unsigned int num = 1U << (8U - shift);
-   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
+   unsigned int num = 1U << (8U - shift);
+   unsigned int max = (1U << (16U - shift))-1U;
    unsigned int i;
    png_uint_32 last;
 
@@ -4121,7 +4115,7 @@
  */
 static void
 png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
-    PNG_CONST png_fixed_point gamma_val)
+    png_fixed_point gamma_val)
 {
    unsigned int i;
    png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
diff --git a/png.h b/png.h
index 19e464c..8e272a0 100644
--- a/png.h
+++ b/png.h
@@ -1,29 +1,65 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.6.35, July 15, 2018
+ * libpng version 1.6.36 - December 1, 2018
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
- * This code is released under the libpng license (See LICENSE, below)
+ * This code is released under the libpng license. (See LICENSE, below.)
  *
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.6.35, July 15, 2018:
+ *   libpng versions 0.97, January 1998, through 1.6.35, July 2018:
  *     Glenn Randers-Pehrson.
+ *   libpng version 1.6.36, December 1, 2018: Cosmin Truta
  *   See also "Contributing Authors", below.
  */
 
 /*
- * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+ * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
+ * =========================================
  *
- * If you modify libpng you may insert additional notices immediately following
- * this sentence.
+ * PNG Reference Library License version 2
+ * ---------------------------------------
  *
- * This code is released under the libpng license.
+ *  * Copyright (c) 1995-2018 The PNG Reference Library Authors.
+ *  * Copyright (c) 2018 Cosmin Truta.
+ *  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
+ *  * Copyright (c) 1996-1997 Andreas Dilger.
+ *  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+ *
+ * The software is supplied "as is", without warranty of any kind,
+ * express or implied, including, without limitation, the warranties
+ * of merchantability, fitness for a particular purpose, title, and
+ * non-infringement.  In no even shall the Copyright owners, or
+ * anyone distributing the software, be liable for any damages or
+ * other liability, whether in contract, tort or otherwise, arising
+ * from, out of, or in connection with the software, or the use or
+ * other dealings in the software, even if advised of the possibility
+ * of such damage.
+ *
+ * Permission is hereby granted to use, copy, modify, and distribute
+ * this software, or portions hereof, for any purpose, without fee,
+ * subject to the following restrictions:
+ *
+ *  1. The origin of this software must not be misrepresented; you
+ *     must not claim that you wrote the original software.  If you
+ *     use this software in a product, an acknowledgment in the product
+ *     documentation would be appreciated, but is not required.
+ *
+ *  2. Altered source versions must be plainly marked as such, and must
+ *     not be misrepresented as being the original software.
+ *
+ *  3. This Copyright notice may not be removed or altered from any
+ *     source or altered source distribution.
+ *
+ *
+ * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
+ * -----------------------------------------------------------------------
  *
  * libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
@@ -31,38 +67,38 @@
  * disclaimer and license as libpng-1.0.6 with the following individuals
  * added to the list of Contributing Authors:
  *
- *    Simon-Pierre Cadieux
- *    Eric S. Raymond
- *    Mans Rullgard
- *    Cosmin Truta
- *    Gilles Vollant
- *    James Yu
- *    Mandar Sahastrabuddhe
- *    Google Inc.
- *    Vadim Barkov
+ *     Simon-Pierre Cadieux
+ *     Eric S. Raymond
+ *     Mans Rullgard
+ *     Cosmin Truta
+ *     Gilles Vollant
+ *     James Yu
+ *     Mandar Sahastrabuddhe
+ *     Google Inc.
+ *     Vadim Barkov
  *
  * and with the following additions to the disclaimer:
  *
- *    There is no warranty against interference with your enjoyment of the
- *    library or against infringement.  There is no warranty that our
- *    efforts or the library will fulfill any of your particular purposes
- *    or needs.  This library is provided with all faults, and the entire
- *    risk of satisfactory quality, performance, accuracy, and effort is with
- *    the user.
+ *     There is no warranty against interference with your enjoyment of
+ *     the library or against infringement.  There is no warranty that our
+ *     efforts or the library will fulfill any of your particular purposes
+ *     or needs.  This library is provided with all faults, and the entire
+ *     risk of satisfactory quality, performance, accuracy, and effort is
+ *     with the user.
  *
  * Some files in the "contrib" directory and some configure-generated
- * files that are distributed with libpng have other copyright owners and
+ * files that are distributed with libpng have other copyright owners, and
  * are released under other open source licenses.
  *
  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  * libpng-0.96, and are distributed according to the same disclaimer and
- * license as libpng-0.96, with the following individuals added to the list
- * of Contributing Authors:
+ * license as libpng-0.96, with the following individuals added to the
+ * list of Contributing Authors:
  *
- *    Tom Lane
- *    Glenn Randers-Pehrson
- *    Willem van Schaik
+ *     Tom Lane
+ *     Glenn Randers-Pehrson
+ *     Willem van Schaik
  *
  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
  * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
@@ -70,14 +106,14 @@
  * libpng-0.88, with the following individuals added to the list of
  * Contributing Authors:
  *
- *    John Bowler
- *    Kevin Bracey
- *    Sam Bushell
- *    Magnus Holmgren
- *    Greg Roelofs
- *    Tom Tanner
+ *     John Bowler
+ *     Kevin Bracey
+ *     Sam Bushell
+ *     Magnus Holmgren
+ *     Greg Roelofs
+ *     Tom Tanner
  *
- * Some files in the "scripts" directory have other copyright owners
+ * Some files in the "scripts" directory have other copyright owners,
  * but are released under this license.
  *
  * libpng versions 0.5, May 1995, through 0.88, January 1996, are
@@ -86,62 +122,49 @@
  * For the purposes of this copyright and license, "Contributing Authors"
  * is defined as the following set of individuals:
  *
- *    Andreas Dilger
- *    Dave Martindale
- *    Guy Eric Schalnat
- *    Paul Schmidt
- *    Tim Wegner
+ *     Andreas Dilger
+ *     Dave Martindale
+ *     Guy Eric Schalnat
+ *     Paul Schmidt
+ *     Tim Wegner
  *
- * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
- * and Group 42, Inc. disclaim all warranties, expressed or implied,
- * including, without limitation, the warranties of merchantability and of
- * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
- * assume no liability for direct, indirect, incidental, special, exemplary,
- * or consequential damages, which may result from the use of the PNG
- * Reference Library, even if advised of the possibility of such damage.
+ * The PNG Reference Library is supplied "AS IS".  The Contributing
+ * Authors and Group 42, Inc. disclaim all warranties, expressed or
+ * implied, including, without limitation, the warranties of
+ * merchantability and of fitness for any purpose.  The Contributing
+ * Authors and Group 42, Inc. assume no liability for direct, indirect,
+ * incidental, special, exemplary, or consequential damages, which may
+ * result from the use of the PNG Reference Library, even if advised of
+ * the possibility of such damage.
  *
  * Permission is hereby granted to use, copy, modify, and distribute this
  * source code, or portions hereof, for any purpose, without fee, subject
  * to the following restrictions:
  *
- *   1. The origin of this source code must not be misrepresented.
+ *  1. The origin of this source code must not be misrepresented.
  *
- *   2. Altered versions must be plainly marked as such and must not
- *      be misrepresented as being the original source.
+ *  2. Altered versions must be plainly marked as such and must not
+ *     be misrepresented as being the original source.
  *
- *   3. This Copyright notice may not be removed or altered from any
- *      source or altered source distribution.
+ *  3. This Copyright notice may not be removed or altered from any
+ *     source or altered source distribution.
  *
- * The Contributing Authors and Group 42, Inc. specifically permit, without
- * fee, and encourage the use of this source code as a component to
- * supporting the PNG file format in commercial products.  If you use this
- * source code in a product, acknowledgment is not required but would be
- * appreciated.
+ * The Contributing Authors and Group 42, Inc. specifically permit,
+ * without fee, and encourage the use of this source code as a component
+ * to supporting the PNG file format in commercial products.  If you use
+ * this source code in a product, acknowledgment is not required but would
+ * be appreciated.
  *
  * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
  *
- * TRADEMARK:
+ * TRADEMARK
+ * =========
  *
- * The name "libpng" has not been registered by the Copyright owner
+ * The name "libpng" has not been registered by the Copyright owners
  * as a trademark in any jurisdiction.  However, because libpng has
  * been distributed and maintained world-wide, continually since 1995,
- * the Copyright owner claims "common-law trademark protection" in any
+ * the Copyright owners claim "common-law trademark protection" in any
  * jurisdiction where common-law trademark is recognized.
- *
- * OSI CERTIFICATION:
- *
- * Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
- * a certification mark of the Open Source Initiative. OSI has not addressed
- * the additional disclaimers inserted at version 1.0.7.
- *
- * EXPORT CONTROL:
- *
- * The Copyright owner believes that the Export Control Classification
- * Number (ECCN) for libpng is EAR99, which means not subject to export
- * controls or International Traffic in Arms Regulations (ITAR) because
- * it is open source, publicly available software, that does not contain
- * any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
- * 734.7(b).
  */
 
 /*
@@ -207,23 +230,25 @@
  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
  *    1.0.7                    1    10007  (still compatible)
  *    ...
- *    1.0.19                  10    10019  10.so.0.19[.0]
+ *    1.0.69                  10    10069  10.so.0.69[.0]
  *    ...
- *    1.2.59                  13    10257  12.so.0.59[.0]
+ *    1.2.59                  13    10259  12.so.0.59[.0]
  *    ...
- *    1.5.30                  15    10527  15.so.15.30[.0]
+ *    1.4.20                  14    10420  14.so.0.20[.0]
  *    ...
- *    1.6.35                  16    10635  16.so.16.35[.0]
+ *    1.5.30                  15    10530  15.so.15.30[.0]
+ *    ...
+ *    1.6.36                  16    10636  16.so.16.36[.0]
  *
- *    Henceforth the source version will match the shared-library major
- *    and minor numbers; the shared-library major version number will be
- *    used for changes in backward compatibility, as it is intended.  The
- *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
- *    for applications, is an unsigned integer of the form xyyzz corresponding
- *    to the source version x.y.z (leading zeros in y and z).  Beta versions
- *    were given the previous public release number plus a letter, until
- *    version 1.0.6j; from then on they were given the upcoming public
- *    release number plus "betaNN" or "rcNN".
+ *    Henceforth the source version will match the shared-library major and
+ *    minor numbers; the shared-library major version number will be used for
+ *    changes in backward compatibility, as it is intended.
+ *    The PNG_LIBPNG_VER macro, which is not used within libpng but is
+ *    available for applications, is an unsigned integer of the form XYYZZ
+ *    corresponding to the source version X.Y.Z (leading zeros in Y and Z).
+ *    Beta versions were given the previous public release number plus a
+ *    letter, until version 1.0.6j; from then on they were given the upcoming
+ *    public release number plus "betaNN" or "rcNN".
  *
  *    Binary incompatibility exists only when applications make direct access
  *    to the info_ptr or png_ptr members through png.h, and the compiled
@@ -233,65 +258,8 @@
  *    in binary compatibility (e.g., when a new feature is added).
  *
  * See libpng.txt or libpng.3 for more information.  The PNG specification
- * is available as a W3C Recommendation and as an ISO Specification,
- * <https://www.w3.org/TR/2003/REC-PNG-20031110/
- */
-
-/*
- * Y2K compliance in libpng:
- * =========================
- *
- *    July 15, 2018
- *
- *    Since the PNG Development group is an ad-hoc body, we can't make
- *    an official declaration.
- *
- *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.6.35 are Y2K compliant.  It is my belief that
- *    earlier versions were also Y2K compliant.
- *
- *    Libpng only has two year fields.  One is a 2-byte unsigned integer
- *    that will hold years up to 65535.  The other, which is deprecated,
- *    holds the date in text format, and will hold years up to 9999.
- *
- *    The integer is
- *        "png_uint_16 year" in png_time_struct.
- *
- *    The string is
- *        "char time_buffer[29]" in png_struct.  This is no longer used
- *    in libpng-1.6.x and will be removed from libpng-1.7.0.
- *
- *    There are seven time-related functions:
- *        png.c: png_convert_to_rfc_1123_buffer() in png.c
- *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
- *          png_convert_to_rfc_1152() in error prior to libpng-0.98)
- *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
- *        png_convert_from_time_t() in pngwrite.c
- *        png_get_tIME() in pngget.c
- *        png_handle_tIME() in pngrutil.c, called in pngread.c
- *        png_set_tIME() in pngset.c
- *        png_write_tIME() in pngwutil.c, called in pngwrite.c
- *
- *    All handle dates properly in a Y2K environment.  The
- *    png_convert_from_time_t() function calls gmtime() to convert from system
- *    clock time, which returns (year - 1900), which we properly convert to
- *    the full 4-digit year.  There is a possibility that libpng applications
- *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
- *    function, or that they are incorrectly passing only a 2-digit year
- *    instead of "year - 1900" into the png_convert_from_struct_tm() function,
- *    but this is not under our control.  The libpng documentation has always
- *    stated that it works with 4-digit years, and the APIs have been
- *    documented as such.
- *
- *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
- *    integer to hold the year, and can hold years as large as 65535.
- *
- *    zlib, upon which libpng depends, is also Y2K compliant.  It contains
- *    no date-related code.
- *
- *       Glenn Randers-Pehrson
- *       libpng maintainer
- *       PNG Development Group
+ * is available as a W3C Recommendation and as an ISO/IEC Standard; see
+ * <https://www.w3.org/TR/2003/REC-PNG-20031110/>
  */
 
 #ifndef PNG_H
@@ -309,8 +277,8 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.35"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.35 - July 15, 2018\n"
+#define PNG_LIBPNG_VER_STRING "1.6.36"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.6.36 - December 1, 2018\n"
 
 #define PNG_LIBPNG_VER_SONUM   16
 #define PNG_LIBPNG_VER_DLLNUM  16
@@ -318,13 +286,13 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   6
-#define PNG_LIBPNG_VER_RELEASE 35
+#define PNG_LIBPNG_VER_RELEASE 36
 
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
  */
 
-#define PNG_LIBPNG_VER_BUILD  02
+#define PNG_LIBPNG_VER_BUILD  0
 
 /* Release Status */
 #define PNG_LIBPNG_BUILD_ALPHA    1
@@ -341,15 +309,16 @@
 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
                                        PNG_LIBPNG_BUILD_PRIVATE */
 
-#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
+#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
 
-/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
- * We must not include leading zeros.
- * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
- * version 1.0.0 was mis-numbered 100 instead of 10000).  From
- * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
+/* Careful here.  At one time, Guy wanted to use 082, but that
+ * would be octal.  We must not include leading zeros.
+ * Versions 0.7 through 1.0.0 were in the range 0 to 100 here
+ * (only version 1.0.0 was mis-numbered 100 instead of 10000).
+ * From version 1.0.1 it is:
+ * XXYYZZ, where XX=major, YY=minor, ZZ=release
  */
-#define PNG_LIBPNG_VER 10635 /* 1.6.35 */
+#define PNG_LIBPNG_VER 10636 /* 1.6.36 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
@@ -459,7 +428,7 @@
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_6_35;
+typedef char* png_libpng_version_1_6_36;
 
 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
  *
@@ -2013,12 +1982,12 @@
 PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
     png_inforp info_ptr, png_bytep *exif));
 PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
-    png_inforp info_ptr, const png_bytep exif));
+    png_inforp info_ptr, png_bytep exif));
 
 PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
     png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
 PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
-    png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif));
+    png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
 #endif
 
 #ifdef PNG_gAMA_SUPPORTED
@@ -2764,7 +2733,7 @@
  *
  * When the simplified API needs to convert between sRGB and linear colorspaces,
  * the actual sRGB transfer curve defined in the sRGB specification (see the
- * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
+ * article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2
  * approximation used elsewhere in libpng.
  *
  * When an alpha channel is present it is expected to denote pixel coverage
@@ -2967,7 +2936,7 @@
  * 'flags' field of png_image.
  */
 #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
-   /* This indicates the the RGB values of the in-memory bitmap do not
+   /* This indicates that the RGB values of the in-memory bitmap do not
     * correspond to the red, green and blue end-points defined by sRGB.
     */
 
diff --git a/pngconf.h b/pngconf.h
index a4646ba..5e641b2 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,11 +1,12 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.6.35, July 15, 2018
+ * libpng version 1.6.36
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -57,14 +58,13 @@
 
 #endif /* PNG_BUILDING_SYMBOL_TABLE */
 
-/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
- * PNG_NO_CONST; this is no longer supported except for data declarations which
- * apparently still cause problems in 2011 on some compilers.
+/* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
+ * using PNG_NO_CONST.  This is no longer supported.
  */
 #define PNG_CONST const /* backward compatibility only */
 
-/* This controls optimization of the reading of 16-bit and 32-bit values
- * from PNG files.  It can be set on a per-app-file basis - it
+/* This controls optimization of the reading of 16-bit and 32-bit
+ * values from PNG files.  It can be set on a per-app-file basis: it
  * just changes whether a macro is used when the function is called.
  * The library builder sets the default; if read functions are not
  * built into the library the macro implementation is forced on.
diff --git a/pngdebug.h b/pngdebug.h
index 15a7ed0..00d5a45 100644
--- a/pngdebug.h
+++ b/pngdebug.h
@@ -1,10 +1,10 @@
 
 /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
  *
- * Last changed in libpng 1.6.8 [December 19, 2013]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pngerror.c b/pngerror.c
index ad48bfb..ec3a709 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,10 +1,10 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * Last changed in libpng 1.6.31 [July 27, 2017]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -425,7 +425,7 @@
  * if the character is invalid.
  */
 #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
-static PNG_CONST char png_digit[16] = {
+static const char png_digit[16] = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'A', 'B', 'C', 'D', 'E', 'F'
 };
@@ -885,7 +885,7 @@
 png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
     PNG_NORETURN)
 {
-   const png_const_structrp png_ptr = png_nonconst_ptr;
+   png_const_structrp png_ptr = png_nonconst_ptr;
    png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
 
    /* An error is always logged here, overwriting anything (typically a warning)
@@ -920,7 +920,7 @@
 void /* PRIVATE */ PNGCBAPI
 png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
 {
-   const png_const_structrp png_ptr = png_nonconst_ptr;
+   png_const_structrp png_ptr = png_nonconst_ptr;
    png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
 
    /* A warning is only logged if there is no prior warning or error. */
diff --git a/pngget.c b/pngget.c
index 2325508..5abf1ef 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,10 +1,10 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pnginfo.h b/pnginfo.h
index 2fcf868..1f98ded 100644
--- a/pnginfo.h
+++ b/pnginfo.h
@@ -1,10 +1,10 @@
 
 /* pnginfo.h - header file for PNG reference library
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pngmem.c b/pngmem.c
index ff3ef7e..09ed9c1 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,10 +1,10 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pngpread.c b/pngpread.c
index c4ba51c..e283627 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,10 +1,10 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -972,20 +972,20 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
 
    /* Height of interlace block.  This is not currently used - if you need
     * it, uncomment it here and in png.h
-   static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
    */
 #endif
 
diff --git a/pngpriv.h b/pngpriv.h
index 3581f67..973c3ea 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -1,10 +1,10 @@
 
 /* pngpriv.h - private declarations for use inside libpng
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -174,7 +174,10 @@
 #     else /* !defined __ARM_NEON__ */
          /* The 'intrinsics' code simply won't compile without this -mfpu=neon:
           */
-#        define PNG_ARM_NEON_IMPLEMENTATION 2
+#        if !defined(__aarch64__)
+            /* The assembler code currently does not work on ARM64 */
+#          define PNG_ARM_NEON_IMPLEMENTATION 2
+#        endif /* __aarch64__ */
 #     endif /* __ARM_NEON__ */
 #  endif /* !PNG_ARM_NEON_IMPLEMENTATION */
 
@@ -1534,10 +1537,10 @@
 #endif
 
 PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
-    const png_uint_32 chunk_name),PNG_EMPTY);
+    png_uint_32 chunk_name),PNG_EMPTY);
 
 PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
-    const png_uint_32 chunk_length),PNG_EMPTY);
+    png_uint_32 chunk_length),PNG_EMPTY);
 
 PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
     png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
@@ -2114,6 +2117,29 @@
 PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
    png_const_charp key, png_bytep new_key), PNG_EMPTY);
 
+#if PNG_ARM_NEON_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void,
+                      png_riffle_palette_rgba,
+                      (png_structrp, png_row_infop),
+                      PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int,
+                      png_do_expand_palette_neon_rgba,
+                      (png_structrp,
+                       png_row_infop,
+                       png_const_bytep,
+                       const png_bytepp,
+                       const png_bytepp),
+                      PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int,
+                      png_do_expand_palette_neon_rgb,
+                      (png_structrp,
+                       png_row_infop,
+                       png_const_bytep,
+                       const png_bytepp,
+                       const png_bytepp),
+                      PNG_EMPTY);
+#endif
+
 /* Maintainer: Put new private prototypes here ^ */
 
 #include "pngdebug.h"
diff --git a/pngread.c b/pngread.c
index bff7503..f8e7621 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,10 +1,10 @@
 
 /* pngread.c - read a PNG file
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -1621,7 +1621,7 @@
     * errors (which are unfortunately quite common.)
     */
    {
-         static PNG_CONST png_byte chunks_to_process[] = {
+         static const png_byte chunks_to_process[] = {
             98,  75,  71,  68, '\0',  /* bKGD */
             99,  72,  82,  77, '\0',  /* cHRM */
            103,  65,  77,  65, '\0',  /* gAMA */
@@ -1758,9 +1758,9 @@
     png_uint_32 alpha, int encoding)
 {
    png_imagep image = display->image;
-   const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
+   int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
        P_LINEAR : P_sRGB;
-   const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
+   int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
        (red != green || green != blue);
 
    if (ip > 255)
@@ -1869,13 +1869,13 @@
    /* Store the value. */
    {
 #     ifdef PNG_FORMAT_AFIRST_SUPPORTED
-         const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
+         int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
             (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
 #     else
 #        define afirst 0
 #     endif
 #     ifdef PNG_FORMAT_BGR_SUPPORTED
-         const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
+         int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
 #     else
 #        define bgr 0
 #     endif
@@ -2085,11 +2085,11 @@
 {
    png_image_read_control *display =
       png_voidcast(png_image_read_control*, argument);
-   const png_imagep image = display->image;
+   png_imagep image = display->image;
 
-   const png_structrp png_ptr = image->opaque->png_ptr;
-   const png_uint_32 output_format = image->format;
-   const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
+   png_structrp png_ptr = image->opaque->png_ptr;
+   png_uint_32 output_format = image->format;
+   int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
       P_LINEAR : P_sRGB;
 
    unsigned int cmap_entries;
@@ -2802,7 +2802,7 @@
             unsigned int num_trans = png_ptr->num_trans;
             png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;
             png_const_colorp colormap = png_ptr->palette;
-            const int do_background = trans != NULL &&
+            int do_background = trans != NULL &&
                (output_format & PNG_FORMAT_FLAG_ALPHA) == 0;
             unsigned int i;
 
@@ -3946,7 +3946,7 @@
        */
       if (linear != 0)
       {
-         PNG_CONST png_uint_16 le = 0x0001;
+         png_uint_16 le = 0x0001;
 
          if ((*(png_const_bytep) & le) != 0)
             png_set_swap(png_ptr);
@@ -4108,7 +4108,7 @@
        * original PNG format because it may not occur in the output PNG format
        * and libpng deals with the issues of reading the original.
        */
-      const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
+      unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
 
       /* The following checks just the 'row_stride' calculation to ensure it
        * fits in a signed 32-bit value.  Because channels/components can be
@@ -4119,7 +4119,7 @@
       if (image->width <= 0x7fffffffU/channels) /* no overflow */
       {
          png_uint_32 check;
-         const png_uint_32 png_row_stride = image->width * channels;
+         png_uint_32 png_row_stride = image->width * channels;
 
          if (row_stride == 0)
             row_stride = (png_int_32)/*SAFE*/png_row_stride;
diff --git a/pngrio.c b/pngrio.c
index 3722214..7946358 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,10 +1,10 @@
 
 /* pngrio.c - functions for data input
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pngrtran.c b/pngrtran.c
index 67d1f24..ccc58ce 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,10 +1,10 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -18,6 +18,17 @@
 
 #include "pngpriv.h"
 
+#ifdef PNG_ARM_NEON_IMPLEMENTATION
+#  if PNG_ARM_NEON_IMPLEMENTATION == 1
+#    define PNG_ARM_NEON_INTRINSICS_AVAILABLE
+#    if defined(_MSC_VER) && defined(_M_ARM64)
+#      include <arm64_neon.h>
+#    else
+#      include <arm_neon.h>
+#    endif
+#  endif
+#endif
+
 #ifdef PNG_READ_SUPPORTED
 
 /* Set the action on getting a CRC error for an ancillary or critical chunk. */
@@ -2986,7 +2997,6 @@
  */
 static int
 png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
-
 {
    int rgb_error = 0;
 
@@ -2995,12 +3005,11 @@
    if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
        (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
    {
-      PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
-      PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
-      PNG_CONST png_uint_32 bc = 32768 - rc - gc;
-      PNG_CONST png_uint_32 row_width = row_info->width;
-      PNG_CONST int have_alpha =
-         (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
+      png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
+      png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
+      png_uint_32 bc = 32768 - rc - gc;
+      png_uint_32 row_width = row_info->width;
+      int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
 
       if (row_info->bit_depth == 8)
       {
@@ -4143,12 +4152,11 @@
    {
       if (row_info->bit_depth == 8)
       {
-         PNG_CONST png_bytep table = png_ptr->gamma_from_1;
+         png_bytep table = png_ptr->gamma_from_1;
 
          if (table != NULL)
          {
-            PNG_CONST int step =
-               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
+            int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
 
             /* The alpha channel is the last component: */
             row += step - 1;
@@ -4162,13 +4170,12 @@
 
       else if (row_info->bit_depth == 16)
       {
-         PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;
-         PNG_CONST int gamma_shift = png_ptr->gamma_shift;
+         png_uint_16pp table = png_ptr->gamma_16_from_1;
+         int gamma_shift = png_ptr->gamma_shift;
 
          if (table != NULL)
          {
-            PNG_CONST int step =
-               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
+            int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
 
             /* The alpha channel is the last component: */
             row += step - 2;
@@ -4199,8 +4206,9 @@
  * upon whether you supply trans and num_trans.
  */
 static void
-png_do_expand_palette(png_row_infop row_info, png_bytep row,
-    png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
+png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
+    png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha,
+    int num_trans)
 {
    int shift, value;
    png_bytep sp, dp;
@@ -4304,14 +4312,25 @@
                sp = row + (size_t)row_width - 1;
                dp = row + ((size_t)row_width << 2) - 1;
 
-               for (i = 0; i < row_width; i++)
+               i = 0;
+#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
+               if (png_ptr->riffled_palette != NULL)
+               {
+                  /* The RGBA optimization works with png_ptr->bit_depth == 8
+                   * but sometimes row_info->bit_depth has been changed to 8.
+                   * In these cases, the palette hasn't been riffled.
+                   */
+                  i = png_do_expand_palette_neon_rgba(png_ptr, row_info, row,
+                      &sp, &dp);
+               }
+#endif
+
+               for (; i < row_width; i++)
                {
                   if ((int)(*sp) >= num_trans)
                      *dp-- = 0xff;
-
                   else
                      *dp-- = trans_alpha[*sp];
-
                   *dp-- = palette[*sp].blue;
                   *dp-- = palette[*sp].green;
                   *dp-- = palette[*sp].red;
@@ -4328,8 +4347,13 @@
             {
                sp = row + (size_t)row_width - 1;
                dp = row + (size_t)(row_width * 3) - 1;
+               i = 0;
+#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
+               i = png_do_expand_palette_neon_rgb(png_ptr, row_info, row,
+                   &sp, &dp);
+#endif
 
-               for (i = 0; i < row_width; i++)
+               for (; i < row_width; i++)
                {
                   *dp-- = palette[*sp].blue;
                   *dp-- = palette[*sp].green;
@@ -4743,8 +4767,22 @@
    {
       if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
       {
-         png_do_expand_palette(row_info, png_ptr->row_buf + 1,
-             png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
+#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
+         if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8))
+         {
+            /* Allocate space for the decompressed full palette. */
+            if (png_ptr->riffled_palette == NULL)
+            {
+               png_ptr->riffled_palette = png_malloc(png_ptr, 256*4);
+               if (png_ptr->riffled_palette == NULL)
+                  png_error(png_ptr, "NULL row buffer");
+               /* Build the RGBA palette. */
+               png_riffle_palette_rgba(png_ptr, row_info);
+            }
+         }
+#endif
+         png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1,
+            png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
       }
 
       else
diff --git a/pngrutil.c b/pngrutil.c
index 7001f19..d5fa08c 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,10 +1,10 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -1461,8 +1461,7 @@
                {
                   /* We have the ICC profile header; do the basic header checks.
                    */
-                  const png_uint_32 profile_length =
-                     png_get_uint_32(profile_header);
+                  png_uint_32 profile_length = png_get_uint_32(profile_header);
 
                   if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
                       keyword, profile_length) != 0)
@@ -1479,8 +1478,8 @@
                          * profile.  The header check has already validated
                          * that none of this stuff will overflow.
                          */
-                        const png_uint_32 tag_count = png_get_uint_32(
-                            profile_header+128);
+                        png_uint_32 tag_count =
+                           png_get_uint_32(profile_header + 128);
                         png_bytep profile = png_read_buffer(png_ptr,
                             profile_length, 2/*silent*/);
 
@@ -3132,7 +3131,7 @@
  */
 
 void /* PRIVATE */
-png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
+png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
 {
    int i;
    png_uint_32 cn=chunk_name;
@@ -3151,7 +3150,7 @@
 }
 
 void /* PRIVATE */
-png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
+png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
 {
    png_alloc_size_t limit = PNG_UINT_31_MAX;
 
@@ -3363,7 +3362,7 @@
          /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
           * then pass:
           */
-         static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
+         static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
          {
             /* Little-endian byte masks for PACKSWAP */
             { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
@@ -3374,7 +3373,7 @@
          /* display_mask has only three entries for the odd passes, so index by
           * pass>>1.
           */
-         static PNG_CONST png_uint_32 display_mask[2][3][3] =
+         static const png_uint_32 display_mask[2][3][3] =
          {
             /* Little-endian byte masks for PACKSWAP */
             { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
@@ -3687,7 +3686,7 @@
 {
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    /* Offset to next interlace block */
-   static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    png_debug(1, "in png_do_read_interlace");
    if (row != NULL && row_info != NULL)
@@ -4329,16 +4328,16 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 
    png_debug(1, "in png_read_finish_row");
    png_ptr->row_number++;
@@ -4394,16 +4393,16 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 
    unsigned int max_pixel_depth;
    size_t row_bytes;
diff --git a/pngset.c b/pngset.c
index 7cf54d9..ec75dbe 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,10 +1,10 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -137,7 +137,7 @@
 #ifdef PNG_eXIf_SUPPORTED
 void PNGAPI
 png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
-    const png_bytep eXIf_buf)
+    png_bytep eXIf_buf)
 {
   png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
   PNG_UNUSED(info_ptr)
@@ -146,7 +146,7 @@
 
 void PNGAPI
 png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
-    const png_uint_32 num_exif, const png_bytep eXIf_buf)
+    png_uint_32 num_exif, png_bytep eXIf_buf)
 {
    int i;
 
@@ -1399,7 +1399,7 @@
       /* Ignore all unknown chunks and all chunks recognized by
        * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
        */
-      static PNG_CONST png_byte chunks_to_ignore[] = {
+      static const png_byte chunks_to_ignore[] = {
          98,  75,  71,  68, '\0',  /* bKGD */
          99,  72,  82,  77, '\0',  /* cHRM */
         101,  88,  73, 102, '\0',  /* eXIf */
diff --git a/pngstruct.h b/pngstruct.h
index 699e8ac..94a6d04 100644
--- a/pngstruct.h
+++ b/pngstruct.h
@@ -1,10 +1,10 @@
 
 /* pngstruct.h - header file for PNG reference library
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -228,6 +228,10 @@
                                * big_row_buf; while writing it is separately
                                * allocated.
                                */
+#ifdef PNG_READ_EXPAND_SUPPORTED
+   /* Buffer to accelerate palette transformations. */
+   png_bytep riffled_palette;
+#endif
 #ifdef PNG_WRITE_FILTER_SUPPORTED
    png_bytep try_row;    /* buffer to save trial row when filtering */
    png_bytep tst_row;    /* buffer to save best trial row when filtering */
diff --git a/pngtest.c b/pngtest.c
index 4411fd9..f27e91e 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,10 +1,10 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -449,13 +449,13 @@
  */
 typedef struct
 {
-   PNG_CONST char *file_name;
+   const char *file_name;
 }  pngtest_error_parameters;
 
 static void PNGCBAPI
 pngtest_warning(png_structp png_ptr, png_const_charp message)
 {
-   PNG_CONST char *name = "UNKNOWN (ERROR!)";
+   const char *name = "UNKNOWN (ERROR!)";
    pngtest_error_parameters *test =
       (pngtest_error_parameters*)png_get_error_ptr(png_ptr);
 
@@ -850,7 +850,7 @@
 
 /* Test one file */
 static int
-test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
+test_one_file(const char *inname, const char *outname)
 {
    static png_FILE_p fpin;
    static png_FILE_p fpout;  /* "static" prevents setjmp corruption */
@@ -1809,11 +1809,11 @@
 
 /* Input and output filenames */
 #ifdef RISCOS
-static PNG_CONST char *inname = "pngtest/png";
-static PNG_CONST char *outname = "pngout/png";
+static const char *inname = "pngtest/png";
+static const char *outname = "pngout/png";
 #else
-static PNG_CONST char *inname = "pngtest.png";
-static PNG_CONST char *outname = "pngout.png";
+static const char *inname = "pngtest.png";
+static const char *outname = "pngout.png";
 #endif
 
 int
@@ -2153,4 +2153,4 @@
 #endif
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_35 Your_png_h_is_not_version_1_6_35;
+typedef png_libpng_version_1_6_36 Your_png_h_is_not_version_1_6_36;
diff --git a/pngtrans.c b/pngtrans.c
index de84aa6..1100f46 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,10 +1,10 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -345,7 +345,7 @@
 #endif
 
 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-static PNG_CONST png_byte onebppswaptable[256] = {
+static const png_byte onebppswaptable[256] = {
    0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
    0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
    0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@@ -380,7 +380,7 @@
    0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
 };
 
-static PNG_CONST png_byte twobppswaptable[256] = {
+static const png_byte twobppswaptable[256] = {
    0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
    0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
    0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
@@ -415,7 +415,7 @@
    0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
 };
 
-static PNG_CONST png_byte fourbppswaptable[256] = {
+static const png_byte fourbppswaptable[256] = {
    0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
    0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
    0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
diff --git a/pngwio.c b/pngwio.c
index e539168..10e919d 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,10 +1,10 @@
 
 /* pngwio.c - functions for data output
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pngwrite.c b/pngwrite.c
index 5bd87f3..160c877 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,10 +1,10 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -469,7 +469,7 @@
 
 #ifdef PNG_CONVERT_tIME_SUPPORTED
 void PNGAPI
-png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
+png_convert_from_struct_tm(png_timep ptime, const struct tm * ttime)
 {
    png_debug(1, "in png_convert_from_struct_tm");
 
@@ -948,6 +948,10 @@
    png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
    png_free(png_ptr, png_ptr->row_buf);
    png_ptr->row_buf = NULL;
+#ifdef PNG_READ_EXPANDED_SUPPORTED
+   png_free(png_ptr, png_ptr->riffled_palette);
+   png_ptr->riffled_palette = NULL;
+#endif
 #ifdef PNG_WRITE_FILTER_SUPPORTED
    png_free(png_ptr, png_ptr->prev_row);
    png_free(png_ptr, png_ptr->try_row);
@@ -1536,7 +1540,7 @@
        display->first_row);
    png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
    png_uint_16p row_end;
-   const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
+   unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
        3 : 1;
    int aindex = 0;
    png_uint_32 y = image->height;
@@ -1573,7 +1577,7 @@
 
       while (out_ptr < row_end)
       {
-         const png_uint_16 alpha = in_ptr[aindex];
+         png_uint_16 alpha = in_ptr[aindex];
          png_uint_32 reciprocal = 0;
          int c;
 
@@ -1695,7 +1699,7 @@
        display->first_row);
    png_bytep output_row = png_voidcast(png_bytep, display->local_row);
    png_uint_32 y = image->height;
-   const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
+   unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
        3 : 1;
 
    if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
@@ -1783,25 +1787,25 @@
 static void
 png_image_set_PLTE(png_image_write_control *display)
 {
-   const png_imagep image = display->image;
+   png_imagep image = display->image;
    const void *cmap = display->colormap;
-   const int entries = image->colormap_entries > 256 ? 256 :
+   int entries = image->colormap_entries > 256 ? 256 :
        (int)image->colormap_entries;
 
    /* NOTE: the caller must check for cmap != NULL and entries != 0 */
-   const png_uint_32 format = image->format;
-   const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
+   png_uint_32 format = image->format;
+   unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
 
 #   if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
       defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
-      const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
+      int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
           (format & PNG_FORMAT_FLAG_ALPHA) != 0;
 #   else
 #     define afirst 0
 #   endif
 
 #   ifdef PNG_FORMAT_BGR_SUPPORTED
-      const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
+      int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
 #   else
 #     define bgr 0
 #   endif
@@ -1951,12 +1955,12 @@
     * and total image size to ensure that they are within the system limits.
     */
    {
-      const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
+      unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
 
       if (image->width <= 0x7fffffffU/channels) /* no overflow */
       {
          png_uint_32 check;
-         const png_uint_32 png_row_stride = image->width * channels;
+         png_uint_32 png_row_stride = image->width * channels;
 
          if (display->row_stride == 0)
             display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
@@ -2052,7 +2056,7 @@
     */
    if (write_16bit != 0)
    {
-      PNG_CONST png_uint_16 le = 0x0001;
+      png_uint_16 le = 0x0001;
 
       if ((*(png_const_bytep) & le) != 0)
          png_set_swap(png_ptr);
@@ -2166,7 +2170,7 @@
 {
    png_image_write_control *display = png_voidcast(png_image_write_control*,
        png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
-   const png_alloc_size_t ob = display->output_bytes;
+   png_alloc_size_t ob = display->output_bytes;
 
    /* Check for overflow; this should never happen: */
    if (size <= ((png_alloc_size_t)-1) - ob)
diff --git a/pngwtran.c b/pngwtran.c
index 3a1e0a2..49a13c1 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,10 +1,10 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -254,8 +254,7 @@
 
          for (i = 0; i < istop; i++, bp++)
          {
-
-            const unsigned int c = i%channels;
+            unsigned int c = i%channels;
             int j;
             unsigned int v, out;
 
@@ -283,7 +282,7 @@
 
          for (bp = row, i = 0; i < istop; i++)
          {
-            const unsigned int c = i%channels;
+            unsigned int c = i%channels;
             int j;
             unsigned int value, v;
 
diff --git a/pngwutil.c b/pngwutil.c
index ab431e7..16345e4 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,10 +1,10 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -1893,16 +1893,16 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 #endif
 
    png_alloc_size_t buf_size;
@@ -2008,16 +2008,16 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 #endif
 
    png_debug(1, "in png_write_finish_row");
@@ -2098,10 +2098,10 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte  png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    png_debug(1, "in png_do_write_interlace");
 
@@ -2276,7 +2276,7 @@
 
 #ifdef PNG_WRITE_FILTER_SUPPORTED
 static size_t /* PRIVATE */
-png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
+png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
     size_t row_bytes, size_t lmins)
 {
    png_bytep rp, dp, lp;
@@ -2315,7 +2315,7 @@
 }
 
 static void /* PRIVATE */
-png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp,
+png_setup_sub_row_only(png_structrp png_ptr, png_uint_32 bpp,
     size_t row_bytes)
 {
    png_bytep rp, dp, lp;
@@ -2380,7 +2380,7 @@
 }
 
 static size_t /* PRIVATE */
-png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
+png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp,
     size_t row_bytes, size_t lmins)
 {
    png_bytep rp, dp, pp, lp;
@@ -2420,7 +2420,7 @@
    return (sum);
 }
 static void /* PRIVATE */
-png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
+png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp,
     size_t row_bytes)
 {
    png_bytep rp, dp, pp, lp;
@@ -2442,7 +2442,7 @@
 }
 
 static size_t /* PRIVATE */
-png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
+png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp,
     size_t row_bytes, size_t lmins)
 {
    png_bytep rp, dp, pp, cp, lp;
@@ -2503,7 +2503,7 @@
    return (sum);
 }
 static void /* PRIVATE */
-png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp,
+png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp,
     size_t row_bytes)
 {
    png_bytep rp, dp, pp, cp, lp;
diff --git a/powerpc/filter_vsx_intrinsics.c b/powerpc/filter_vsx_intrinsics.c
index 39521cf..01cf880 100644
--- a/powerpc/filter_vsx_intrinsics.c
+++ b/powerpc/filter_vsx_intrinsics.c
@@ -1,13 +1,14 @@
 /* filter_vsx_intrinsics.c - PowerPC optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2017 Glenn Randers-Pehrson
  * Written by Vadim Barkov, 2017.
- * Last changed in libpng 1.6.29 [March 16, 2017]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  */
+
 #include <stdio.h>
 #include <stdint.h>
 #include "../pngpriv.h"
@@ -173,7 +174,7 @@
 void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
                                   png_const_bytep prev_row)
 {
-   const png_byte bpp = 4;
+   png_byte bpp = 4;
 
    vector unsigned char rp_vec;
    vector unsigned char part_vec;
@@ -230,7 +231,7 @@
 void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
                                   png_const_bytep prev_row)
 {
-   const png_byte bpp = 3;
+   png_byte bpp = 3;
 
    vector unsigned char rp_vec;
    vector unsigned char part_vec;
@@ -294,7 +295,7 @@
 void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
                                   png_const_bytep prev_row)
 {
-   const png_byte bpp = 4;
+   png_byte bpp = 4;
 
    vector unsigned char rp_vec;
    vector unsigned char pp_vec;
@@ -381,7 +382,7 @@
 void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
                                   png_const_bytep prev_row)
 {
-  const png_byte bpp = 3;
+  png_byte bpp = 3;
 
   vector unsigned char rp_vec;
   vector unsigned char pp_vec;
@@ -499,7 +500,7 @@
 void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
    png_const_bytep prev_row)
 {
-   const png_byte bpp = 4;
+   png_byte bpp = 4;
 
    int a, b, c, pa, pb, pc, p;
    vector unsigned char rp_vec;
@@ -619,7 +620,7 @@
 void png_read_filter_row_paeth3_vsx(png_row_infop row_info, png_bytep row,
    png_const_bytep prev_row)
 {
-  const png_byte bpp = 3;
+  png_byte bpp = 3;
 
   int a, b, c, pa, pb, pc, p;
   vector unsigned char rp_vec;
diff --git a/powerpc/powerpc_init.c b/powerpc/powerpc_init.c
index 0701617..54426c5 100644
--- a/powerpc/powerpc_init.c
+++ b/powerpc/powerpc_init.c
@@ -1,14 +1,15 @@
 
 /* powerpc_init.c - POWERPC optimised filter functions
  *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 2017 Glenn Randers-Pehrson
  * Written by Vadim Barkov, 2017.
- * Last changed in libpng 1.6.29 [March 16, 2017]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  */
+
 /* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
  * called.
  */
diff --git a/projects/vstudio/README.txt b/projects/vstudio/README.txt
index b8b4a3a..e28ec95 100644
--- a/projects/vstudio/README.txt
+++ b/projects/vstudio/README.txt
@@ -1,76 +1,77 @@
+Instructions for building libpng using Microsoft Visual Studio
+==============================================================
 
-VisualStudio instructions
-
-libpng version 1.6.35 - July 15, 2018
-
+Copyright (c) 2018 Cosmin Truta
 Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson
 
 This code is released under the libpng license.
-For conditions of distribution and use, see the disclaimer
-and license in png.h
+For conditions of distribution and use, see the disclaimer and license
+in png.h
 
-This directory  contains support for building libpng under MicroSoft
-VisualStudio 2010.  It may also work under later versions of VisualStudio.
-You should be familiar with VisualStudio before using this directory.
+This directory contains a solution for building libpng under Microsoft
+Visual Studio 2010.  It may also work under later versions of Visual
+Studio.  You should be familiar with Visual Studio before using this
+solution.
 
 Initial preparations
-====================
-You must enter some information in zlib.props before attempting to build
-with this 'solution'.  Please read and edit zlib.props first.  You will
-probably not be familiar with the contents of zlib.props - do not worry,
-it is mostly harmless.
+--------------------
+You must enter some information in zlib.props before attempting to
+build with this 'solution'.  Please read and edit zlib.props first.
+You will probably not be familiar with the contents of zlib.props -
+do not worry, it is mostly harmless.
 
 This is all you need to do to build the 'release' and 'release library'
 configurations.
 
 Debugging
-=========
+---------
 The release configurations default to /Ox optimization.  Full debugging
-information is produced (in the .pdb), but if you encounter a problem the
-optimization may make it difficult to debug.  Simply rebuild with a lower
-optimization level (e.g. /Od.)
+information is produced (in the .pdb), but if you encounter a problem
+the optimization may make it difficult to debug.  Simply rebuild with a
+lower optimization level (e.g. /Od.)
 
 Linking your application
-========================
-Normally you should link against the 'release' configuration.  This builds a
-DLL for libpng with the default runtime options used by Visual Studio 2010.
-In particular the runtime library is the "MultiThreaded DLL" version.
-If you use Visual Studio defaults to build your application you will have no
-problems.
+------------------------
+Normally you should link against the 'release' configuration.  This
+builds a DLL for libpng with the default runtime options used by Visual
+Studio.  In particular the runtime library is the "MultiThreaded DLL"
+version.  If you use Visual Studio defaults to build your application,
+you should have no problems.
 
-If you don't use the Visual Studio defaults your application must still be
-built with the default runtime option (/MD).  If, for some reason, it is not
-then your application will crash inside libpng16.dll as soon as libpng
-tries to read from a file handle you pass in.
+If you don't use the Visual Studio defaults your application must still
+be built with the default runtime option (/MD).  If, for some reason,
+it is not then your application will crash inside libpng16.dll as soon
+as libpng tries to read from a file handle you pass in.
 
-If you do not want to use the DLL, for example for a very small application,
-the 'release library' configuration may be more appropriate.  This is built
-with a non-standard runtime library - the "MultiThreaded" version.  When you
-build your application it must be compiled with this option (/MT), otherwise
-it will not build (if you are lucky) or crash (if you are not.) See the
-WARNING file that is distributed along with this readme.txt.
+If you do not want to use the DLL, and prefer static linking instead,
+you may choose the 'release library' configuration.  This is built with
+a non-standard runtime library - the "MultiThreaded" version.  When you
+build your application, it must be compiled with this option (/MT),
+otherwise it will not build (if you are lucky) or it will crash (if you
+are not.) See the WARNING file that is distributed with this README.
 
 Stop reading here
-=================
+-----------------
 You have enough information to build a working application.
 
 Debug versions have limited support
-===================================
-This solution includes limited support for debug versions of libpng.  You
-do not need these unless your own solution itself uses debug builds (it is
-far more effective to debug on the release builds, there is no point building
-a special debug build unless you have heap corruption problems that you can't
-track down.)
+-----------------------------------
+This solution includes limited support for debug versions of libpng.
+You do not need these unless your own solution itself uses debug builds
+(it is far more effective to debug on the release builds, there is no
+point building a special debug build unless you have heap corruption
+problems that you can't track down.)
 
-The debug build of libpng is minimally supported.  Support for debug builds of
-zlib is also minimal.  You really don't want to do this.
+The debug build of libpng is minimally supported.  Support for debug
+builds of zlib is also minimal.  Please keep this in mind, if you want
+to use it.
 
 WARNING
-=======
-Libpng 1.6.x does not use the default run-time library when building static
-library builds of libpng; instead of the shared DLL runtime it uses a static
-runtime.  If you need to change this make sure to change the setting on all the
-relevant projects:
+-------
+Libpng 1.6.x does not use the default run-time library when building
+static library builds of libpng; instead of the shared DLL runtime, it
+uses a static runtime.  If you need to change this, make sure to change
+the setting on all the relevant projects:
 
     libpng
     zlib
@@ -82,16 +83,5 @@
     DLL         /MD            /MDd
     Library     /MT            /MTd
 
-NOTICE that libpng 1.5.x erroneously used /MD for Debug DLL builds; if you used
-the debug builds in your app and you changed your app to use /MD you will need
-to change it back to /MDd for libpng 1.6.0 and later.
-
-The Visual Studio 2010 defaults for a Win32 DLL or Static Library project are
-as follows:
-
-                     Release     Debug
-    DLL               /MD         /MDd
-    Static Library    /MD         /MDd
-
-Also, be sure to build libpng, zlib, and your project all for the same
+Also, be sure to build libpng, zlib, and your project, all for the same
 platform (e.g., 32-bit or 64-bit).
diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props
index 5bf6e28..8786279 100644
--- a/projects/vstudio/zlib.props
+++ b/projects/vstudio/zlib.props
@@ -2,16 +2,15 @@
 <!--
  * zlib.props - location of zlib source
  *
- * libpng version 1.6.35 - July 15, 2018
- *
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
 
- * You must edit this file to record the location of the zlib
- * source code.
+ * You may need to edit this file in order to update the location
+ * of the zlib source code.
  -->
 
 <Project ToolsVersion="4.0"
@@ -32,7 +31,7 @@
 	 versions do not match.  The zlib version used in this build is recorded
 	 below:
      -->
-    <ZLibSrcDir>..\..\..\..\zlib-1.2.8</ZLibSrcDir>
+    <ZLibSrcDir>..\..\..\..\zlib</ZLibSrcDir>
 
     <!-- The following line allows compilation for an ARM target with Visual
          Studio 2012.  Notice that this is not supported by the Visual Studio
diff --git a/scripts/README.txt b/scripts/README.txt
index 4faf115..3d911ef 100644
--- a/scripts/README.txt
+++ b/scripts/README.txt
@@ -1,24 +1,20 @@
 
-Makefiles for libpng version 1.6.35 - July 15, 2018
+Makefiles for libpng
 
-pnglibconf.h.prebuilt       =>  Stores configuration settings
+pnglibconf.h.prebuilt  =>  Configuration settings
  makefile.linux    =>  Linux/ELF makefile
-                       (gcc, creates libpng16.so.16.1.6.35)
+                       (gcc, creates shared libpng16.so.16.1.6.*)
  makefile.linux-opt=>  Linux/ELF makefile with hardware optimizations on
-                       (gcc, creates libpng16.so.16.1.6.35)
+                       (gcc, creates shared libpng16.so.16.1.6.*)
  makefile.gcc      =>  Generic makefile (gcc, creates static libpng.a)
- makefile.knr      =>  Archaic UNIX Makefile that converts files with
-                       ansi2knr (Requires ansi2knr.c from
-                       ftp://ftp.cs.wisc.edu/ghost)
  makefile.acorn    =>  Acorn makefile
  makefile.aix      =>  AIX/gcc makefile
  makefile.amiga    =>  Amiga makefile
  makefile.atari    =>  Atari makefile
  makefile.bc32     =>  32-bit Borland C++ (all modules compiled in C mode)
- makefile.beos     =>  beos makefile
- makefile.bor      =>  Borland makefile (uses bcc)
+ makefile.beos     =>  BeOS makefile
  makefile.cegcc    =>  minge32ce for Windows CE makefile
- makefile.darwin   =>  Darwin makefile, can use on MacosX
+ makefile.darwin   =>  Darwin makefile, for macOS (formerly Mac OS X)
  makefile.dec      =>  DEC Alpha UNIX makefile
  makefile.dj2      =>  DJGPP 2 makefile
  makefile.freebsd  =>  FreeBSD makefile
@@ -29,23 +25,20 @@
  makefile.ibmc     =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
  makefile.intel    =>  Intel C/C++ version 4.0 and later
  makefile.mips     =>  MIPS makefile
- makefile.msc      =>  Microsoft C makefile
- makefile.netbsd   =>  NetBSD/cc makefile, makes libpng.so.
+ makefile.netbsd   =>  NetBSD/cc makefile, makes shared libpng.so
  makefile.openbsd  =>  OpenBSD makefile
- makefile.os2      =>  OS/2 Makefile (gcc and emx, requires libpng.def)
- makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
- makefile.sggcc    =>  Silicon Graphics (gcc,
-                       creates libpng16.so.16.1.6.35)
+ makefile.sco      =>  SCO OSr5 ELF and Unixware 7 with Native cc
+ makefile.sggcc    =>  Silicon Graphics makefile
+                       (gcc, creates shared libpng16.so.16.1.6.*)
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.solaris  =>  Solaris 2.X makefile (gcc,
-                       creates libpng16.so.16.1.6.35)
- makefile.so9      =>  Solaris 9 makefile (gcc,
-                       creates libpng16.so.16.1.6.35)
+ makefile.solaris  =>  Solaris 2.X makefile
+                       (gcc, creates shared libpng16.so.16.1.6.*)
+ makefile.so9      =>  Solaris 9 makefile
+                       (gcc, creates shared libpng16.so.16.1.6.*)
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
  makefile.sunos    =>  Sun makefile
  makefile.32sunu   =>  Sun Ultra 32-bit makefile
  makefile.64sunu   =>  Sun Ultra 64-bit makefile
- makefile.tc3      =>  Turbo C 3.0 makefile
  makefile.vcwin32  =>  makefile for Microsoft Visual C++ 4.0 and later
  makevms.com       =>  VMS build script
  smakefile.ppc     =>  AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
@@ -57,20 +50,20 @@
  libpng-config-body.in => used by several makefiles to create libpng-config
  libpng-config-head.in => used by several makefiles to create libpng-config
  libpng.pc.in      =>  Used by several makefiles to create libpng.pc
- pngwin.rc         =>  Used by the visualc71 project.
+ pngwin.rc         =>  Used by the visualc71 project
  pngwin.def        =>  Used by makefile.os2
  pngwin.dfn        =>  Used to maintain pngwin.def
  SCOPTIONS.ppc     =>  Used with smakefile.ppc
 
- checksym.awk       =>  Used for maintaining pnglibconf.h
- def.dfn            =>  Used for maintaining pnglibconf.h
- options.awk        =>  Used for maintaining pnglibconf.h
- pnglibconf.dfa     =>  Used for maintaining pnglibconf.h
- pnglibconf.mak     =>  Used for maintaining pnglibconf.h
- sym.dfn            =>  Used for symbol versioning
- symbols.def        =>  Used for symbol versioning
- symbols.dfn        =>  Used for symbol versioning
- vers.dfn           =>  Used for symbol versioning
+ checksym.awk      =>  Used for maintaining pnglibconf.h
+ def.dfn           =>  Used for maintaining pnglibconf.h
+ options.awk       =>  Used for maintaining pnglibconf.h
+ pnglibconf.dfa    =>  Used for maintaining pnglibconf.h
+ pnglibconf.mak    =>  Used for maintaining pnglibconf.h
+ sym.dfn           =>  Used for symbol versioning
+ symbols.def       =>  Used for symbol versioning
+ symbols.dfn       =>  Used for symbol versioning
+ vers.dfn          =>  Used for symbol versioning
 
  libtool.m4        =>  Used by autoconf tools
  ltoptions.m4      =>  Used by autoconf tools
diff --git a/scripts/def.c b/scripts/def.c
deleted file mode 100644
index 5a15905..0000000
--- a/scripts/def.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* def.c - define format of libpng.def
- *
- * Last changed in libpng version 1.6.16 [December 22, 2014]
- * Copyright (c) 2011-2014 Glenn Randers-Pehrson
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-/* Write the export file header: */
-PNG_DFN ";--------------------------------------------------------------"
-PNG_DFN "; LIBPNG module definition file for OS/2"
-PNG_DFN ";--------------------------------------------------------------"
-PNG_DFN ""
-PNG_DFN "; If you give the library an explicit name one or other files"
-PNG_DFN "; may need modifying to support the new name on one or more"
-PNG_DFN "; systems."
-PNG_DFN "LIBRARY"
-PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
-PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
-PNG_DFN ""
-PNG_DFN "EXPORTS"
-PNG_DFN ";Version 1.6.35"
-
-#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
-        PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
-
-#include "../png.h"
diff --git a/scripts/descrip.mms b/scripts/descrip.mms
index 463c425..a3aefbf 100644
--- a/scripts/descrip.mms
+++ b/scripts/descrip.mms
@@ -16,10 +16,10 @@
 CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF)
 
 all : pngtest.exe libpng.olb
-		@ write sys$output " pngtest available"
+	@ write sys$output " pngtest available"
 
 libpng.olb : libpng.olb($(OBJS))
-	@ write sys$output " Libpng available"
+	@ write sys$output " libpng available"
 
 
 pngtest.exe : pngtest.obj libpng.olb
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
index c601ccd..985271a 100644
--- a/scripts/libpng-config-head.in
+++ b/scripts/libpng-config-head.in
@@ -11,7 +11,7 @@
 
 # Modeled after libxml-config.
 
-version=1.6.35
+version=1.6.36
 prefix=""
 libdir=""
 libs=""
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index 985db64..2f74923 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -5,6 +5,6 @@
 
 Name: libpng
 Description: Loads and saves PNG files
-Version: 1.6.35
+Version: 1.6.36
 Libs: -L${libdir} -lpng16
 Cflags: -I${includedir}
diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu
index 7d4b7c5..c849ecd 100644
--- a/scripts/makefile.32sunu
+++ b/scripts/makefile.32sunu
@@ -219,7 +219,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu
index 341fce9..8880fa9 100644
--- a/scripts/makefile.64sunu
+++ b/scripts/makefile.64sunu
@@ -219,7 +219,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.bor b/scripts/makefile.bor
deleted file mode 100644
index 6693772..0000000
--- a/scripts/makefile.bor
+++ /dev/null
@@ -1,170 +0,0 @@
-# Makefile for libpng
-# 16-bit Borland C++ (Note: All modules are compiled in C mode)
-# To build the library, do:
-#       "make -fmakefile.bor -DMODEL=c"
-# or:   "make -fmakefile.bor -DMODEL=l"
-#
-# ------------ Borland C++ ------------
-
-### Absolutely necessary for this makefile to work
-.AUTODEPEND
-
-## Where zlib.h, zconf.h and zlib_MODEL.lib are
-ZLIB_DIR=..\zlib
-
-## Compiler, linker, librarian and other tools
-CC=bcc
-LD=bcc
-LIB=tlib
-CP=copy
-
-!ifndef MODEL
-MODEL=l
-!endif
-
-MODEL_ARG=-m$(MODEL)
-
-#TARGET_CPU=3
-# 2 = 286, 3 = 386, etc.
-!ifndef TARGET_CPU
-TARGET_CPU=2
-!endif
-
-# Use this if you don't want Borland's fancy exception handling
-# (for Borland C++ 4.0 or later)
-#NOEHLIB=noeh$(MODEL).lib
-
-!ifdef DEBUG
-CDEBUG=-v
-LDEBUG=-v
-!else
-CDEBUG=
-LDEBUG=
-!endif
-
-# STACKOFLOW=1
-!ifdef STACKOFLOW
-CDEBUG=$(CDEBUG) -N
-LDEBUG=$(LDEBUG) -N
-!endif
-
-# -X- turn on dependency generation in the object file
-# -w  set all warnings on
-# -O2 optimize for speed
-# -Z  global optimization
-CPPFLAGS=-I$(ZLIB_DIR)
-CFLAGS=-O2 -Z -X- -w -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG)
-
-# -M  generate map file
-LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG)
-
-# Pre-built configuration
-# See scripts\pnglibconf.mak for more options
-!ifndef PNGLIBCONF_H_PREBUILT
-PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
-!endif
-
-## Variables
-
-OBJS = \
-	png.obj \
-	pngerror.obj \
-	pngget.obj \
-	pngmem.obj \
-	pngpread.obj \
-	pngread.obj \
-	pngrio.obj \
-	pngrtran.obj \
-	pngrutil.obj \
-	pngset.obj \
-	pngtrans.obj \
-	pngwio.obj \
-	pngwrite.obj \
-	pngwtran.obj \
-	pngwutil.obj
-
-LIBOBJS = \
-	+png.obj \
-	+pngerror.obj \
-	+pngget.obj \
-	+pngmem.obj \
-	+pngpread.obj \
-	+pngread.obj \
-	+pngrio.obj \
-	+pngrtran.obj \
-	+pngrutil.obj \
-	+pngset.obj \
-	+pngtrans.obj \
-	+pngwio.obj \
-	+pngwrite.obj \
-	+pngwtran.obj \
-	+pngwutil.obj
-
-LIBNAME=libpng$(MODEL).lib
-
-## Implicit rules
-
-# Braces let make "batch" calls to the compiler,
-# 2 calls instead of 12; space is important.
-.c.obj:
-	$(CC) $(CPPFLAGS) $(CFLAGS) -c {$*.c }
-
-.c.exe:
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $*.c \
-	  $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
-
-## Major targets
-
-all: libpng pngtest
-
-# try !include scripts\pnglibconf.mak for more options
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-	$(CP) $(PNGLIBCONF_H_PREBUILT) $@
-
-libpng: $(LIBNAME)
-
-pngtest: pngtest$(MODEL).exe
-
-test: pngtest$(MODEL).exe
-	pngtest$(MODEL)
-
-## Minor Targets
-
-png.obj: png.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngerror.obj: pngerror.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngget.obj: pngget.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngmem.obj: pngmem.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngpread.obj: pngpread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngread.obj: pngread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrio.obj: pngrio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrtran.obj: pngrtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrutil.obj: pngrutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngset.obj: pngset.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngtrans.obj: pngtrans.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwio.obj: pngwio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwrite.obj: pngwrite.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwtran.obj: pngwtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwutil.obj: pngwutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-
-$(LIBNAME): $(OBJS)
-	-del $(LIBNAME)
-	$(LIB) $(LIBNAME) @&&|
-$(LIBOBJS), libpng$(MODEL)
-|
-
-pngtest$(MODEL).obj: pngtest.c png.h pngconf.h pnglibconf.h
-	$(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
-
-pngtest$(MODEL).exe: pngtest$(MODEL).obj
-	$(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
-
-# Clean up anything else you want
-clean:
-	-del pnglibconf.h
-	-del *.obj
-	-del *.exe
-	-del *.lib
-	-del *.lst
-	-del *.map
-
-# End of makefile for libpng
diff --git a/scripts/makefile.cegcc b/scripts/makefile.cegcc
index 31d2078..60fb113 100644
--- a/scripts/makefile.cegcc
+++ b/scripts/makefile.cegcc
@@ -23,7 +23,7 @@
 
 VERMAJ = 1
 VERMIN = 6
-VERMIC = 35
+VERMIC = 36
 VER = $(VERMAJ).$(VERMIN).$(VERMIC)
 NAME = libpng
 PACKAGE = $(NAME)-$(VER)
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index be3f92c..33c27cc 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -200,7 +200,7 @@
 	$(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
 	libpng.pc $(LIBNAME).*dylib pngtesti pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.freebsd b/scripts/makefile.freebsd
index cad1a5a..5fec61e 100644
--- a/scripts/makefile.freebsd
+++ b/scripts/makefile.freebsd
@@ -62,7 +62,7 @@
 pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
 	cp $(PNGLIBCONF_H_PREBUILT) $@
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.hp64 b/scripts/makefile.hp64
index 5948be8..4421e78 100644
--- a/scripts/makefile.hp64
+++ b/scripts/makefile.hp64
@@ -1,7 +1,7 @@
 # makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
 # Copyright (C) 1999-2002, 2006, 2009, 2010-2014 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42
-# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
+# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
 #
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -206,7 +206,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 5c8791b..efef1f3 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -209,7 +209,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index b07612d..27b312a 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -1,7 +1,7 @@
 # makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
 # Copyright (C) 1999-2002, 2006, 2010-2014 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42
-# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
+# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
 #
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -204,7 +204,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.knr b/scripts/makefile.knr
deleted file mode 100644
index d8de064..0000000
--- a/scripts/makefile.knr
+++ /dev/null
@@ -1,116 +0,0 @@
-# makefile for libpng
-# Copyright (C) 2002, 2006, 2009, 2014 Glenn Randers-Pehrson
-# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
-#
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
-#
-# This makefile requires the file ansi2knr.c, which you can get
-# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/
-# If you have libjpeg, you probably already have ansi2knr.c in the jpeg
-# source distribution.
-
-# where make install puts libpng.a and png.h
-prefix=/usr/local
-INCPATH=$(prefix)/include
-LIBPATH=$(prefix)/lib
-
-# override DESTDIR= on the make install command line to easily support
-# installing into a temporary location.  Example:
-#
-#    make install DESTDIR=/tmp/build/libpng
-#
-# If you're going to install into a temporary location
-# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
-# you execute make install.
-DESTDIR=
-
-CC = cc
-CPPFLAGS = -I../zlib
-CFLAGS = -O
-LDFLAGS = -L. -L../zlib/ -lpng -lz -lm
-# flags for ansi2knr
-ANSI2KNRFLAGS=
-
-RANLIB = ranlib
-#RANLIB = echo
-
-CP = cp
-RM_F = rm -f
-
-# Pre-built configuration
-# See scripts/pnglibconf.mak for more options
-PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
-
-OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
-	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
-	pngwtran.o pngmem.o pngerror.o pngpread.o
-
-all: ansi2knr libpng.a pngtest
-
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-	$(CP) $(PNGLIBCONF_H_PREBUILT) $@
-
-# general rule to allow ansi2knr to work
-.c.o:
-	./ansi2knr $*.c T$*.c
-	$(CC) $(CPPFLAGS) $(CFLAGS) -c T$*.c
-	rm -f T$*.c $*.o
-	mv T$*.o $*.o
-
-ansi2knr: ansi2knr.c
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c
-
-libpng.a: ansi2knr $(OBJS)
-	ar rc $@  $(OBJS)
-	$(RANLIB) $@
-
-pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
-
-test: pngtest
-	./pngtest
-
-install: libpng.a png.h pngconf.h pnglibconf.h
-	-@mkdir $(DESTDIR)$(INCPATH)
-	-@mkdir $(DESTDIR)$(INCPATH)/libpng
-	-@mkdir $(DESTDIR)$(LIBPATH)
-	-@rm -f $(DESTDIR)$(INCPATH)/png.h
-	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
-	cp png.h $(DESTDIR)$(INCPATH)/libpng
-	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
-	cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng
-	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
-	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
-	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h
-	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
-	cp libpng.a $(DESTDIR)$(LIBPATH)
-	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
-
-clean:
-	$(RM_F) *.o libpng.a pngtest pngout.png ansi2knr pnglibconf.h
-
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
-writelock:
-	chmod a-w *.[ch35] $(DOCS) scripts/*
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-
-pngtest.o: png.h pngconf.h pnglibconf.h
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 5568912..32eb859 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -10,7 +10,7 @@
 # Library name:
 LIBNAME = libpng16
 PNGMAJ = 16
-RELEASE = 35
+RELEASE = 36
 
 # Shared library names:
 LIBSO=$(LIBNAME).so
@@ -50,8 +50,7 @@
 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
 
 CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
-CFLAGS= -W -Wall -O3 -funroll-loops \
-	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
+CFLAGS=-W -Wall -O3 -funroll-loops $(ALIGN) # $(WARNMORE) -g
 
 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
@@ -222,7 +221,7 @@
 	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.linux-opt b/scripts/makefile.linux-opt
index d4a5e3b..76f6d1a 100644
--- a/scripts/makefile.linux-opt
+++ b/scripts/makefile.linux-opt
@@ -10,7 +10,7 @@
 # Library name:
 LIBNAME = libpng16
 PNGMAJ = 16
-RELEASE = 35
+RELEASE = 36
 
 # Shared library names:
 LIBSO=$(LIBNAME).so
@@ -232,7 +232,7 @@
 	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.mips b/scripts/makefile.mips
index 5633608..0357ae8 100644
--- a/scripts/makefile.mips
+++ b/scripts/makefile.mips
@@ -78,7 +78,7 @@
 clean:
 	rm -f *.o libpng.a pngtest pngout.png pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.msc b/scripts/makefile.msc
deleted file mode 100644
index 539d62e..0000000
--- a/scripts/makefile.msc
+++ /dev/null
@@ -1,100 +0,0 @@
-# makefile for libpng
-# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
-# Copyright (C) 2006, 2009, 2014 Glenn Randers-Pehrson
-#
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
-#
-# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
-
-# -------- Microsoft C 5.1 and later, does not use assembler code --------
-MODEL=L
-CPPFLAGS=-I..\zlib
-CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL)
-#-Ox generates bad code with MSC 5.1
-CC=cl
-LD=link
-LDFLAGS=/e/st:0x1500/noe
-CP=copy
-O=.obj
-
-# Pre-built configuration
-# See scripts\pnglibconf.mak for more options
-PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
-
-#uncomment next to put error messages in a file
-ERRFILE= >> pngerrs
-
-# variables
-OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
-OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
-OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
-
-all: libpng.lib
-
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-	$(CP) $(PNGLIBCONF_H_PREBUILT) $@
-
-png$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
-	del libpng.lib
-	lib libpng $(OBJS1);
-	lib libpng $(OBJS2);
-	lib libpng $(OBJS3);
-
-pngtest$(O): png.h pngconf.h pnglibconf.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
-
-pngtest.exe: pngtest.obj libpng.lib
-	$(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ;
-
-test: pngtest.exe
-	pngtest
-
-# End of makefile for libpng
-
diff --git a/scripts/makefile.msys b/scripts/makefile.msys
index 209ad4f..2af7a6a 100644
--- a/scripts/makefile.msys
+++ b/scripts/makefile.msys
@@ -18,7 +18,7 @@
 # Library name:
 LIBNAME = libpng16
 PNGMAJ = 16
-RELEASE = 35
+RELEASE = 36
 
 # Shared library names:
 LIBSO=$(LIBNAME).dll
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
index 8a49035..d0a6a37 100644
--- a/scripts/makefile.ne12bsd
+++ b/scripts/makefile.ne12bsd
@@ -17,7 +17,7 @@
 
 LIB=	png16
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.6.35
+SHLIB_MINOR=	1.6.36
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index b1e8e95..589c1f8 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -17,7 +17,7 @@
 
 LIB=	png
 SHLIB_MAJOR=	16
-SHLIB_MINOR=	1.6.35
+SHLIB_MINOR=	1.6.36
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.openbsd b/scripts/makefile.openbsd
index 5edac0f..4057b2e 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -11,7 +11,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	16
-SHLIB_MINOR=	1.6.35
+SHLIB_MINOR=	1.6.36
 
 LIB=	png
 SRCS=	png.c pngerror.c pngget.c pngmem.c pngpread.c \
@@ -28,7 +28,7 @@
 CLEANFILES+= pngtest.o pngtest pnglibconf.h
 
 MAN=	libpng.3 libpngpf.3 png.5
-DOCS=	ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO \
+DOCS=	ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO \
 	libpng-manual.txt
 
 # Pre-built configuration
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 67d84aa..01d7eaa 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -201,7 +201,7 @@
 	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
 	pnglibconf.h libpng.pc
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index a0d051d..82efe7a 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -211,7 +211,7 @@
 	$(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc \
 	so_locations libpng-config $(LIBSO) $(LIBSOMAJ)* pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index 7df0902..5d9c23f 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -212,7 +212,7 @@
 	$(LIBSO) $(LIBSOMAJ)* \
 	so_locations pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index ba9308c..93166f3 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -222,7 +222,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 8a450d3..f6d7b58 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -44,8 +44,7 @@
 	-Wmissing-declarations -Wtraditional -Wcast-align \
 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
 CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
-CFLAGS= -W -Wall -O \
-	# $(WARNMORE) -g -DPNG_DEBUG=5
+CFLAGS=-W -Wall -O # $(WARNMORE) -g
 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
 
 INCPATH=$(prefix)/include
@@ -219,7 +218,7 @@
 	libpng-config $(LIBSO) $(LIBSOMAJ)* \
 	libpng.pc pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.solaris-x86 b/scripts/makefile.solaris-x86
deleted file mode 100644
index 2ee3c14..0000000
--- a/scripts/makefile.solaris-x86
+++ /dev/null
@@ -1,243 +0,0 @@
-# makefile for libpng on Solaris 2.x with gcc
-# Copyright (C) 2004, 2006-2008, 2010-2014 Glenn Randers-Pehrson
-# Contributed by William L. Sebok, based on makefile.linux
-# Copyright (C) 1998 Greg Roelofs
-# Copyright (C) 1996, 1997 Andreas Dilger
-
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
-
-# Library name:
-LIBNAME = libpng16
-PNGMAJ = 16
-
-# Shared library names:
-LIBSO=$(LIBNAME).so
-LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
-LIBSOREL=$(LIBSOMAJ).$(RELEASE)
-OLDSO=libpng.so
-
-# Utilities:
-AR_RC=ar rc
-CC=gcc
-MKDIR_P=mkdir -p
-LN_SF=ln -f -s
-RANLIB=echo
-CP=cp
-RM_F=/bin/rm -f
-
-# Where make install puts libpng.a, libpng16.so*, and png.h
-prefix=/usr/local
-exec_prefix=$(prefix)
-
-# Where the zlib library and include files are located
-# Changing these to ../zlib poses a security risk.  If you want
-# to have zlib in an adjacent directory, specify the full path instead of "..".
-#ZLIBLIB=../zlib
-#ZLIBINC=../zlib
-
-ZLIBLIB=/usr/local/lib
-ZLIBINC=/usr/local/include
-
-WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-	-Wmissing-declarations -Wtraditional -Wcast-align \
-	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
-CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
-CFLAGS=-W -Wall -O # $(WARNMORE) -g
-LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
-
-INCPATH=$(prefix)/include
-LIBPATH=$(exec_prefix)/lib
-MANPATH=$(prefix)/man
-BINPATH=$(exec_prefix)/bin
-
-# override DESTDIR= on the make install command line to easily support
-# installing into a temporary location.  Example:
-#
-#    make install DESTDIR=/tmp/build/libpng
-#
-# If you're going to install into a temporary location
-# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
-# you execute make install.
-DESTDIR=
-
-DB=$(DESTDIR)$(BINPATH)
-DI=$(DESTDIR)$(INCPATH)
-DL=$(DESTDIR)$(LIBPATH)
-DM=$(DESTDIR)$(MANPATH)
-
-# Pre-built configuration
-# See scripts/pnglibconf.mak for more options
-PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
-
-OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
-	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
-	pngwtran.o pngmem.o pngerror.o pngpread.o
-
-OBJSDLL = $(OBJS:.o=.pic.o)
-
-.SUFFIXES:      .c .o .pic.o
-
-.c.o:
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
-
-.c.pic.o:
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
-
-all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
-
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-	$(CP) $(PNGLIBCONF_H_PREBUILT) $@
-
-libpng.a: $(OBJS)
-	$(AR_RC) $@ $(OBJS)
-	$(RANLIB) $@
-
-libpng.pc:
-	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
-	-e s!@exec_prefix@!$(exec_prefix)! \
-	-e s!@libdir@!$(LIBPATH)! \
-	-e s!@includedir@!$(INCPATH)! \
-	-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
-
-libpng-config:
-	( cat scripts/libpng-config-head.in; \
-	echo prefix=\"$(prefix)\"; \
-	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
-	echo cppflags=\""; \
-	echo L_opts=\"-L$(LIBPATH)\"; \
-	echo R_opts=\"-R$(LIBPATH)\"; \
-	echo libs=\"-lpng16 -lz -lm\"; \
-	cat scripts/libpng-config-body.in ) > libpng-config
-	chmod +x libpng-config
-
-$(LIBSO): $(LIBSOMAJ)
-	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
-
-$(LIBSOMAJ): $(OBJSDLL)
-	@case "`type ld`" in *ucb*) \
-	echo; \
-	echo '## WARNING:'; \
-	echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \
-	echo '## and /usr/ucb/ld.  If they do, you need to adjust your PATH'; \
-	echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \
-	echo '## The environment variable LD_LIBRARY_PATH should not be set'; \
-	echo '## at all.  If it is, things are likely to break because of'; \
-	echo '## the libucb dependency that is created.'; \
-	echo; \
-	;; \
-	esac
-	$(LD) -G -h $(LIBSOMAJ) \
-	 -o $(LIBSOMAJ) $(OBJSDLL)
-
-pngtest: pngtest.o $(LIBSO)
-	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
-
-test: pngtest
-	./pngtest
-
-install-headers: png.h pngconf.h pnglibconf.h
-	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
-	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
-	cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
-	-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
-	-@$(RM_F) $(DI)/libpng
-	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
-
-install-static: install-headers libpng.a
-	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
-	cp libpng.a $(DL)/$(LIBNAME).a
-	chmod 644 $(DL)/$(LIBNAME).a
-	-@$(RM_F) $(DL)/libpng.a
-	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
-
-install-shared: install-headers $(LIBSOMAJ) libpng.pc
-	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
-	-@$(RM_F) $(DL)/$(LIBSO)
-	-@$(RM_F) $(DL)/$(LIBSOREL)
-	-@$(RM_F) $(DL)/$(OLDSO)
-	cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
-	chmod 755 $(DL)/$(LIBSOREL)
-	(cd $(DL); \
-	$(LN_SF) $(LIBSOREL) $(LIBSO); \
-	$(LN_SF) $(LIBSO) $(OLDSO))
-	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
-	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
-	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
-	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
-	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
-	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
-
-install-man: libpng.3 libpngpf.3 png.5
-	-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
-	-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
-	-@$(RM_F) $(DM)/man3/libpng.3
-	-@$(RM_F) $(DM)/man3/libpngpf.3
-	cp libpng.3 $(DM)/man3
-	cp libpngpf.3 $(DM)/man3
-	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
-	-@$(RM_F) $(DM)/man5/png.5
-	cp png.5 $(DM)/man5
-
-install-config: libpng-config
-	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
-	-@$(RM_F) $(DB)/libpng-config
-	-@$(RM_F) $(DB)/$(LIBNAME)-config
-	cp libpng-config $(DB)/$(LIBNAME)-config
-	chmod 755 $(DB)/$(LIBNAME)-config
-	(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
-
-install: install-static install-shared install-man install-config
-
-# If you installed in $(DESTDIR), test-installed won't work until you
-# move the library to its final location.  Use test-dd to test it
-# before then.
-
-test-dd:
-	echo
-	echo Testing installed dynamic shared library in $(DL).
-	$(CC) -I$(DI) $(CPPFLAGS) \
-	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
-	   -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \
-	   -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL)
-	./pngtestd pngtest.png
-
-test-installed:
-	echo
-	echo Testing installed dynamic shared library.
-	$(CC) $(CPPFLAGS) \
-	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
-	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \
-	   -L$(ZLIBLIB) -R$(ZLIBLIB)
-	./pngtesti pngtest.png
-
-clean:
-	$(RM_F) *.o libpng.a pngtest pngtesti pngout.png \
-	libpng-config $(LIBSO) $(LIBSOMAJ)* \
-	libpng.pc pnglibconf.h
-
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
-writelock:
-	chmod a-w *.[ch35] $(DOCS) scripts/*
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-
-pngtest.o: png.h pngconf.h pnglibconf.h
diff --git a/scripts/makefile.std b/scripts/makefile.std
index ee6a868..2f4871d 100644
--- a/scripts/makefile.std
+++ b/scripts/makefile.std
@@ -109,7 +109,7 @@
 	$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h pnglibconf.c \
 	pnglibconf.out
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
@@ -122,6 +122,7 @@
 pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
@@ -129,6 +130,5 @@
 pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
 
 pngtest.o: png.h pngconf.h pnglibconf.h
diff --git a/scripts/makefile.sunos b/scripts/makefile.sunos
index efe308c..9a0e28e 100644
--- a/scripts/makefile.sunos
+++ b/scripts/makefile.sunos
@@ -90,7 +90,7 @@
 clean:
 	$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h
 
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
diff --git a/scripts/makefile.tc3 b/scripts/makefile.tc3
deleted file mode 100644
index 1d01502..0000000
--- a/scripts/makefile.tc3
+++ /dev/null
@@ -1,100 +0,0 @@
-# Makefile for libpng
-# TurboC/C++ (Note: All modules are compiled in C mode)
-
-# To use, do "make -fmakefile.tc3"
-
-# ----- Turbo C++ 3.0 -----
-
-MODEL=l
-CPPFLAGS=-I..\zlib
-CFLAGS=-O2 -Z -m$(MODEL)
-CC=tcc
-LD=tcc
-LIB=tlib
-LDFLAGS=-m$(MODEL) -L..\zlib
-CP=copy
-
-# Pre-built configuration
-# See scripts\pnglibconf.mak for more options
-!ifndef PNGLIBCONF_H_PREBUILT
-PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
-!endif
-
-O=.obj
-E=.exe
-
-# variables
-OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
-OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
-OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
-OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O)
-OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O)
-OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
-
-all: libpng$(MODEL).lib pngtest$(E)
-
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-	$(CP) $(PNGLIBCONF_H_PREBUILT) $@
-
-pngtest: pngtest$(E)
-
-test: pngtest$(E)
-	pngtest$(E)
-
-png$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-		  $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngtest$(O): png.h pngconf.h pnglibconf.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
-
-libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3)
-	$(LIB) libpng$(MODEL) +$(OBJSL1)
-	$(LIB) libpng$(MODEL) +$(OBJSL2)
-	$(LIB) libpng$(MODEL) +$(OBJSL3)
-
-pngtest$(E): pngtest$(O) libpng$(MODEL).lib
-	$(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib
-
-# End of makefile for libpng
diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa
index b298a72..15bd08e 100644
--- a/scripts/pnglibconf.dfa
+++ b/scripts/pnglibconf.dfa
@@ -8,7 +8,8 @@
 com
 version
 com
-com Copyright (c) 1998-2017 Glenn Randers-Pehrson
+com Copyright (c) 2018 Cosmin Truta
+com Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
 com
 com This code is released under the libpng license.
 com For conditions of distribution and use, see the disclaimer
diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt
index 00acecc..00340c6 100644
--- a/scripts/pnglibconf.h.prebuilt
+++ b/scripts/pnglibconf.h.prebuilt
@@ -1,10 +1,9 @@
-/* libpng 1.6.35 STANDARD API DEFINITION */
-
 /* pnglibconf.h - library build configuration */
 
-/* Libpng version 1.6.35 - July 15, 2018 */
+/* libpng version 1.6.36 */
 
-/* Copyright (c) 1998-2018 Glenn Randers-Pehrson */
+/* Copyright (c) 2018 Cosmin Truta */
+/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
 
 /* This code is released under the libpng license. */
 /* For conditions of distribution and use, see the disclaimer */
@@ -20,8 +19,6 @@
 #define PNG_ALIGNED_MEMORY_SUPPORTED
 /*#undef PNG_ARM_NEON_API_SUPPORTED*/
 /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
-/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
-/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
 #define PNG_BENIGN_ERRORS_SUPPORTED
 #define PNG_BENIGN_READ_ERRORS_SUPPORTED
 /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
@@ -46,6 +43,8 @@
 #define PNG_IO_STATE_SUPPORTED
 #define PNG_MNG_FEATURES_SUPPORTED
 #define PNG_POINTER_INDEXING_SUPPORTED
+/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
+/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
 #define PNG_PROGRESSIVE_READ_SUPPORTED
 #define PNG_READ_16BIT_SUPPORTED
 #define PNG_READ_ALPHA_MODE_SUPPORTED
diff --git a/scripts/symbols.def b/scripts/symbols.def
index a8f7ce2..82494bb 100644
--- a/scripts/symbols.def
+++ b/scripts/symbols.def
@@ -1,4 +1,3 @@
-;Version 1.6.35
 ;--------------------------------------------------------------
 ; LIBPNG symbol list as a Win32 DEF file
 ; Contains all the symbols that can be exported from libpng