2013-09-02 19:22:53 -04:00
|
|
|
/*
|
2015-01-01 18:04:46 -05:00
|
|
|
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
2013-09-02 19:22:53 -04:00
|
|
|
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2013-11-14 00:54:36 -05:00
|
|
|
#ifndef BGFX_IMAGE_H_HEADER_GUARD
|
|
|
|
#define BGFX_IMAGE_H_HEADER_GUARD
|
2013-09-02 19:22:53 -04:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
|
|
|
struct ImageContainer
|
|
|
|
{
|
2013-09-09 00:03:03 -04:00
|
|
|
void* m_data;
|
|
|
|
uint32_t m_size;
|
2013-09-02 19:22:53 -04:00
|
|
|
uint32_t m_offset;
|
|
|
|
uint32_t m_width;
|
|
|
|
uint32_t m_height;
|
|
|
|
uint32_t m_depth;
|
2013-09-09 00:03:03 -04:00
|
|
|
uint8_t m_format;
|
2013-09-02 19:22:53 -04:00
|
|
|
uint8_t m_numMips;
|
|
|
|
bool m_hasAlpha;
|
|
|
|
bool m_cubeMap;
|
|
|
|
bool m_ktx;
|
2015-05-02 22:57:42 -04:00
|
|
|
bool m_srgb;
|
2013-09-02 19:22:53 -04:00
|
|
|
};
|
|
|
|
|
2013-09-09 00:03:03 -04:00
|
|
|
struct ImageMip
|
2013-09-02 19:22:53 -04:00
|
|
|
{
|
|
|
|
uint32_t m_width;
|
|
|
|
uint32_t m_height;
|
|
|
|
uint32_t m_blockSize;
|
|
|
|
uint32_t m_size;
|
|
|
|
uint8_t m_bpp;
|
2013-09-09 00:03:03 -04:00
|
|
|
uint8_t m_format;
|
2013-09-02 19:22:53 -04:00
|
|
|
bool m_hasAlpha;
|
|
|
|
const uint8_t* m_data;
|
|
|
|
};
|
|
|
|
|
2014-03-01 22:27:34 -05:00
|
|
|
struct ImageBlockInfo
|
|
|
|
{
|
|
|
|
uint8_t bitsPerPixel;
|
|
|
|
uint8_t blockWidth;
|
|
|
|
uint8_t blockHeight;
|
|
|
|
uint8_t blockSize;
|
2015-02-02 00:38:47 -05:00
|
|
|
uint8_t minBlockX;
|
|
|
|
uint8_t minBlockY;
|
2015-03-13 01:35:45 -04:00
|
|
|
uint8_t depthBits;
|
|
|
|
uint8_t stencilBits;
|
2014-03-01 22:27:34 -05:00
|
|
|
};
|
|
|
|
|
2014-01-12 16:51:26 -05:00
|
|
|
///
|
|
|
|
bool isCompressed(TextureFormat::Enum _format);
|
|
|
|
|
|
|
|
///
|
|
|
|
bool isColor(TextureFormat::Enum _format);
|
|
|
|
|
|
|
|
///
|
|
|
|
bool isDepth(TextureFormat::Enum _format);
|
|
|
|
|
2013-09-06 00:41:42 -04:00
|
|
|
///
|
2014-03-01 22:27:34 -05:00
|
|
|
uint8_t getBitsPerPixel(TextureFormat::Enum _format);
|
|
|
|
|
|
|
|
///
|
|
|
|
const ImageBlockInfo& getBlockInfo(TextureFormat::Enum _format);
|
2013-09-06 00:41:42 -04:00
|
|
|
|
2014-02-06 02:07:11 -05:00
|
|
|
///
|
|
|
|
const char* getName(TextureFormat::Enum _format);
|
|
|
|
|
2013-09-02 19:22:53 -04:00
|
|
|
///
|
|
|
|
void imageSolid(uint32_t _width, uint32_t _height, uint32_t _solid, void* _dst);
|
|
|
|
|
|
|
|
///
|
2013-09-03 23:13:07 -04:00
|
|
|
void imageCheckerboard(uint32_t _width, uint32_t _height, uint32_t _step, uint32_t _0, uint32_t _1, void* _dst);
|
2013-09-02 19:22:53 -04:00
|
|
|
|
|
|
|
///
|
2013-11-09 00:07:35 -05:00
|
|
|
void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, void* _dst);
|
2013-09-02 19:22:53 -04:00
|
|
|
|
|
|
|
///
|
2013-11-09 00:07:35 -05:00
|
|
|
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, void* _dst);
|
2013-09-02 19:22:53 -04:00
|
|
|
|
2013-11-08 23:53:23 -05:00
|
|
|
///
|
2013-11-09 00:07:35 -05:00
|
|
|
void imageCopy(uint32_t _width, uint32_t _height, uint32_t _bpp, uint32_t _srcPitch, const void* _src, void* _dst);
|
2013-11-08 23:53:23 -05:00
|
|
|
|
2013-09-02 19:22:53 -04:00
|
|
|
///
|
|
|
|
void imageWriteTga(bx::WriterI* _writer, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale, bool _yflip);
|
|
|
|
|
|
|
|
///
|
|
|
|
bool imageParse(ImageContainer& _imageContainer, bx::ReaderSeekerI* _reader);
|
|
|
|
|
|
|
|
///
|
2013-09-09 00:03:03 -04:00
|
|
|
bool imageParse(ImageContainer& _imageContainer, const void* _data, uint32_t _size);
|
|
|
|
|
|
|
|
///
|
2015-04-11 03:17:49 -04:00
|
|
|
void imageDecodeToBgra8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint32_t _pitch, uint8_t _type);
|
|
|
|
|
|
|
|
///
|
|
|
|
void imageDecodeToRgba8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint32_t _pitch, uint8_t _type);
|
2013-09-02 19:22:53 -04:00
|
|
|
|
|
|
|
///
|
2013-09-09 00:03:03 -04:00
|
|
|
bool imageGetRawData(const ImageContainer& _dds, uint8_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);
|
2013-09-02 19:22:53 -04:00
|
|
|
|
|
|
|
} // namespace bgfx
|
|
|
|
|
2013-11-14 00:54:36 -05:00
|
|
|
#endif // BGFX_IMAGE_H_HEADER_GUARD
|