Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/GlideHQ/TxImage.h
2 views
1
/*
2
* Texture Filtering
3
* Version: 1.0
4
*
5
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
6
* Email koolsmoky(at)users.sourceforge.net
7
* Web http://www.3dfxzone.it/koolsmoky
8
*
9
* this is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2, or (at your option)
12
* any later version.
13
*
14
* this is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with GNU Make; see the file COPYING. If not, write to
21
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
*/
23
24
#ifndef __TXIMAGE_H__
25
#define __TXIMAGE_H__
26
27
#include <stdio.h>
28
#include <png.h>
29
#include "TxInternal.h"
30
31
#ifndef WIN32
32
typedef struct tagBITMAPFILEHEADER {
33
uint16_t bfType;
34
uint32_t bfSize;
35
uint16_t bfReserved1;
36
uint16_t bfReserved2;
37
uint32_t bfOffBits;
38
} BITMAPFILEHEADER;
39
40
typedef struct tagBITMAPINFOHEADER {
41
uint32_t biSize;
42
int32_t biWidth;
43
int32_t biHeight;
44
uint16_t biPlanes;
45
uint16_t biBitCount;
46
uint32_t biCompression;
47
uint32_t biSizeImage;
48
uint32_t biXPelsPerMeter;
49
uint32_t biYPelsPerMeter;
50
uint32_t biClrUsed;
51
uint32_t biClrImportant;
52
} BITMAPINFOHEADER;
53
#else
54
typedef struct tagBITMAPFILEHEADER BITMAPFILEHEADER;
55
typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER;
56
#endif
57
58
#define DDSD_CAPS 0x00000001
59
#define DDSD_HEIGHT 0x00000002
60
#define DDSD_WIDTH 0x00000004
61
#define DDSD_PITCH 0x00000008
62
#define DDSD_PIXELFORMAT 0x00001000
63
#define DDSD_MIPMAPCOUNT 0x00020000
64
#define DDSD_LINEARSIZE 0x00080000
65
#define DDSD_DEPTH 0x00800000
66
67
#define DDPF_ALPHAPIXELS 0x00000001
68
#define DDPF_FOURCC 0x00000004
69
#define DDPF_RGB 0x00000040
70
71
#define DDSCAPS_COMPLEX 0x00000008
72
#define DDSCAPS_TEXTURE 0x00001000
73
#define DDSCAPS_MIPMAP 0x00400000
74
75
typedef struct tagDDSPIXELFORMAT {
76
uint32_t dwSize;
77
uint32_t dwFlags;
78
uint32_t dwFourCC;
79
uint32_t dwRGBBitCount;
80
uint32_t dwRBitMask;
81
uint32_t dwGBitMask;
82
uint32_t dwBBitMask;
83
uint32_t dwRGBAlphaBitMask;
84
} DDSPIXELFORMAT;
85
86
typedef struct tagDDSFILEHEADER {
87
uint32_t dwMagic;
88
uint32_t dwSize;
89
uint32_t dwFlags;
90
uint32_t dwHeight;
91
uint32_t dwWidth;
92
uint32_t dwLinearSize;
93
uint32_t dwDepth;
94
uint32_t dwMipMapCount;
95
uint32_t dwReserved1[11];
96
DDSPIXELFORMAT ddpf;
97
uint32_t dwCaps1;
98
uint32_t dwCaps2;
99
} DDSFILEHEADER;
100
101
class TxImage
102
{
103
private:
104
boolean getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr);
105
boolean getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr);
106
boolean getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr);
107
public:
108
TxImage() {}
109
~TxImage() {}
110
uint8* readPNG(FILE* fp, int* width, int* height, uint16* format);
111
boolean writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette);
112
uint8* readBMP(FILE* fp, int* width, int* height, uint16* format);
113
uint8* readDDS(FILE* fp, int* width, int* height, uint16* format);
114
};
115
116
#endif /* __TXIMAGE_H__ */
117
118