// BlockyFroggy
// Copyright © 2017 John Ryland.
// All rights reserved.
#pragma once
#ifndef IMAGE_H
#define IMAGE_H
/*!
@page Topics
@subpage ImageHandling
@page ImageHandling Image Handling
### Image Format Support
Formats | Support
------------- | -------------
BMP | No
GIF | No
PNG | Yes
JPEG | No
TGA | Yes
PVR | WIP
*/
#include <cstdint>
#include <vector>
#include <cstdlib>
using ByteArray = std::vector<uint8_t>;
enum ImageType
{
RAW_RGB_24BPP = 0x8051,
RAW_RGBA_32BPP = 0x8058,
//PVR_Alpha_2BPP,
//PVR_Alpha_4BPP,
PVRTC_RGB_4BPPV1 = 0x8C00,
PVRTC_RGB_2BPPV1 = 0x8C01,
PVRTC_RGBA_4BPPV1 = 0x8C02,
PVRTC_RGBA_2BPPV1 = 0x8C03,
};
//! Holds image formatted data in an array of bytes.
struct Image
{
ImageType m_type;
ByteArray m_data;
size_t m_width;
size_t m_height;
};
bool LoadFile(const char* filename, ByteArray& data);
bool SaveFile(const char* filename, const ByteArray& data);
bool DecodeTGA(const ByteArray& inData, Image& outImage);
bool EncodeTGA(const Image& inImage, ByteArray& outData);
bool DecodePNG(const ByteArray& inData, Image& outImage);
//bool EncodePNG(const Image& inImage, ByteArray& outData);
bool ConvertImage(const Image& inImage, Image& outImage, ImageType outputFormat = PVRTC_RGB_4BPPV1);
#endif // IMAGE_H