Commit a209aaa7 authored by Kochunas, Brendan M.'s avatar Kochunas, Brendan M. Committed by Henderson, Shane
Browse files

Creates interface to libpng for writing PNG files

Squash branch 'libpng' into 'master'

* Fixes unused parameter compiler warnings in FileType_PNG

* Fixes unused PRIVATE module variable in FileType_PNG

Description:
The module private variable `emesg` was only used when
TPL_ENABLE_PNG was enabled. If Futility was built without
PNG this variable was not used, however, we still output an
exception from the module. This modifies that one exception mesg
to first use `emesg` so that we avoid the "Unused PRIVATE module
variable" warning.

* Completes initial implementation of FileType_PNG

Description:
The initial implementation provides the PNGFileType derived type
with essentially 4 methods for use in client code:
  1. init() Initializes the object
  2. writeImageData() writes a png file from RGB data
  3. readImageData() reads a PNG and makes an array of RGB data
  4. clear() destroys the object

Because it extends BaseFileType it must also provide implementations
for fopen, fclose, and fdelete. All the above are unit tested.

The initial implementation only supports reading/writing 8-bit RGB
png files from From fortran integer arrays.

This has not been tested for portability, but works for gcc-8.5.0
and libpng-1.6.39

VERA-dev Issue # - 5408

* Implements most of FileType_PNG and unit test

Description:
This commit implements most of the capability of FileType_PNG.
It implements everything but readImageData. The implemented routines
are unit tested. Test passes except for testReadImageData because
it is not implemented.

Only tested on gcc-8.5.0. Portability testing will come later.

VERA-dev Issue # - 5408

* Adds a fortran unit test for libpng compatability

Description:
This commit defines a new unit test, testTPLPNGf.
It is equivalent to testTPLPNG.c but written in Fortran.
This test, tests specifically the ability to call the necessary
C interfaces to use libpng directly from Fortran.
It produces an output file outputf.png that should be identical to
output.png

VERA-dev Issue # - 5408

* Creates module and test for PNGFileType class

Description:
This commit creates a couple new files to interface with libpng
and modifies the build system to process these.
Specifically it:
 - Creates the FileType_PNG module for PNGFileType. This inherits
   from the BaseFileType. The class API and C interfaces are preliminary.
   It is a stub class for the moment.
 - Creates a stub unit test for the new class. Test purposely fails.
 - New source file and test always build (regardless of succesffuly finding libpng)

VERA-dev Issue # - 5408

* Adds unit test for testing usability of libpng

Description:
This commit adds one unit test, testTPLPNG, that is a simple
C program that writes a png image using the libpng API.
When this test fails to build or run successfully, it indicates
a problem with the libpng found during configure and how
Futility intends to use libpng.

VERA-dev Issue # - 5408

* Defines a TPL for libpng in build system

Description
This commit does the following:
 - Creates a tribits find module for libpng
 - Adds messaging about libpng during configure
 - Defines preprocessor symbol FUTILITY_HAVE_PNG when tpl is found
 - Defines an optional dependency for Futility on libpng

VERA-dev Issue # - 5408

Adds support for reading/writing png data

https://code.ornl.gov/vera/vera-dev/-/issues/5408

**Developer Checklist:**
- [x] Have you done a self-review after creating the merge request?
- [x] Have you filled in the Merge Request information (title, description) thoroughly?
- [x] Have you updated the relevant tickets (if this MR is linked to any VERA-dev tickets)?
- [x] Have you addressed all suggested feedback and commented on it to let the reviewer know? (Do not resolve discussions that the reviewer started)

**Reviewer Checklist:**
- [x] Have you confirmed all discussions were adequately addressed and resolved them all?
- [x] Does it conform to formatting guidelines?
- [x] Are there adequate and clear comments?
- [x] Is the design clean and sensible?
- [x] Are the changes optimal/efficient?
- [x] Were sufficient DBC checks added?
- [x] Are there unit tests? (if necessary)
- [x] Is the MR description clear, including a link to the VERA-Dev issue if appropriate?

