Optimize PNG export
Some checks failed
JCS-Prod/RSE-Terrain/pipeline/pr-master There was a failure building this commit

This commit is contained in:
JackCarterSmith 2022-08-29 18:22:00 +02:00
parent 85c86c4a27
commit 49f5e8809b
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24
4 changed files with 17 additions and 8 deletions

2
Jenkinsfile vendored
View File

@ -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 {

View File

@ -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.
*
*/

View File

@ -10,10 +10,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#include <png.h>
#include "options.h"
#include <RSPTerrain_datatypes.h>
#include <RSPTerrain_errordefs.h>
#include <png.h>
#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];
}
}

View File

@ -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 ) {