Browse Source

engine: imagelib: refactor to use stdint.h definitions, use spaces for alignment instead of tabs

pull/2/head
Alibek Omarov 5 years ago
parent
commit
46b0590e4e
  1. 30
      engine/common/imagelib/img_bmp.h
  2. 50
      engine/common/imagelib/img_dds.h
  3. 42
      engine/common/imagelib/img_png.h
  4. 24
      engine/common/imagelib/img_tga.h

30
engine/common/imagelib/img_bmp.h

@ -30,21 +30,21 @@ GNU General Public License for more details.
#pragma pack( push, 1 ) #pragma pack( push, 1 )
typedef struct typedef struct
{ {
char id[2]; // bmfh.bfType int8_t id[2]; // bmfh.bfType
dword fileSize; // bmfh.bfSize uint32_t fileSize; // bmfh.bfSize
dword reserved0; // bmfh.bfReserved1 + bmfh.bfReserved2 uint32_t reserved0; // bmfh.bfReserved1 + bmfh.bfReserved2
dword bitmapDataOffset; // bmfh.bfOffBits uint32_t bitmapDataOffset; // bmfh.bfOffBits
dword bitmapHeaderSize; // bmih.biSize uint32_t bitmapHeaderSize; // bmih.biSize
int width; // bmih.biWidth int32_t width; // bmih.biWidth
int height; // bmih.biHeight int32_t height; // bmih.biHeight
word planes; // bmih.biPlanes uint16_t planes; // bmih.biPlanes
word bitsPerPixel; // bmih.biBitCount uint16_t bitsPerPixel; // bmih.biBitCount
dword compression; // bmih.biCompression uint32_t compression; // bmih.biCompression
dword bitmapDataSize; // bmih.biSizeImage uint32_t bitmapDataSize; // bmih.biSizeImage
dword hRes; // bmih.biXPelsPerMeter uint32_t hRes; // bmih.biXPelsPerMeter
dword vRes; // bmih.biYPelsPerMeter uint32_t vRes; // bmih.biYPelsPerMeter
dword colors; // bmih.biClrUsed uint32_t colors; // bmih.biClrUsed
dword importantColors; // bmih.biClrImportant uint32_t importantColors; // bmih.biClrImportant
} bmp_t; } bmp_t;
#pragma pack( pop ) #pragma pack( pop )
#endif // IMG_BMP_H #endif // IMG_BMP_H

50
engine/common/imagelib/img_dds.h

@ -77,40 +77,40 @@ GNU General Public License for more details.
typedef struct dds_pf_s typedef struct dds_pf_s
{ {
uint dwSize; uint32_t dwSize;
uint dwFlags; uint32_t dwFlags;
uint dwFourCC; uint32_t dwFourCC;
uint dwRGBBitCount; uint32_t dwRGBBitCount;
uint dwRBitMask; uint32_t dwRBitMask;
uint dwGBitMask; uint32_t dwGBitMask;
uint dwBBitMask; uint32_t dwBBitMask;
uint dwABitMask; uint32_t dwABitMask;
} dds_pixf_t; } dds_pixf_t;
// DDCAPS2 // DDCAPS2
typedef struct dds_caps_s typedef struct dds_caps_s
{ {
uint dwCaps1; uint32_t dwCaps1;
uint dwCaps2; uint32_t dwCaps2;
uint dwCaps3; // currently unused uint32_t dwCaps3; // currently unused
uint dwCaps4; // currently unused uint32_t dwCaps4; // currently unused
} dds_caps_t; } dds_caps_t;
typedef struct dds_s typedef struct dds_s
{ {
uint dwIdent; // must matched with DDSHEADER uint32_t dwIdent; // must matched with DDSHEADER
uint dwSize; uint32_t dwSize;
uint dwFlags; // determines what fields are valid uint32_t dwFlags; // determines what fields are valid
uint dwHeight; uint32_t dwHeight;
uint dwWidth; uint32_t dwWidth;
uint dwLinearSize; // Formless late-allocated optimized surface size uint32_t dwLinearSize; // Formless late-allocated optimized surface size
uint dwDepth; // depth if a volume texture uint32_t dwDepth; // depth if a volume texture
uint dwMipMapCount; // number of mip-map levels requested uint32_t dwMipMapCount; // number of mip-map levels requested
uint dwAlphaBitDepth; // depth of alpha buffer requested uint32_t dwAlphaBitDepth; // depth of alpha buffer requested
uint dwReserved1[10]; // reserved for future expansions uint32_t dwReserved1[10]; // reserved for future expansions
dds_pixf_t dsPixelFormat; dds_pixf_t dsPixelFormat;
dds_caps_t dsCaps; dds_caps_t dsCaps;
uint dwTextureStage; uint32_t dwTextureStage;
} dds_t; } dds_t;
#endif // IMG_DDS_H #endif // IMG_DDS_H

