From 747e954047eee356d9874376127cd9e7486fdaee Mon Sep 17 00:00:00 2001
From: "FeRD (Frank Dana)" <ferdnyc@gmail.com>
Date: Wed, 21 Apr 2021 13:30:10 -0400
Subject: [PATCH 5/8] find-libpng-header

---
 cmake/OpenCVFindLibsGrfmt.cmake     | 4 ++--
 modules/imgcodecs/src/grfmt_png.cpp | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
index 23a6ca6..a4e3cee 100644
--- a/cmake/OpenCVFindLibsGrfmt.cmake
+++ b/cmake/OpenCVFindLibsGrfmt.cmake
@@ -228,9 +228,9 @@ if(WITH_PNG)
     include(FindPNG)
     if(PNG_FOUND)
       include(CheckIncludeFile)
-      check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
+      check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng16/png.h" HAVE_LIBPNG_PNG_H)
       if(HAVE_LIBPNG_PNG_H)
-        ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
+        ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng16/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
       else()
         ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
       endif()
diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp
index 9e1a2d4..bfb23d1 100644
--- a/modules/imgcodecs/src/grfmt_png.cpp
+++ b/modules/imgcodecs/src/grfmt_png.cpp
@@ -59,7 +59,7 @@
 #endif
 
 #ifdef HAVE_LIBPNG_PNG_H
-#include <libpng/png.h>
+#include <libpng16/png.h>
 #else
 #include <png.h>
 #endif
-- 
2.31.1

