45901c935c
- Fixing DDS writer so it writes a non-zero pitch/linearsize field (a few DDS readers in the wild require this field to be set) - Fixing example2.cpp and example3.cpp so they write non-zero pitch/linearsize fields. - Misc merges from the ddsexport branch - Adding -usesourceformat command line option, useful when reprocessing a lot of existing DDS files.
112 lines
3.6 KiB
C++
112 lines
3.6 KiB
C++
// File: crn_texture_conversion.h
|
|
// See Copyright Notice and license at the end of inc/crnlib.h
|
|
#pragma once
|
|
#include "crn_dxt_image.h"
|
|
#include "crn_dds_texture.h"
|
|
#include "crn_rect.h"
|
|
#include "crn_lzma_codec.h"
|
|
|
|
namespace crnlib
|
|
{
|
|
namespace texture_conversion
|
|
{
|
|
class convert_stats
|
|
{
|
|
public:
|
|
convert_stats();
|
|
|
|
bool init(
|
|
const wchar_t* pSrc_filename,
|
|
const wchar_t* pDst_filename,
|
|
dds_texture& src_tex,
|
|
texture_file_types::format dst_file_type,
|
|
bool lzma_stats);
|
|
|
|
bool print(bool psnr_metrics, bool mip_stats, bool grayscale_sampling, const wchar_t *pCSVStatsFile = NULL) const;
|
|
|
|
void clear();
|
|
|
|
dynamic_wstring m_src_filename;
|
|
dynamic_wstring m_dst_filename;
|
|
texture_file_types::format m_dst_file_type;
|
|
|
|
dds_texture* m_pInput_tex;
|
|
dds_texture m_output_tex;
|
|
|
|
uint64 m_input_file_size;
|
|
uint m_total_input_pixels;
|
|
|
|
uint64 m_output_file_size;
|
|
uint m_total_output_pixels;
|
|
|
|
uint64 m_output_comp_file_size;
|
|
};
|
|
|
|
class convert_params
|
|
{
|
|
public:
|
|
convert_params() :
|
|
m_pInput_texture(NULL),
|
|
m_texture_type(cTextureTypeUnknown),
|
|
m_dst_file_type(texture_file_types::cFormatInvalid),
|
|
m_dst_format(PIXEL_FMT_INVALID),
|
|
m_pProgress_func(NULL),
|
|
m_pProgress_user_data(NULL),
|
|
m_pIntermediate_texture(NULL),
|
|
m_write_mipmaps_to_multiple_files(false),
|
|
m_quick(false),
|
|
m_debugging(false),
|
|
m_param_debugging(false),
|
|
m_no_stats(false),
|
|
m_lzma_stats(false),
|
|
m_status(false),
|
|
m_canceled(false),
|
|
m_use_source_format(false)
|
|
{
|
|
}
|
|
|
|
~convert_params()
|
|
{
|
|
crnlib_delete(m_pIntermediate_texture);
|
|
}
|
|
|
|
void print();
|
|
|
|
// Input parameters
|
|
dds_texture* m_pInput_texture;
|
|
|
|
texture_type m_texture_type;
|
|
|
|
dynamic_wstring m_dst_filename;
|
|
texture_file_types::format m_dst_file_type;
|
|
pixel_format m_dst_format;
|
|
|
|
crn_comp_params m_comp_params;
|
|
crn_mipmap_params m_mipmap_params;
|
|
|
|
typedef bool (*progress_callback_func_ptr)(uint percentage_complete, void* pUser_data_ptr);
|
|
progress_callback_func_ptr m_pProgress_func;
|
|
void* m_pProgress_user_data;
|
|
|
|
// Return parameters
|
|
dds_texture* m_pIntermediate_texture;
|
|
mutable dynamic_wstring m_error_message;
|
|
|
|
bool m_write_mipmaps_to_multiple_files;
|
|
bool m_quick;
|
|
bool m_debugging;
|
|
bool m_param_debugging;
|
|
bool m_no_stats;
|
|
bool m_use_source_format;
|
|
|
|
bool m_lzma_stats;
|
|
mutable bool m_status;
|
|
mutable bool m_canceled;
|
|
};
|
|
|
|
bool process(convert_params& params, convert_stats& stats);
|
|
|
|
} // namespace texture_conversion
|
|
|
|
} // namespace crnlib
|