Commit 2a48a5f8 authored by Michael Natterer's avatar Michael Natterer 😴

plug-ins: big formatting and indentation cleanup in file-dds

Also change the license to GPL 3 or later, like all other files.
parent 1c91578b
/*
DDS GIMP plugin
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include <math.h>
#include "color.h"
int linear_to_sRGB(int c)
int
linear_to_sRGB(int c)
{
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.0031308f)
v = 12.92f * v;
else
v = 1.055f * powf(v, 0.41666f) - 0.055f;
return((int)floorf(255.0f * v + 0.5f));
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.0031308f)
v = 12.92f * v;
else
v = 1.055f * powf(v, 0.41666f) - 0.055f;
return (int)floorf(255.0f * v + 0.5f);
}
int sRGB_to_linear(int c)
int
sRGB_to_linear(int c)
{
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.04045f)
v /= 12.92f;
else
v = powf((v + 0.055f) / 1.055f, 2.4f);
return((int)floorf(255.0f * v + 0.5f));
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.04045f)
v /= 12.92f;
else
v = powf((v + 0.055f) / 1.055f, 2.4f);
return (int)floorf(255.0f * v + 0.5f);
}
/*
DDS GIMP plugin
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef COLOR_H
#define COLOR_H
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __COLOR_H__
#define __COLOR_H__
#include "imath.h"
......@@ -30,62 +28,69 @@ int linear_to_sRGB(int c);
int sRGB_to_linear(int c);
/* YCoCg encoding */
static inline void RGB_to_YCoCg(unsigned char *dst, int r, int g, int b)
static inline void
RGB_to_YCoCg (unsigned char *dst, int r, int g, int b)
{
int y = ((r + (g << 1) + b) + 2) >> 2;
int co = ((((r << 1) - (b << 1)) + 2) >> 2) + 128;
int cg = (((-r + (g << 1) - b) + 2) >> 2) + 128;
dst[0] = 255;
dst[1] = (cg > 255 ? 255 : (cg < 0 ? 0 : cg));
dst[2] = (co > 255 ? 255 : (co < 0 ? 0 : co));
dst[3] = (y > 255 ? 255 : (y < 0 ? 0 : y));
int y = ((r + (g << 1) + b) + 2) >> 2;
int co = ((((r << 1) - (b << 1)) + 2) >> 2) + 128;
int cg = (((-r + (g << 1) - b) + 2) >> 2) + 128;
dst[0] = 255;
dst[1] = (cg > 255 ? 255 : (cg < 0 ? 0 : cg));
dst[2] = (co > 255 ? 255 : (co < 0 ? 0 : co));
dst[3] = (y > 255 ? 255 : (y < 0 ? 0 : y));
}
/* other color conversions */
static inline int rgb_to_luminance(int r, int g, int b)
static inline int
rgb_to_luminance (int r, int g, int b)
{
/* ITU-R BT.709 luma coefficents, scaled by 256 */
return(((r * 54 + g * 182 + b * 20) + 128) >> 8);
/* ITU-R BT.709 luma coefficents, scaled by 256 */
return ((r * 54 + g * 182 + b * 20) + 128) >> 8;
}
static inline unsigned short pack_r5g6b5(int r, int g, int b)
static inline unsigned short
pack_r5g6b5 (int r, int g, int b)
{
return((mul8bit(r, 31) << 11) |
(mul8bit(g, 63) << 5) |
(mul8bit(b, 31) ));
return (mul8bit(r, 31) << 11) |
(mul8bit(g, 63) << 5) |
(mul8bit(b, 31) );
}
static inline unsigned short pack_rgba4(int r, int g, int b, int a)
static inline unsigned short
pack_rgba4 (int r, int g, int b, int a)
{
return((mul8bit(a, 15) << 12) |
(mul8bit(r, 15) << 8) |
(mul8bit(g, 15) << 4) |
(mul8bit(b, 15) ));
return (mul8bit(a, 15) << 12) |
(mul8bit(r, 15) << 8) |
(mul8bit(g, 15) << 4) |
(mul8bit(b, 15) );
}
static inline unsigned short pack_rgb5a1(int r, int g, int b, int a)
static inline unsigned short
pack_rgb5a1 (int r, int g, int b, int a)
{
return((((a >> 7) & 0x01) << 15) |
(mul8bit(r, 31) << 10) |
(mul8bit(g, 31) << 5) |
(mul8bit(b, 31) ));
return (((a >> 7) & 0x01) << 15) |
(mul8bit(r, 31) << 10) |
(mul8bit(g, 31) << 5) |
(mul8bit(b, 31) );
}
static inline unsigned char pack_r3g3b2(int r, int g, int b)
static inline unsigned char
pack_r3g3b2(int r, int g, int b)
{
return((mul8bit(r, 7) << 5) |
(mul8bit(g, 7) << 2) |
(mul8bit(b, 3) ));
return (mul8bit(r, 7) << 5) |
(mul8bit(g, 7) << 2) |
(mul8bit(b, 3) );
}
static inline unsigned int pack_rgb10a2(int r, int g, int b, int a)
static inline unsigned int
pack_rgb10a2 (int r, int g, int b, int a)
{
return(((unsigned int)((a >> 6) & 0x003) << 30) |
((unsigned int)((r << 2) & 0x3ff) << 20) |
((unsigned int)((g << 2) & 0x3ff) << 10) |
((unsigned int)((b << 2) & 0x3ff) ));
return ((unsigned int)((a >> 6) & 0x003) << 30) |
((unsigned int)((r << 2) & 0x3ff) << 20) |
((unsigned int)((g << 2) & 0x3ff) << 10) |
((unsigned int)((b << 2) & 0x3ff) );
}
#endif
#endif /* __COLOR_H__ */
......@@ -37,6 +37,7 @@
#include "dds.h"
#include "misc.h"
static void query (void);
static void run (const gchar *name,
gint nparams,
......@@ -44,6 +45,7 @@ static void run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO =
{
0,
......@@ -52,7 +54,6 @@ GimpPlugInInfo PLUG_IN_INFO =
run
};
DDSWriteVals dds_write_vals =
{
DDS_COMPRESS_NONE,
......@@ -73,55 +74,57 @@ DDSWriteVals dds_write_vals =
DDSReadVals dds_read_vals =
{
1,
1
1,
1
};
static GimpParamDef load_args[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_STRING, "filename", "The name of the file to load"},
{GIMP_PDB_STRING, "raw_filename", "The name entered"},
{GIMP_PDB_INT32, "load_mipmaps", "Load mipmaps if present"},
{GIMP_PDB_INT32, "decode_images", "Decode YCoCg/AExp images when detected"}
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_STRING, "filename", "The name of the file to load"},
{ GIMP_PDB_STRING, "raw_filename", "The name entered"},
{ GIMP_PDB_INT32, "load_mipmaps", "Load mipmaps if present"},
{ GIMP_PDB_INT32, "decode_images", "Decode YCoCg/AExp images when detected"}
};
static GimpParamDef load_return_vals[] =
{
{GIMP_PDB_IMAGE, "image", "Output image"}
{ GIMP_PDB_IMAGE, "image", "Output image"}
};
static GimpParamDef save_args[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image"},
{GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"},
{GIMP_PDB_STRING, "filename", "The name of the file to save the image as"},
{GIMP_PDB_STRING, "raw_filename", "The name entered"},
{GIMP_PDB_INT32, "compression_format", "Compression format (0 = None, 1 = BC1/DXT1, 2 = BC2/DXT3, 3 = BC3/DXT5, 4 = BC3n/DXT5nm, 5 = BC4/ATI1N, 6 = BC5/ATI2N, 7 = RXGB (DXT5), 8 = Alpha Exponent (DXT5), 9 = YCoCg (DXT5), 10 = YCoCg scaled (DXT5))"},
{GIMP_PDB_INT32, "mipmaps", "How to handle mipmaps (0 = No mipmaps, 1 = Generate mipmaps, 2 = Use existing mipmaps (layers)"},
{GIMP_PDB_INT32, "savetype", "How to save the image (0 = selected layer, 1 = cube map, 2 = volume map, 3 = texture array"},
{GIMP_PDB_INT32, "format", "Custom pixel format (0 = default, 1 = R5G6B5, 2 = RGBA4, 3 = RGB5A1, 4 = RGB10A2)"},
{GIMP_PDB_INT32, "transparent_index", "Index of transparent color or -1 to disable (for indexed images only)."},
{GIMP_PDB_INT32, "mipmap_filter", "Filtering to use when generating mipmaps (0 = default, 1 = nearest, 2 = box, 3 = triangle, 4 = quadratic, 5 = bspline, 6 = mitchell, 7 = lanczos, 8 = kaiser)"},
{GIMP_PDB_INT32, "mipmap_wrap", "Wrap mode to use when generating mipmaps (0 = default, 1 = mirror, 2 = repeat, 3 = clamp)"},
{GIMP_PDB_INT32, "gamma_correct", "Use gamma correct mipmap filtering"},
{GIMP_PDB_INT32, "srgb", "Use sRGB colorspace for gamma correction"},
{GIMP_PDB_FLOAT, "gamma", "Gamma value to use for gamma correction (i.e. 2.2)"},
{GIMP_PDB_INT32, "perceptual_metric", "Use a perceptual error metric during compression"},
{GIMP_PDB_INT32, "preserve_alpha_coverage", "Preserve alpha test converage for alpha channel maps"},
{GIMP_PDB_FLOAT, "alpha_test_threshold", "Alpha test threshold value for which alpha test converage should be preserved"}
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_IMAGE, "image", "Input image"},
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"},
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image as"},
{ GIMP_PDB_STRING, "raw_filename", "The name entered"},
{ GIMP_PDB_INT32, "compression_format", "Compression format (0 = None, 1 = BC1/DXT1, 2 = BC2/DXT3, 3 = BC3/DXT5, 4 = BC3n/DXT5nm, 5 = BC4/ATI1N, 6 = BC5/ATI2N, 7 = RXGB (DXT5), 8 = Alpha Exponent (DXT5), 9 = YCoCg (DXT5), 10 = YCoCg scaled (DXT5))"},
{ GIMP_PDB_INT32, "mipmaps", "How to handle mipmaps (0 = No mipmaps, 1 = Generate mipmaps, 2 = Use existing mipmaps (layers)"},
{ GIMP_PDB_INT32, "savetype", "How to save the image (0 = selected layer, 1 = cube map, 2 = volume map, 3 = texture array"},
{ GIMP_PDB_INT32, "format", "Custom pixel format (0 = default, 1 = R5G6B5, 2 = RGBA4, 3 = RGB5A1, 4 = RGB10A2)"},
{ GIMP_PDB_INT32, "transparent_index", "Index of transparent color or -1 to disable (for indexed images only)."},
{ GIMP_PDB_INT32, "mipmap_filter", "Filtering to use when generating mipmaps (0 = default, 1 = nearest, 2 = box, 3 = triangle, 4 = quadratic, 5 = bspline, 6 = mitchell, 7 = lanczos, 8 = kaiser)"},
{ GIMP_PDB_INT32, "mipmap_wrap", "Wrap mode to use when generating mipmaps (0 = default, 1 = mirror, 2 = repeat, 3 = clamp)"},
{ GIMP_PDB_INT32, "gamma_correct", "Use gamma correct mipmap filtering"},
{ GIMP_PDB_INT32, "srgb", "Use sRGB colorspace for gamma correction"},
{ GIMP_PDB_FLOAT, "gamma", "Gamma value to use for gamma correction (i.e. 2.2)"},
{ GIMP_PDB_INT32, "perceptual_metric", "Use a perceptual error metric during compression"},
{ GIMP_PDB_INT32, "preserve_alpha_coverage", "Preserve alpha test converage for alpha channel maps"},
{ GIMP_PDB_FLOAT, "alpha_test_threshold", "Alpha test threshold value for which alpha test converage should be preserved"}
};
static GimpParamDef decode_args[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image"},
{GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"}
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_IMAGE, "image", "Input image"},
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"}
};
MAIN ()
static void
query (void)
{
......@@ -225,7 +228,7 @@ run (const gchar *name,
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
if (!strcmp (name, LOAD_PROC))
if (! strcmp (name, LOAD_PROC))
{
switch (run_mode)
{
......@@ -233,12 +236,14 @@ run (const gchar *name,
gimp_ui_init ("dds", 0);
gimp_get_data (LOAD_PROC, &dds_read_vals);
break;
case GIMP_RUN_NONINTERACTIVE:
dds_read_vals.mipmaps = param[3].data.d_int32;
dds_read_vals.decode_images = param[4].data.d_int32;
if (nparams != G_N_ELEMENTS (load_args))
status = GIMP_PDB_CALLING_ERROR;
break;
default:
break;
}
......@@ -256,12 +261,14 @@ run (const gchar *name,
gimp_set_data (LOAD_PROC, &dds_read_vals, sizeof (dds_read_vals));
}
else if (status != GIMP_PDB_CANCEL)
status = GIMP_PDB_EXECUTION_ERROR;
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
}
else if (!strcmp (name, SAVE_PROC))
else if (! strcmp (name, SAVE_PROC))
{
imageID = param[1].data.d_int32;
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
switch (run_mode)
......@@ -280,6 +287,7 @@ run (const gchar *name,
values[0].data.d_status = GIMP_PDB_CANCEL;
return;
}
default:
break;
}
......@@ -289,48 +297,70 @@ run (const gchar *name,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (SAVE_PROC, &dds_write_vals);
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams != G_N_ELEMENTS (save_args))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
dds_write_vals.compression = param[5].data.d_int32;
dds_write_vals.mipmaps = param[6].data.d_int32;
dds_write_vals.savetype = param[7].data.d_int32;
dds_write_vals.format = param[8].data.d_int32;
dds_write_vals.transindex = param[9].data.d_int32;
dds_write_vals.mipmap_filter = param[10].data.d_int32;
dds_write_vals.mipmap_wrap = param[11].data.d_int32;
dds_write_vals.gamma_correct = param[12].data.d_int32;
dds_write_vals.srgb = param[13].data.d_int32;
dds_write_vals.gamma = param[14].data.d_float;
dds_write_vals.perceptual_metric = param[15].data.d_int32;
dds_write_vals.compression = param[5].data.d_int32;
dds_write_vals.mipmaps = param[6].data.d_int32;
dds_write_vals.savetype = param[7].data.d_int32;
dds_write_vals.format = param[8].data.d_int32;
dds_write_vals.transindex = param[9].data.d_int32;
dds_write_vals.mipmap_filter = param[10].data.d_int32;
dds_write_vals.mipmap_wrap = param[11].data.d_int32;
dds_write_vals.gamma_correct = param[12].data.d_int32;
dds_write_vals.srgb = param[13].data.d_int32;
dds_write_vals.gamma = param[14].data.d_float;
dds_write_vals.perceptual_metric = param[15].data.d_int32;
dds_write_vals.preserve_alpha_coverage = param[16].data.d_int32;
dds_write_vals.alpha_test_threshold = param[17].data.d_float;
dds_write_vals.alpha_test_threshold = param[17].data.d_float;
if ((dds_write_vals.compression < DDS_COMPRESS_NONE) ||
(dds_write_vals.compression >= DDS_COMPRESS_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.mipmaps < DDS_MIPMAP_NONE) ||
(dds_write_vals.mipmaps >= DDS_MIPMAP_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.savetype < DDS_SAVE_SELECTED_LAYER) ||
(dds_write_vals.savetype >= DDS_SAVE_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.format < DDS_FORMAT_DEFAULT) ||
(dds_write_vals.format >= DDS_FORMAT_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.mipmap_filter < DDS_MIPMAP_FILTER_DEFAULT) ||
(dds_write_vals.mipmap_filter >= DDS_MIPMAP_FILTER_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.mipmap_wrap < DDS_MIPMAP_WRAP_DEFAULT) ||
(dds_write_vals.mipmap_wrap >= DDS_MIPMAP_WRAP_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
}
break;
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (SAVE_PROC, &dds_write_vals);
break;
default:
break;
}
......@@ -353,7 +383,7 @@ run (const gchar *name,
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (imageID);
}
else if (!strcmp (name, DECODE_YCOCG_PROC))
else if (! strcmp (name, DECODE_YCOCG_PROC))
{
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
......@@ -365,7 +395,7 @@ run (const gchar *name,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
}
else if (!strcmp (name, DECODE_YCOCG_SCALED_PROC))
else if (! strcmp (name, DECODE_YCOCG_SCALED_PROC))
{
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
......@@ -377,7 +407,7 @@ run (const gchar *name,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
}
else if (!strcmp (name, DECODE_ALPHA_EXP_PROC))
else if (! strcmp (name, DECODE_ALPHA_EXP_PROC))
{
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
......@@ -390,7 +420,9 @@ run (const gchar *name,
gimp_displays_flush ();
}
else
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
values[0].data.d_status = status;
}
......@@ -4,24 +4,22 @@
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DDS_H
#define DDS_H
#ifndef __DDS_H__
#define __DDS_H__
#define FOURCC(a, b, c, d) \
((unsigned int)((unsigned int)(a) ) | \
......@@ -31,78 +29,78 @@
typedef enum
{
DDS_COMPRESS_NONE = 0,
DDS_COMPRESS_BC1, /* DXT1 */
DDS_COMPRESS_BC2, /* DXT3 */
DDS_COMPRESS_BC3, /* DXT5 */
DDS_COMPRESS_BC3N, /* DXT5n */
DDS_COMPRESS_BC4, /* ATI1 */
DDS_COMPRESS_BC5, /* ATI2 */
DDS_COMPRESS_RXGB, /* DXT5 */
DDS_COMPRESS_AEXP, /* DXT5 */
DDS_COMPRESS_YCOCG, /* DXT5 */
DDS_COMPRESS_YCOCGS, /* DXT5 */
DDS_COMPRESS_MAX
DDS_COMPRESS_NONE = 0,
DDS_COMPRESS_BC1, /* DXT1 */
DDS_COMPRESS_BC2, /* DXT3 */
DDS_COMPRESS_BC3, /* DXT5 */
DDS_COMPRESS_BC3N, /* DXT5n */
DDS_COMPRESS_BC4, /* ATI1 */
DDS_COMPRESS_BC5, /* ATI2 */
DDS_COMPRESS_RXGB, /* DXT5 */
DDS_COMPRESS_AEXP, /* DXT5 */
DDS_COMPRESS_YCOCG, /* DXT5 */
DDS_COMPRESS_YCOCGS, /* DXT5 */
DDS_COMPRESS_MAX
} DDS_COMPRESSION_TYPE;
typedef enum
{
DDS_SAVE_SELECTED_LAYER = 0,
DDS_SAVE_CUBEMAP,
DDS_SAVE_VOLUMEMAP,
DDS_SAVE_ARRAY,
DDS_SAVE_MAX
DDS_SAVE_SELECTED_LAYER = 0,
DDS_SAVE_CUBEMAP,
DDS_SAVE_VOLUMEMAP,
DDS_SAVE_ARRAY,
DDS_SAVE_MAX
} DDS_SAVE_TYPE;
typedef enum
{
DDS_FORMAT_DEFAULT = 0,
DDS_FORMAT_RGB8,
DDS_FORMAT_RGBA8,
DDS_FORMAT_BGR8,
DDS_FORMAT_ABGR8,
DDS_FORMAT_R5G6B5,
DDS_FORMAT_RGBA4,
DDS_FORMAT_RGB5A1,
DDS_FORMAT_RGB10A2,
DDS_FORMAT_R3G3B2,
DDS_FORMAT_A8,
DDS_FORMAT_L8,
DDS_FORMAT_L8A8,
DDS_FORMAT_AEXP,
DDS_FORMAT_YCOCG,
DDS_FORMAT_MAX
DDS_FORMAT_DEFAULT = 0,
DDS_FORMAT_RGB8,
DDS_FORMAT_RGBA8,
DDS_FORMAT_BGR8,
DDS_FORMAT_ABGR8,
DDS_FORMAT_R5G6B5,
DDS_FORMAT_RGBA4,
DDS_FORMAT_RGB5A1,
DDS_FORMAT_RGB10A2,
DDS_FORMAT_R3G3B2,
DDS_FORMAT_A8,
DDS_FORMAT_L8,
DDS_FORMAT_L8A8,
DDS_FORMAT_AEXP,
DDS_FORMAT_YCOCG,
DDS_FORMAT_MAX
} DDS_FORMAT_TYPE;
typedef enum
{
DDS_MIPMAP_NONE = 0,
DDS_MIPMAP_GENERATE,
DDS_MIPMAP_EXISTING,
DDS_MIPMAP_MAX
DDS_MIPMAP_NONE = 0,
DDS_MIPMAP_GENERATE,
DDS_MIPMAP_EXISTING,
DDS_MIPMAP_MAX
} DDS_MIPMAP;
typedef enum
{
DDS_MIPMAP_FILTER_DEFAULT = 0,
DDS_MIPMAP_FILTER_NEAREST,
DDS_MIPMAP_FILTER_BOX,
DDS_MIPMAP_FILTER_TRIANGLE,
DDS_MIPMAP_FILTER_QUADRATIC,
DDS_MIPMAP_FILTER_BSPLINE,
DDS_MIPMAP_FILTER_MITCHELL,
DDS_MIPMAP_FILTER_LANCZOS,
DDS_MIPMAP_FILTER_KAISER,
DDS_MIPMAP_FILTER_MAX
DDS_MIPMAP_FILTER_DEFAULT = 0,
DDS_MIPMAP_FILTER_NEAREST,
DDS_MIPMAP_FILTER_BOX,
DDS_MIPMAP_FILTER_TRIANGLE,
DDS_MIPMAP_FILTER_QUADRATIC,
DDS_MIPMAP_FILTER_BSPLINE,
DDS_MIPMAP_FILTER_MITCHELL,
DDS_MIPMAP_FILTER_LANCZOS,
DDS_MIPMAP_FILTER_KAISER,
DDS_MIPMAP_FILTER_MAX
} DDS_MIPMAP_FILTER;
typedef enum
{
DDS_MIPMAP_WRAP_DEFAULT = 0,
DDS_MIPMAP_WRAP_MIRROR,
DDS_MIPMAP_WRAP_REPEAT,
DDS_MIPMAP_WRAP_CLAMP,
DDS_MIPMAP_WRAP_MAX
DDS_MIPMAP_WRAP_DEFAULT = 0,
DDS_MIPMAP_WRAP_MIRROR,
DDS_MIPMAP_WRAP_REPEAT,
DDS_MIPMAP_WRAP_CLAMP,
DDS_MIPMAP_WRAP_MAX
} DDS_MIPMAP_WRAP;
#define DDS_HEADERSIZE 128
......@@ -151,177 +149,177 @@ typedef enum
typedef struct
{
unsigned int size;
unsigned int flags;
char fourcc[4];
unsigned int bpp;
unsigned int rmask;
unsigned int gmask;
unsigned int bmask;
unsigned int amask;
unsigned int size;
unsigned int flags;
char fourcc[4];
<