**PSM Checklist**
- [x] Have you confirmed that all discussions were addressed, or that follow-on issues have been created for them?
- [x] Have you confirmed sufficient testing was conducted?
- [x] Does this impact other repositories?
- [x] Does the MR have an adequate description?
- [x] If the MR has multiple commits, did you set the MR to squash merge?

See merge request https://code.ornl.gov/futility/Futility/-/merge_requests/416
parent 61e39f07
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -97,6 +97,19 @@ ELSE()
      ${${PNAME}_ENABLE_HDF5_DEFAULT}
  )

  # Define Package dependent option for HDF5 TPL
  IF(TPL_ENABLE_PNG)
      SET(${PNAME}_ENABLE_PNG_DEFAULT ON)
  ELSE()
      SET(${PNAME}_ENABLE_PNG_DEFAULT OFF)
  ENDIF()
  TRIBITS_ADD_OPTION_AND_DEFINE(
      ${PNAME}_ENABLE_PNG
      HAVE_PNG
      "Enable use of PNG library."
      ${${PNAME}_ENABLE_PNG_DEFAULT}
  )

  # Define Package dependent option for PARDISO TPL
  IF(TPL_ENABLE_PARDISO)
      SET(${PNAME}_ENABLE_PARDISO_DEFAULT ON)
+1 −0
Original line number Diff line number Diff line
@@ -17,4 +17,5 @@ SET(Futility_TPLS_FINDMODS_CLASSIFICATIONS
       PAPI     "${Futility_SOURCE_DIR}/cmake/tpl/"             SS
       SLEPC    "${Futility_SOURCE_DIR}/cmake/tpl/"             SS
       SUNDIALS "${Futility_SOURCE_DIR}/cmake/tpl/"             SS
       PNG      "${Futility_SOURCE_DIR}/cmake/tpl/"             SS
  )
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ SET(LIB_OPTIONAL_DEP_PACKAGES
SET(TEST_REQUIRED_DEP_PACKAGES)
SET(TEST_OPTIONAL_DEP_PACKAGES)
SET(LIB_REQUIRED_DEP_TPLS)
SET(LIB_OPTIONAL_DEP_TPLS BLAS LAPACK MPI HYPRE PETSC PARDISO HDF5 PAPI SLEPC SUNDIALS)
SET(LIB_OPTIONAL_DEP_TPLS BLAS LAPACK MPI HYPRE PETSC PARDISO HDF5 PNG PAPI SLEPC SUNDIALS)
SET(TEST_REQUIRED_DEP_TPLS)
SET(TEST_OPTIONAL_DEP_TPLS MPI)

+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@ IF(${PACKAGE_NAME}_ENABLE_HDF5)
        MESSAGE(STATUS "Enabling HDF5")
    ENDIF()
ENDIF()
IF(${PACKAGE_NAME}_ENABLE_PNG)
   SET(${PACKAGE_NAME}_DEFINES ${${PACKAGE_NAME}_DEFINES} FUTILITY_HAVE_PNG)
   IF(${PACKAGE_NAME} STREQUAL "Futility")
        MESSAGE(STATUS "Enabling PNG")
    ENDIF()
ENDIF()
IF(${PACKAGE_NAME}_ENABLE_BLAS)
    SET(${PACKAGE_NAME}_DEFINES ${${PACKAGE_NAME}_DEFINES} HAVE_BLAS)
    IF(${PACKAGE_NAME} STREQUAL "Futility")
+13 −0
Original line number Diff line number Diff line
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
#                          Futility Development Group                          !
#                             All rights reserved.                             !
#                                                                              !
# Futility is a jointly-maintained, open-source project between the University !
# of Michigan and Oak Ridge National Laboratory.  The copyright and license    !
# can be found in LICENSE.txt in the head directory of this repository.        !
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!

TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES( PNG
  REQUIRED_HEADERS png.h
  REQUIRED_LIBS_NAMES png)
Loading