42
engine/common/imagelib/img_png.h

@ -22,52 +22,52 @@ GNU General Public License for more details.
======================================================================== ========================================================================
*/ */
enum enum png_colortype
{ {
PNG_CT_GREY, PNG_CT_GREY,
PNG_CT_PALLETE = BIT(0), PNG_CT_PALLETE = BIT(0),
PNG_CT_RGB = BIT(1), PNG_CT_RGB = BIT(1),
PNG_CT_ALPHA = BIT(2), PNG_CT_ALPHA = BIT(2),
PNG_CT_RGBA = (PNG_CT_RGB|PNG_CT_ALPHA) PNG_CT_RGBA = (PNG_CT_RGB|PNG_CT_ALPHA)
} png_colortype; };
enum enum png_filter
{ {
PNG_F_NONE, PNG_F_NONE,
PNG_F_SUB, PNG_F_SUB,
PNG_F_UP, PNG_F_UP,
PNG_F_AVERAGE, PNG_F_AVERAGE,
PNG_F_PAETH PNG_F_PAETH
} png_filter; };
#pragma pack( push, 1 ) #pragma pack( push, 1 )
typedef struct png_ihdr_s typedef struct png_ihdr_s
{ {
uint width; uint32_t width;
uint height; uint32_t height;
byte bitdepth; uint8_t bitdepth;
byte colortype; uint8_t colortype;
byte compression; uint8_t compression;
byte filter; uint8_t filter;
byte interlace; uint8_t interlace;
} png_ihdr_t; } png_ihdr_t;
typedef struct png_s typedef struct png_s
{ {
byte sign[8]; uint8_t sign[8];
uint ihdr_len; uint32_t ihdr_len;
byte ihdr_sign[4]; uint8_t ihdr_sign[4];
png_ihdr_t ihdr_chunk; png_ihdr_t ihdr_chunk;
uint ihdr_crc32; uint32_t ihdr_crc32;
} png_t; } png_t;
#pragma pack( pop )
typedef struct png_footer_s typedef struct png_footer_s
{ {
uint idat_crc32; uint32_t idat_crc32;
uint iend_len; uint32_t iend_len;
byte iend_sign[4]; uint8_t iend_sign[4];
uint iend_crc32; uint32_t iend_crc32;
} png_footer_t; } png_footer_t;
#pragma pack( pop )
#endif // IMG_PNG_H #endif // IMG_PNG_H

24
engine/common/imagelib/img_tga.h

@ -24,18 +24,18 @@ GNU General Public License for more details.
#pragma pack( push, 1 ) #pragma pack( push, 1 )
typedef struct tga_s typedef struct tga_s
{ {
byte id_length; uint8_t id_length;
byte colormap_type; uint8_t colormap_type;
byte image_type; uint8_t image_type;
word colormap_index; uint16_t colormap_index;
word colormap_length; uint16_t colormap_length;
byte colormap_size; uint8_t colormap_size;
word x_origin; uint16_t x_origin;
word y_origin; uint16_t y_origin;
word width; uint16_t width;
word height; uint16_t height;
byte pixel_size; uint8_t pixel_size;
byte attributes; uint8_t attributes;
} tga_t; } tga_t;
#pragma pack( pop ) #pragma pack( pop )
#endif // IMG_TGA_H #endif // IMG_TGA_H

Loading…
Cancel
Save