### Installing Pkg-config Files Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Installs the .pc files for pkg-config to the lib/pkgconfig directory. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) ``` -------------------------------- ### Installing Man Pages Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Installs man pages for libpng to the appropriate man directory. ```cmake install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) install(FILES png.5 DESTINATION man/man5) ``` -------------------------------- ### Implement Test Plugin (VC++ Example) Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/other_documentation.dox This is an example of the main file content for creating a test plug-in using Visual C++. It includes the necessary header and uses the CPPUNIT_PLUGIN_IMPLEMENT() macro. ```cpp #include CPPUNIT_PLUGIN_IMPLEMENT(); ``` -------------------------------- ### Installing Static Library Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Installs the static library to library and archive destinations if PNG_STATIC is enabled and installation is not skipped. ```cmake install(TARGETS ${PNG_LIB_NAME_STATIC} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) ``` -------------------------------- ### Installing Config Executables Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Installs the libpng-config and custom PNGLIB_NAME-config executables to the bin directory. ```cmake install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) ``` -------------------------------- ### Installing Headers Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Installs PNG header files to the include directory and a subdirectory named after the library. ```cmake install(FILES png.h pngconf.h DESTINATION include) install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME}) ``` -------------------------------- ### Installing Shared Library Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Installs the shared library to runtime, library, and archive destinations if PNG_SHARED is enabled and installation is not skipped. ```cmake install(TARGETS ${PNG_LIB_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) ``` -------------------------------- ### Example of png_debug1 Usage Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt This demonstrates how to use the png_debug1 macro with a specific level and a formatted string containing a variable. ```c png_debug1(2, "foo=%d\n", foo); ``` -------------------------------- ### Makefile.am Example (Unix) Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/Money.dox This is a placeholder for a Makefile.am file, which would typically define build rules for a project managed with automake. ```makefile ``` -------------------------------- ### Fixture Setup for Complex Number Tests Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/cookbook.dox Demonstrates how to set up a test fixture by subclassing CppUnit::TestFixture. It overrides setUp to allocate Complex number objects and tearDown to deallocate them, preparing resources for test cases. ```cpp class ComplexNumberTest : public CppUnit::TestFixture { private: Complex *m_10_1, *m_1_1, *m_11_2; public: void setUp() { m_10_1 = new Complex( 10, 1 ); m_1_1 = new Complex( 1, 1 ); m_11_2 = new Complex( 11, 2 ); } void tearDown() { delete m_10_1; delete m_1_1; delete m_11_2; } }; ``` -------------------------------- ### Setting CMake Installation Variables Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Sets standard CMake installation prefix variables based on CMAKE_INSTALL_PREFIX. ```cmake set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}) set(libdir ${CMAKE_INSTALL_PREFIX}/lib) set(includedir ${CMAKE_INSTALL_PREFIX}/include) ``` -------------------------------- ### CppUnit Test Fixture Setup and Teardown Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/cookbook.dox Defines methods for setting up test fixtures before each test and tearing them down afterward. ```cpp public: void setUp() { m_10_1 = new Complex( 10, 1 ); m_1_1 = new Complex( 1, 1 ); m_11_2 = new Complex( 11, 2 ); } void tearDown() { delete m_10_1; delete m_1_1; delete m_11_2; } ``` -------------------------------- ### Detect Libpng Presence with Autoconf Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Example of how to use the png_get_io_ptr() function in an autoconf 'configure.in' script to detect the presence of libpng version 0.88 or later. ```autoconf AC_CHECK_LIB(png, png_get_io_ptr, ...) ``` -------------------------------- ### Dynamic Map Implementation Example Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/src/msvc6/testrunner/DynamicWindow/doc/cdxCDynamicWnd-DOC.html Use DECLARE_DYNAMIC_MAP() in the class definition and BEGIN_DYNAMIC_MAP() with DYNAMIC_MAP_ENTRY() macros in the implementation to define child control resizing behavior. This is an alternative to using AddSzControl(). ```cpp BEGIN_DYNAMIC_MAP(CTestDlg,cdxCDynamicDialog) DYNAMIC_MAP_ENTRY(IDC_BOX_1, mdResize, mdResize) DYNAMIC_MAP_ENTRY(IDC_LIST1, mdResize, mdResize) DYNAMIC_MAP_ENTRY(IDC_EDIT, mdResize, mdRepos) DYNAMIC_MAP_ENTRY(IDC_NEW, mdRepos, mdRepos) DYNAMIC_MAP_ENTRY(IDOK, mdRelative, mdRepos) DYNAMIC_MAP_ENTRY(IDCANCEL, mdRelative, mdRepos) END_DYNAMIC_MAP() ``` -------------------------------- ### MoneyTest Fixture Implementation Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/Money.dox This C++ source file provides the implementation for the MoneyTest fixture. It registers the fixture with the CppUnit registry and defines the setup, teardown, and testConstructor methods. Currently, testConstructor uses CPPUNIT_FAIL to indicate it's not implemented. ```cpp #include "stdafx.h" #include "MoneyTest.h" // Registers the fixture into the 'registry' CPPUNIT_TEST_SUITE_REGISTRATION( MoneyTest ); void MoneyTest::setUp() { } void MoneyTest::tearDown() { } void MoneyTest::testConstructor() { CPPUNIT_FAIL( "not implemented" ); } ``` -------------------------------- ### Declare Test Suite with Helper Macros Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/cookbook.dox Introduces the use of CppUnit helper macros to automatically implement the static suite() method for a test fixture. This simplifies test setup by reducing repetitive code. ```cpp #include class ComplexNumberTest : public CppUnit::TestFixture { ``` -------------------------------- ### Configure Unknown Chunk Handling Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Sets libpng's behavior for unknown chunks. This example shows ignoring all unknown chunks, then specifically keeping 'vpAg', and finally ignoring other known but unused chunks. ```c #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* ignore all unknown chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); /* also ignore unused known chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, (int)sizeof(unused_chunks)/5); #endif ``` -------------------------------- ### Transferring Data Responsibility with png_data_freer Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Example demonstrating how to transfer data freeing responsibility between read and write structures using png_data_freer. This is useful when reassigning data ownership. ```c png_data_freer(read_ptr, read_info_ptr, PNG_USER_WILL_FREE_DATA, PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) png_data_freer(write_ptr, write_info_ptr, PNG_DESTROY_WILL_FREE_DATA, PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) ``` -------------------------------- ### AddSzControl() Usage Example Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/src/msvc6/testrunner/DynamicWindow/doc/cdxCDynamicWnd-DOC.html Use AddSzControl() in OnInitDialog() or OnInitialUpdate() to specify how child controls should resize or reposition when the parent window resizes. The arguments define the control ID and the resizing behavior for width and height changes. ```cpp AddSzControl(IDC_BOX_1,mdResize,mdResize); AddSzControl(IDC_LIST,mdResize,mdResize); AddSzControl(IDC_EDIT,mdResize,mdRepos); AddSzControl(IDC_NEW,mdRepos,mdRepos); AddSzControl(IDOK,mdRelative,mdRepos); AddSzControl(IDCANCEL,mdRelative,mdRepos); ``` -------------------------------- ### Get Libpng Version Number at Runtime Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieve the version number of the libpng library currently in use. The returned number is encoded as major version, minor version (with leading zero), and release number (with leading zero). For example, version 1.0.7 results in 10007. ```c png_uint_32 libpng_vn = png_access_version_number(); ``` -------------------------------- ### Configure and Run Tests with TextUi::TestRunner Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/cookbook.dox Demonstrates how to set up and run tests using CppUnit::TextUi::TestRunner in a main function. This involves creating a runner instance, adding test suites, and executing the run() method. ```cpp int main( int argc, char **argv) { CppUnit::TextUi::TestRunner runner; runner.addTest( ExampleTestCase::suite() ); runner.addTest( ComplexNumberTest::suite() ); runner.run(); return 0; } ``` -------------------------------- ### Configuring PC and Config Files Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Uses the configure_file command to generate .pc and -config files from input templates. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng-config.in ${CMAKE_CURRENT_BINARY_DIR}/libpng-config) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng-config.in ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config) ``` -------------------------------- ### Initializing I/O with a File Pointer Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Initialize libpng's I/O operations using a FILE pointer. Ensure the file is opened in binary mode. ```c png_init_io(png_ptr, fp); ``` -------------------------------- ### Create and Initialize PNG Read Structures Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Allocate and initialize png_struct and png_info structures using provided functions. Check for NULL return values to ensure successful creation. Error handling and warning functions can be passed, or set to NULL to use defaults. ```c png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, user_error_fn, user_warning_fn); if (!png_ptr) return (ERROR); png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); return (ERROR); } png_infop end_info = png_create_info_struct(png_ptr); if (!end_info) { png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); return (ERROR); } ``` -------------------------------- ### Get User Transform Pointer Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the pointer to the user structure set by png_set_user_transform_info. ```APIDOC ## png_get_user_transform_ptr ### Description Retrieves the pointer to the user structure previously set via png_set_user_transform_info. ### Function Signature ```c png_voidp png_get_user_transform_ptr(png_structp png_ptr); ``` ### Parameters - **png_ptr** (png_structp) - Pointer to the PNG write structure. ### Returns (png_voidp) - Pointer to the user-defined structure. ``` -------------------------------- ### Get User Transform Pointer Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the pointer to the user structure previously set with png_set_user_transform_info. ```c voidp write_user_transform_ptr = png_get_user_transform_ptr(png_ptr); ``` -------------------------------- ### Single-line Comment Style Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Example of a single-line comment placed before a statement, aligned with the statement's indentation. ```c /* Single-line comment */ statement; ``` -------------------------------- ### Creating and Configuring a CSizingControlBar Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/src/msvc6/testrunner/DynamicWindow/SizeCBar.html Demonstrates how to create, style, enable docking, and dock a CSizingControlBar instance within a CMainFrame. Ensure to set the floating frame class after enabling docking. ```cpp if (!m_wndMyBar.Create(_T("My Bar"), this, CSize(200, 100), TRUE /*bHasGripper*/, AFX_IDW_CONTROLBAR_FIRST + 32)) { TRACE0("Failed to create mybar\n"); return -1; // fail to create } m_wndMyBar.SetBarStyle(m_wndMyBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_wndMyBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); DockControlBar(&m_wndMyBar, AFX_IDW_DOCKBAR_LEFT); ``` -------------------------------- ### Initializing libpng write structures Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Allocates and initializes the png_struct and png_info structures for writing. Error checking is crucial as these can return NULL. ```c png_structp png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, user_error_fn, user_warning_fn); if (!png_ptr) return (ERROR); png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); return (ERROR); } ``` -------------------------------- ### Get User Transform Pointer Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the pointer to the user structure that was set for use by the user transform function. ```c voidp read_user_transform_ptr = png_get_user_transform_ptr(png_ptr); ``` -------------------------------- ### Build zlib with Borland Makefile Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/projects/cbuilder5/libpng.readme.txt Builds the zlib library using its Borland-compatible Makefile. This step is necessary to create the zlib.lib file required for linking with libpng. ```bash make -f win32\Makefile.bor ``` -------------------------------- ### Configure Autoconf for CppUnit (Unix) Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/doc/Money.dox This configure.in script sets up the build environment for a Unix project using autoconf and automake, specifically initializing the build system and locating CppUnit libraries. ```autoconf dnl Process this file with autoconf to produce a configure script. AC_INIT(Makefile.am) AM_INIT_AUTOMAKE(money,0.1) AM_PATH_CPPUNIT(1.9.6) AC_PROG_CXX AC_PROG_CC AC_PROG_INSTALL AC_OUTPUT(Makefile) ``` -------------------------------- ### Get PNG Histogram Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the histogram of palette entries for the PNG image. Requires the hIST chunk to have been read. ```c png_get_hIST(png_ptr, info_ptr, &hist); ``` -------------------------------- ### Opening a file for writing Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Opens a file in binary write mode. Ensure the file is opened correctly before proceeding with libpng operations. ```c FILE *fp = fopen(file_name, "wb"); if (!fp) { return (ERROR); } ``` -------------------------------- ### Get PNG Gamma Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the gamma value at which the PNG file was written. Requires the gAMA chunk to have been read. ```c png_get_gAMA(png_ptr, info_ptr, &gamma); ``` -------------------------------- ### Creating MSVC Import Library for MinGW Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Commands to generate a .def file from a DLL and then create an import library using the MSVC lib tool. ```shell pexports libpng.dll > libpng.def lib /def:libpng.def /machine:x86 ``` -------------------------------- ### For Loop and Typecast Formatting Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Demonstrates spacing rules for for loops, binary operators, typecasts, and function calls. ```c for (i = 2; i > 0; --i) y[i] = a(x) + (int)b; ``` -------------------------------- ### Get PNG Modification Time Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the time the PNG image was last modified. Requires the tIME chunk to have been read. ```c png_get_tIME(png_ptr, info_ptr, &mod_time); ``` -------------------------------- ### Get Pixel Aspect Ratio Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the pixel aspect ratio from the pHYs chunk. Returns 0 if data is not present or invalid. ```c aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, info_ptr); ``` -------------------------------- ### Get PNG Palette Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the color palette and the number of entries for a paletted PNG image. Requires the palette chunk to have been read. ```c png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); ``` -------------------------------- ### Get PNG Signature Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the PNG file signature read from the file. The data is stored at the offset corresponding to the bytes read. ```c signature = png_get_signature(png_ptr, info_ptr); ``` -------------------------------- ### Project and Version Definition Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Defines the project name as 'libpng' (C language) and enables testing. Sets version variables for the libpng library. ```cmake project(libpng C) enable_testing() # Copyright (C) 2007-2010 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 set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 2) set(PNGLIB_RELEASE 46) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) ``` -------------------------------- ### Get PNG Row Bytes Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the number of bytes required to hold a single row of pixel data for the PNG image. ```c rowbytes = png_get_rowbytes(png_ptr, info_ptr); ``` -------------------------------- ### Set User Transform Info Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Sets up a pointer to a user structure for use by a callback function during PNG writing. The user_channels and user_depth parameters are ignored when writing. ```c png_set_user_transform_info(png_ptr, user_ptr, 0, 0); ``` -------------------------------- ### Get PNG Interlace Type Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the interlacing method used for the PNG image. Returns non-zero if interlacing information is available. ```c interlace_type = png_get_interlace_type(png_ptr, info_ptr); ``` -------------------------------- ### Initialize Test Runner Resource Handle Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/cppunit/src/msvc6/testrunner/Change-Diary-ResourceBugFix.txt In TestPlugInRunnerApp.cpp, include and set the global HINSTANCE variable in InitInstance() to retrieve the application's resource handle. ```cpp extern HINSTANCE g_testRunnerResource; // ... in InitInstance() g_testRunnerResource = AfxGetResourceHandle(); ``` -------------------------------- ### MNG Feature Flags Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt These are example bitmasks used with png_permit_mng_features to enable specific MNG extensions. PNG_ALL_MNG_FEATURES enables all supported MNG features. ```c PNG_FLAG_MNG_EMPTY_PLTE PNG_FLAG_MNG_FILTER_64 PNG_ALL_MNG_FEATURES ``` -------------------------------- ### Get Unknown Chunks Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves an array of unknown chunk structures. Each structure contains the name, data, size, and location of an unknown chunk. ```c num_unknown_chunks = png_get_unknown_chunks(png_ptr, info_ptr, &unknowns); ``` -------------------------------- ### Retrieving and Setting Screen Gamma Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Demonstrates how to obtain the screen gamma value, prioritizing user-defined values, environment variables, or falling back to a default. ```c double gamma, screen_gamma; if (/* We have a user-defined screen gamma value */) { screen_gamma = user_defined_screen_gamma; } /* One way that applications can share the same screen gamma value */ else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) { screen_gamma = (double)atof(gamma_str); } /* If we don't have another value */ else { screen_gamma = 2.2; /* A good guess for a PC monitor in a bright office or a dim room */ screen_gamma = 2.0; /* A good guess for a PC monitor in a dark room */ screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ } ``` -------------------------------- ### Libpng User Limits Functions Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Functions to set and retrieve user-defined limits for image width and height. Enabled by default starting with libpng-1.2.6. ```c png_set_user_limits(); png_get_user_width_max(); png_get_user_height_max(); ``` -------------------------------- ### Conditional Debugging with PNG_DEBUG Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt This example shows how to conditionally print messages to stderr using the PNG_DEBUG macro, even when specific debug levels are not used. ```c #ifdef PNG_DEBUG fprintf(stderr, ... #endif ``` -------------------------------- ### Package Configuration Files Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Placeholder for creating pkg-config files, typically used for managing library dependencies. ```cmake # CREATE PKGCONFIG FILES ``` -------------------------------- ### Get sPLT Palette Data Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves data from one or more sPLT chunks, which contain palette information. The number of sPLT chunks read is returned. ```c num_spalettes = png_get_sPLT(png_ptr, info_ptr, &palette_ptr); ``` -------------------------------- ### Get Offset in Inches from oFFs Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Convenience functions to retrieve the x and y offsets in inches from the oFFs chunk. Returns 0 if data is not present or the unit is pixels. ```c x_offset = png_get_x_offset_inches(png_ptr, info_ptr); ``` ```c y_offset = png_get_y_offset_inches(png_ptr, info_ptr); ``` -------------------------------- ### Libpng Initialization Functions Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt These are the preferred functions for creating and initializing libpng structures, offering better error checking and custom error handling compared to older methods. ```c png_create_read_struct() png_create_write_struct() png_create_info_struct() ``` -------------------------------- ### Get Offset in Microns from oFFs Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Convenience functions to retrieve the x and y offsets in microns from the oFFs chunk. Returns 0 if data is not present or the unit is pixels. ```c x_offset = png_get_x_offset_microns(png_ptr, info_ptr); ``` ```c y_offset = png_get_y_offset_microns(png_ptr, info_ptr); ``` -------------------------------- ### Get pHYs Chunk Resolution Data Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves physical resolution data from the pHYs chunk. The unit type specifies whether the resolution is in meters or unknown. ```c png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); ``` -------------------------------- ### Get PNG Filter and Compression Types Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Retrieves the filter method and compression type used in the PNG datastream. For PNG 1.0, these are typically PNG_FILTER_TYPE_BASE and PNG_COMPRESSION_TYPE_BASE. ```c filter_method = png_get_filter_type(png_ptr, info_ptr); compression_type = png_get_compression_type(png_ptr, info_ptr); ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/CMakeLists.txt Sets the minimum CMake version and allows loose loop constructs. Configures the build type for Unix-like systems if not already defined. ```cmake cmake_minimum_required(VERSION 2.4.3) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") endif() ``` -------------------------------- ### Initializing libpng write structures with custom memory allocation Source: https://github.com/arthur-liberman/hcfr-code/blob/main/Tools/png/libpng-1.2.46.txt Uses custom memory allocation routines by defining PNG_USER_MEM_SUPPORTED and calling png_create_write_struct_2. ```c png_structp png_ptr = png_create_write_struct_2 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, user_error_fn, user_warning_fn, (png_voidp) user_mem_ptr, user_malloc_fn, user_free_fn); ```