diff --git a/Jenkinsfile b/Jenkinsfile index fa42698..3060123 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { } environment { CI_OUTPUT_NAME = "RSETerrain" - CI_VERSION = "2.0.2" + CI_VERSION = "2.0.3" CI_BUILD_NUMBER = "$BUILD_NUMBER" } stages { diff --git a/RSETerrain/src/RSETerrain.c b/RSETerrain/src/RSETerrain.c index a344d72..fffb4f0 100644 --- a/RSETerrain/src/RSETerrain.c +++ b/RSETerrain/src/RSETerrain.c @@ -3,7 +3,7 @@ * @date 23/08/2022 * @author JackCarterSmith * @copyright GPL-v3.0 - * @brief HMP model parser and export to Waveform OBJ format and grey-scale PNG heightmap. + * @brief HMP terrain parser and export to Waveform OBJ format and grey-scale PNG heightmap. * */ diff --git a/RSETerrain/src/terrain_export.c b/RSETerrain/src/terrain_export.c index c2f5b5d..5e766e3 100644 --- a/RSETerrain/src/terrain_export.c +++ b/RSETerrain/src/terrain_export.c @@ -10,10 +10,11 @@ #include #include #include +#include +#include #include "options.h" #include #include -#include #include "obj/obj.h" #include "terrain_export.h" @@ -57,18 +58,27 @@ unsigned char exportHeightmapPNG(const T_RSPTERRAIN_HEIGHTMAP* heightmap, const return RSPLIB_ERROR_MEMORY; } + // Set compression level + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + // Set image attributes - png_set_IHDR(png_ptr, info_ptr, heightmap->width * RSPTERRAINLIB_TILE_SAMPLING, heightmap->height * RSPTERRAINLIB_TILE_SAMPLING, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_set_IHDR(png_ptr, info_ptr, + heightmap->width * RSPTERRAINLIB_TILE_SAMPLING, + heightmap->height * RSPTERRAINLIB_TILE_SAMPLING, + 8, + PNG_COLOR_TYPE_GRAY, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT + ); // Store PNG datas in buffer row_ptrs = png_malloc(png_ptr, heightmap->height * RSPTERRAINLIB_TILE_SAMPLING * sizeof(png_byte *)); for ( z = 0; z < heightmap->height * RSPTERRAINLIB_TILE_SAMPLING; z++ ) { - png_byte *row = png_malloc(png_ptr, heightmap->width * RSPTERRAINLIB_TILE_SAMPLING * sizeof(unsigned char) * 3); + png_byte *row = png_malloc(png_ptr, heightmap->width * RSPTERRAINLIB_TILE_SAMPLING * sizeof(unsigned char)); row_ptrs[z] = row; for ( x = 0; x < heightmap->width * RSPTERRAINLIB_TILE_SAMPLING; x++ ) { *row++ = heightmap->heightmap[x][z]; - *row++ = heightmap->heightmap[x][z]; - *row++ = heightmap->heightmap[x][z]; } } diff --git a/RSPTerrainLib/src/RSPTerrain.c b/RSPTerrainLib/src/RSPTerrain.c index c9f6465..578f51a 100644 --- a/RSPTerrainLib/src/RSPTerrain.c +++ b/RSPTerrainLib/src/RSPTerrain.c @@ -22,7 +22,6 @@ char* RSPTerrain_getVersion( void ) { return PRG_VERSION; } - unsigned short RSPTerrain_processHMPFile( T_RSPTERRAIN_HMP* hmpStruct, const char* const filePath, const RSPTERRAIN_PARAMETERS params ) {