1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-14 19:10:25 +00:00

ZAPD update: libpng, zroom improvements and others (#811)

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "769f5702a"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "769f5702a"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Add `libpng` to readme

* Remove `-ifp` since it doesn't exists anymore in ZAPD

* Remove extra print I added

* Add UNK_09 macro and other minor fixes

* Simplify PNG rules

* simplify gitignore

* Update README.md

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>

* Update dockerfile

* basic instructions for cygwin and mac

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "86160be69"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "86160be69"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Change nanoseconds to seconds in extract_assets.py

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
This commit is contained in:
Anghelo Carvajal 2021-05-30 11:09:59 -04:00 committed by GitHub
parent 676ecf06c5
commit 515ebdce9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
142 changed files with 5922 additions and 14735 deletions

View file

@ -1,13 +1,15 @@
#pragma once
#include "HighLevel/HLTexture.h"
#include "ZResource.h"
#include "tinyxml2.h"
#include <vector>
#include "HighLevel/HLTexture.h"
#include "ImageBackend.h"
#include "ZResource.h"
#include "tinyxml2.h"
enum class TextureType
{
Error,
RGBA32bpp,
RGBA16bpp,
Palette4bpp,
@ -17,26 +19,19 @@ enum class TextureType
GrayscaleAlpha4bpp,
GrayscaleAlpha8bpp,
GrayscaleAlpha16bpp,
Error
};
class ZTexture : public ZResource
{
protected:
TextureType type;
uint16_t width, height;
TextureType format = TextureType::Error;
uint32_t width, height;
uint8_t* bmpRgb;
uint8_t* bmpRgba;
bool isRawDataFixed;
ImageBackend textureData;
std::vector<uint8_t> textureDataRaw; // When reading from a PNG file.
uint32_t tlutOffset = static_cast<uint32_t>(-1);
ZTexture* tlut = nullptr;
void ParseXML(tinyxml2::XMLElement* reader) override;
void FixRawData();
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
const uint32_t nRawDataIndex,
const std::string& nRelPath) override; // Extract Mode
void PrepareBitmap();
void PrepareBitmapRGBA16();
void PrepareBitmapRGBA32();
void PrepareBitmapGrayscale8();
@ -46,52 +41,55 @@ protected:
void PrepareBitmapGrayscaleAlpha16();
void PrepareBitmapPalette4();
void PrepareBitmapPalette8();
void PrepareRawData(std::string inFolder);
void PrepareRawDataRGBA16(std::string rgbaPath);
void PrepareRawDataRGBA32(std::string rgbaPath);
void PrepareRawDataGrayscale4(std::string grayPath);
void PrepareRawDataGrayscale8(std::string grayPath);
void PrepareRawDataGrayscaleAlpha4(std::string grayAlphaPath);
void PrepareRawDataGrayscaleAlpha8(std::string grayAlphaPath);
void PrepareRawDataGrayscaleAlpha16(std::string grayAlphaPath);
void PrepareRawDataPalette4(std::string palPath);
void PrepareRawDataPalette8(std::string palPath);
float GetPixelMultiplyer();
void PrepareRawDataFromFile(const fs::path& inFolder);
void PrepareRawDataRGBA16(const fs::path& rgbaPath);
void PrepareRawDataRGBA32(const fs::path& rgbaPath);
void PrepareRawDataGrayscale4(const fs::path& grayPath);
void PrepareRawDataGrayscale8(const fs::path& grayPath);
void PrepareRawDataGrayscaleAlpha4(const fs::path& grayAlphaPath);
void PrepareRawDataGrayscaleAlpha8(const fs::path& grayAlphaPath);
void PrepareRawDataGrayscaleAlpha16(const fs::path& grayAlphaPath);
void PrepareRawDataPalette4(const fs::path& palPath);
void PrepareRawDataPalette8(const fs::path& palPath);
public:
ZTexture(ZFile* nParent);
~ZTexture();
bool isPalette;
bool isPalette = false;
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
uint32_t nRawDataIndex) override;
void FromBinary(const std::vector<uint8_t>& nRawData, uint32_t nRawDataIndex, int32_t nWidth,
int32_t nHeight, TextureType nType, bool nIsPalette);
void FromPNG(const fs::path& pngFilePath, TextureType texType);
void FromHLTexture(HLTexture* hlTex);
static ZTexture* BuildFromXML(tinyxml2::XMLElement* reader, std::string inFolder,
bool readFile);
// static ZTexture* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData,
// uint32_t rawDataIndex, std::string nRelPath, ZFile* nParent);
static ZTexture* FromBinary(TextureType nType, std::vector<uint8_t> nRawData,
uint32_t rawDataIndex, std::string nName, int32_t nWidth,
int32_t nHeight, ZFile* nParent);
static ZTexture* FromPNG(std::string pngFilePath, TextureType texType);
static ZTexture* FromHLTexture(HLTexture* hlTex);
static TextureType GetTextureTypeFromString(std::string str);
std::string GetSourceOutputCode(const std::string& prefix) override;
std::string GetSourceOutputHeader(const std::string& prefix) override;
void ParseXML(tinyxml2::XMLElement* reader) override;
void ParseRawData() override;
void DeclareReferences(const std::string& prefix) override;
std::string GetBodySourceCode() const;
void CalcHash() override;
void Save(const fs::path& outFolder) override;
size_t GetRawDataSize() override;
bool IsExternalResource() const override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
std::string GetExternalExtension() const override;
size_t GetRawDataSize() const override;
std::string GetIMFmtFromType();
std::string GetIMSizFromType();
uint16_t GetWidth();
uint16_t GetHeight();
void SetWidth(uint16_t nWidth);
void SetHeight(uint16_t nHeight);
TextureType GetTextureType();
void Save(const std::string& outFolder) override;
std::string GetExternalExtension() override;
std::string GetPoolOutPath(std::string defaultValue);
void CalcHash() override;
bool IsExternalResource() override;
std::string GetSourceTypeName() override;
ZResourceType GetResourceType() override;
std::string GetDefaultName(const std::string& prefix);
uint32_t GetWidth() const;
uint32_t GetHeight() const;
void SetDimensions(uint32_t nWidth, uint32_t nHeight);
float GetPixelMultiplyer() const;
TextureType GetTextureType() const;
fs::path GetPoolOutPath(const fs::path& defaultValue);
bool IsColorIndexed() const;
void SetTlut(ZTexture* nTlut);
bool HasTlut() const;
};