Optimize PNG export
Some checks failed
JCS-Prod/RSE-Terrain/pipeline/pr-master There was a failure building this commit
Some checks failed
JCS-Prod/RSE-Terrain/pipeline/pr-master There was a failure building this commit
This commit is contained in:
parent
85c86c4a27
commit
49f5e8809b
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -5,7 +5,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
CI_OUTPUT_NAME = "RSETerrain"
|
CI_OUTPUT_NAME = "RSETerrain"
|
||||||
CI_VERSION = "2.0.2"
|
CI_VERSION = "2.0.3"
|
||||||
CI_BUILD_NUMBER = "$BUILD_NUMBER"
|
CI_BUILD_NUMBER = "$BUILD_NUMBER"
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @date 23/08/2022
|
* @date 23/08/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @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.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <png.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include <RSPTerrain_datatypes.h>
|
#include <RSPTerrain_datatypes.h>
|
||||||
#include <RSPTerrain_errordefs.h>
|
#include <RSPTerrain_errordefs.h>
|
||||||
#include <png.h>
|
|
||||||
#include "obj/obj.h"
|
#include "obj/obj.h"
|
||||||
#include "terrain_export.h"
|
#include "terrain_export.h"
|
||||||
|
|
||||||
@ -57,18 +58,27 @@ unsigned char exportHeightmapPNG(const T_RSPTERRAIN_HEIGHTMAP* heightmap, const
|
|||||||
return RSPLIB_ERROR_MEMORY;
|
return RSPLIB_ERROR_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set compression level
|
||||||
|
png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
// Set image attributes
|
// 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
|
// Store PNG datas in buffer
|
||||||
row_ptrs = png_malloc(png_ptr, heightmap->height * RSPTERRAINLIB_TILE_SAMPLING * sizeof(png_byte *));
|
row_ptrs = png_malloc(png_ptr, heightmap->height * RSPTERRAINLIB_TILE_SAMPLING * sizeof(png_byte *));
|
||||||
for ( z = 0; z < heightmap->height * RSPTERRAINLIB_TILE_SAMPLING; z++ ) {
|
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;
|
row_ptrs[z] = row;
|
||||||
for ( x = 0; x < heightmap->width * RSPTERRAINLIB_TILE_SAMPLING; x++ ) {
|
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];
|
|
||||||
*row++ = heightmap->heightmap[x][z];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ char* RSPTerrain_getVersion( void ) {
|
|||||||
return PRG_VERSION;
|
return PRG_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned short RSPTerrain_processHMPFile( T_RSPTERRAIN_HMP* hmpStruct, const char* const filePath,
|
unsigned short RSPTerrain_processHMPFile( T_RSPTERRAIN_HMP* hmpStruct, const char* const filePath,
|
||||||
const RSPTERRAIN_PARAMETERS params ) {
|
const RSPTERRAIN_PARAMETERS params ) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user