Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/GlideHQ/TxImage.h
2 views
/*1* Texture Filtering2* Version: 1.03*4* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.5* Email koolsmoky(at)users.sourceforge.net6* Web http://www.3dfxzone.it/koolsmoky7*8* this is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2, or (at your option)11* any later version.12*13* this is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with GNU Make; see the file COPYING. If not, write to20* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.21*/2223#ifndef __TXIMAGE_H__24#define __TXIMAGE_H__2526#include <stdio.h>27#include <png.h>28#include "TxInternal.h"2930#ifndef WIN3231typedef struct tagBITMAPFILEHEADER {32uint16_t bfType;33uint32_t bfSize;34uint16_t bfReserved1;35uint16_t bfReserved2;36uint32_t bfOffBits;37} BITMAPFILEHEADER;3839typedef struct tagBITMAPINFOHEADER {40uint32_t biSize;41int32_t biWidth;42int32_t biHeight;43uint16_t biPlanes;44uint16_t biBitCount;45uint32_t biCompression;46uint32_t biSizeImage;47uint32_t biXPelsPerMeter;48uint32_t biYPelsPerMeter;49uint32_t biClrUsed;50uint32_t biClrImportant;51} BITMAPINFOHEADER;52#else53typedef struct tagBITMAPFILEHEADER BITMAPFILEHEADER;54typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER;55#endif5657#define DDSD_CAPS 0x0000000158#define DDSD_HEIGHT 0x0000000259#define DDSD_WIDTH 0x0000000460#define DDSD_PITCH 0x0000000861#define DDSD_PIXELFORMAT 0x0000100062#define DDSD_MIPMAPCOUNT 0x0002000063#define DDSD_LINEARSIZE 0x0008000064#define DDSD_DEPTH 0x008000006566#define DDPF_ALPHAPIXELS 0x0000000167#define DDPF_FOURCC 0x0000000468#define DDPF_RGB 0x000000406970#define DDSCAPS_COMPLEX 0x0000000871#define DDSCAPS_TEXTURE 0x0000100072#define DDSCAPS_MIPMAP 0x004000007374typedef struct tagDDSPIXELFORMAT {75uint32_t dwSize;76uint32_t dwFlags;77uint32_t dwFourCC;78uint32_t dwRGBBitCount;79uint32_t dwRBitMask;80uint32_t dwGBitMask;81uint32_t dwBBitMask;82uint32_t dwRGBAlphaBitMask;83} DDSPIXELFORMAT;8485typedef struct tagDDSFILEHEADER {86uint32_t dwMagic;87uint32_t dwSize;88uint32_t dwFlags;89uint32_t dwHeight;90uint32_t dwWidth;91uint32_t dwLinearSize;92uint32_t dwDepth;93uint32_t dwMipMapCount;94uint32_t dwReserved1[11];95DDSPIXELFORMAT ddpf;96uint32_t dwCaps1;97uint32_t dwCaps2;98} DDSFILEHEADER;99100class TxImage101{102private:103boolean getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr);104boolean getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr);105boolean getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr);106public:107TxImage() {}108~TxImage() {}109uint8* readPNG(FILE* fp, int* width, int* height, uint16* format);110boolean writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette);111uint8* readBMP(FILE* fp, int* width, int* height, uint16* format);112uint8* readDDS(FILE* fp, int* width, int* height, uint16* format);113};114115#endif /* __TXIMAGE_H__ */116117118