Add better support
-Add prototype of PNG export function (WIP) -Updated libs files and information -Credit work of @dpethes
This commit is contained in:
parent
5f4ca7c4a0
commit
23e8719f8d
22
README.md
22
README.md
@ -1,26 +1,32 @@
|
||||
# RogueSquadron Data Extractor - TEXTURE module
|
||||
|
||||
Inspired by the work **dpethes** (https://github.com/dpethes/rerogue)
|
||||
|
||||
This set of git repos are a compilation of tools coded in C to make RS modding far more than a dream!
|
||||
The collection consist of few independants modules, each of them deals with specific data like sound, textures, heightmaps, etc...
|
||||
|
||||
This is the **TEXTURE** module.
|
||||
|
||||
**CAUTION! This module is in very alpha! Don't use it for the moment.**
|
||||
|
||||
All modules are independants. This is the **'TEXTURE'** module.
|
||||
|
||||
**CAUTION! Master branch is hugely buggy and should not be used, please take only released versions.**
|
||||
|
||||
## TEXTURE MODULE
|
||||
|
||||
It's extract texture datas from Rogue Squadron 3D (PC) game files (DAT).
|
||||
|
||||
### Using
|
||||
|
||||
*TODO...*
|
||||
|
||||
### Dependencies
|
||||
|
||||
- zlib (1.2.3)
|
||||
- libpng (1.2.37)
|
||||
Necessary libs for running (provided in release) and for compiling.
|
||||
|
||||
- zlib (1.2.11)
|
||||
- libpng (1.6.37)
|
||||
|
||||
### Compiling
|
||||
|
||||
You can compile on both Windows or Linux system, you only need to adjust your dependencies.
|
||||
*Makefile is coming...*
|
||||
|
||||
### Using
|
||||
|
||||
`TEXTractor <HMT_file>`
|
||||
|
@ -20,7 +20,7 @@
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="gun_turret_HMT"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${workspace_loc:Texture-Extractor/Debug}\Texture-Extractor.exe"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/Texture-Extractor.exe"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Texture-Extractor"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.cross.exe.debug.305633050"/>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="gun_turret_HMT"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${workspace_loc:Texture-Extractor/Release}\Texture-Extractor.exe"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Release/Texture-Extractor.exe"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Texture-Extractor"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.cross.exe.release.400013283"/>
|
||||
|
52
src/Image_Exporter.c
Normal file
52
src/Image_Exporter.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include "Image_Exporter.h"
|
||||
|
||||
|
||||
int saveToPNG(RS_IMAGE *img, char *tex_name) {
|
||||
char tex_path[64];
|
||||
FILE *_png_f = NULL;
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
//size_t x,y;
|
||||
png_byte **row_ptrs = NULL;
|
||||
//int pixel_size = 3;
|
||||
//int depth = 8;
|
||||
|
||||
strcpy(tex_path,tex_name);
|
||||
strcat(tex_path, ".png");
|
||||
_png_f = fopen(tex_path, "wb");
|
||||
if (_png_f == NULL) return EXIT_FAILURE;
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL) {
|
||||
fclose(_png_f);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL) {
|
||||
fclose(_png_f);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Set image attributes
|
||||
png_set_IHDR(png_ptr, info_ptr, img->width, img->height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
// Init PNG datas
|
||||
row_ptrs = png_malloc(png_ptr, img->height * sizeof(png_byte));
|
||||
/*for (y=0; y<img->height; y++) {
|
||||
png_byte *row = png_malloc(png_ptr, img->width*sizeof(unsigned char)*3);
|
||||
row_ptrs[y] = row;
|
||||
for (x=0; x<img->width; x++) {
|
||||
unsigned char pixel[3] = pixelAt(img->pixels);
|
||||
}
|
||||
}*/
|
||||
memcpy(row_ptrs, img->pixels, sizeof(unsigned char)*3*img->height*img->width);
|
||||
|
||||
png_init_io(png_ptr, _png_f);
|
||||
png_set_rows(png_ptr, info_ptr, row_ptrs);
|
||||
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
|
||||
|
||||
png_free(png_ptr, row_ptrs);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
fclose(_png_f);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
10
src/Image_Exporter.h
Normal file
10
src/Image_Exporter.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef IMAGE_EXPORTER_H_
|
||||
#define IMAGE_EXPORTER_H_
|
||||
|
||||
#include "RS_images.h"
|
||||
#include <zlib.h>
|
||||
#include <png.h>
|
||||
|
||||
int saveToPNG(RS_IMAGE *img, char *tex_name);
|
||||
|
||||
#endif
|
@ -4,8 +4,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if defined(_WIN32)
|
||||
#define OS 1
|
||||
#include <windows.h>
|
||||
#else
|
||||
#define OS 2
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
@ -58,9 +58,27 @@ HMT_FILE *extractDatasFromHMT(char *hmt_filename) {
|
||||
}
|
||||
|
||||
int exportTextures(HMT_FILE *hmt_f, char *filename) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
int i;
|
||||
|
||||
for (i=0; i<hmt_f->texture_count; i++) {
|
||||
switch (hmt_f->textures_list[i].image.type_) {
|
||||
case 0:
|
||||
case 1:
|
||||
saveToPNG(&(hmt_f->textures_list[i].image), hmt_f->textures_list[i].name);
|
||||
//Write to PNM
|
||||
break;
|
||||
case 3:
|
||||
//Write to TGA
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
saveToPNG(&(hmt_f->textures_list[i].image), hmt_f->textures_list[i].name);
|
||||
//Write to PGM
|
||||
break;
|
||||
default:
|
||||
printf("[INFO] Image type %d not currently supported!", hmt_f->textures_list[i].image.type_);
|
||||
}
|
||||
}
|
||||
|
||||
int saveToPNG(RS_IMAGE *img, char *tex_name) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -4,14 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <zlib.h>
|
||||
#include <png.h>
|
||||
#include "HMT_Parser.h"
|
||||
#include "RS_images.h"
|
||||
#include "Image_Exporter.h"
|
||||
|
||||
void purgeHMTFromMemory(HMT_FILE *_f);
|
||||
HMT_FILE *extractDatasFromHMT(char* hmt_filename);
|
||||
int exportTextures(HMT_FILE *hmt_f, char *filename);
|
||||
int saveToPNG(RS_IMAGE *img, char *tex_name);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user