move stb zlib compressor to extensions folder
This commit is contained in:
@@ -15,8 +15,6 @@
|
||||
#include <cassert>
|
||||
#include <cinttypes>
|
||||
#include <atomic>
|
||||
#include <fstream>
|
||||
#include <zlib.h>
|
||||
#include "Data/Containers/Array.hpp"
|
||||
|
||||
namespace OpenVulkano
|
||||
@@ -206,26 +204,6 @@ namespace OpenVulkano
|
||||
return id;
|
||||
}
|
||||
|
||||
static unsigned char* STBZlibCompressor(unsigned char* data, int data_len, int* out_len, int quality)
|
||||
{
|
||||
uLong maxCompressedSize = compressBound(data_len);
|
||||
void* outData = malloc(maxCompressedSize);
|
||||
if (!outData)
|
||||
{
|
||||
*out_len = 0;
|
||||
return nullptr;
|
||||
}
|
||||
int result = compress2(static_cast<Bytef*>(outData), &maxCompressedSize, data, data_len, Z_BEST_COMPRESSION);
|
||||
if (result != Z_OK)
|
||||
{
|
||||
free(outData);
|
||||
*out_len = 0;
|
||||
return nullptr;
|
||||
}
|
||||
*out_len = static_cast<int>(maxCompressedSize);
|
||||
return static_cast<unsigned char*>(outData);
|
||||
}
|
||||
|
||||
static std::string DemangleTypeName(const char* name);
|
||||
};
|
||||
}
|
||||
|
||||
33
openVulkanoCpp/Extensions/STBZlibCompressor.hpp
Normal file
33
openVulkanoCpp/Extensions/STBZlibCompressor.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace Extensions
|
||||
{
|
||||
static unsigned char* STBZlibCompressor(unsigned char* data, int data_len, int* out_len, int quality)
|
||||
{
|
||||
uLong maxCompressedSize = compressBound(data_len);
|
||||
void* outData = malloc(maxCompressedSize);
|
||||
if (!outData)
|
||||
{
|
||||
*out_len = 0;
|
||||
return nullptr;
|
||||
}
|
||||
int result = compress2(static_cast<Bytef*>(outData), &maxCompressedSize, data, data_len, Z_BEST_COMPRESSION);
|
||||
if (result != Z_OK)
|
||||
{
|
||||
free(outData);
|
||||
*out_len = 0;
|
||||
return nullptr;
|
||||
}
|
||||
*out_len = static_cast<int>(maxCompressedSize);
|
||||
return static_cast<unsigned char*>(outData);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
#include "FontAtlasGeneratorBase.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include <zlib.h>
|
||||
#include "Extensions/STBZlibCompressor.hpp"
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#define STBI_MSC_SECURE_CRT
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#define STBIW_ZLIB_COMPRESS OpenVulkano::Utils::STBZlibCompressor
|
||||
#define STBIW_ZLIB_COMPRESS Extensions::STBZlibCompressor
|
||||
#include <stb_image_write.h>
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
|
||||
Reference in New Issue
Block a user