mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Cleanup, NOW
This commit is contained in:
parent
bc096d35bb
commit
385a6cf3c3
8 changed files with 217 additions and 188 deletions
|
|
@ -653,13 +653,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
|
||||||
realpatch = (patch_t *)pdata;
|
realpatch = (patch_t *)pdata;
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||||
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false);
|
{
|
||||||
|
// Dummy variables.
|
||||||
|
INT32 pngwidth, pngheight;
|
||||||
|
realpatch = (patch_t *)Picture_PNGConvert(pdata, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, lumplength, NULL, 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef WALLFLATS
|
#ifdef WALLFLATS
|
||||||
if (texture->type == TEXTURETYPE_FLAT)
|
if (texture->type == TEXTURETYPE_FLAT)
|
||||||
realpatch = R_FlatToPatch(pdata, texture->width, texture->height, 0, 0, NULL, false);
|
realpatch = (patch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_PATCH, 0, NULL, texture->width, texture->height, 0, 0, 0);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
@ -697,8 +701,12 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
// lump is a png so convert it
|
// lump is a png so convert it
|
||||||
size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum);
|
size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum);
|
||||||
if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len))
|
if ((patch != NULL) && Picture_IsLumpPNG((const UINT8 *)patch, len))
|
||||||
patch = R_PNGToPatch((const UINT8 *)patch, len, NULL, true);
|
{
|
||||||
|
// Dummy variables.
|
||||||
|
INT32 pngwidth, pngheight;
|
||||||
|
patch = (patch_t *)Picture_PNGConvert((const UINT8 *)patch, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, len, NULL, 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// don't do it twice (like a cache)
|
// don't do it twice (like a cache)
|
||||||
|
|
@ -956,6 +964,8 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||||
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
||||||
{
|
{
|
||||||
UINT8 *flat;
|
UINT8 *flat;
|
||||||
|
UINT8 *converted;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
if (needpatchflush)
|
if (needpatchflush)
|
||||||
W_FlushCachedPatches();
|
W_FlushCachedPatches();
|
||||||
|
|
@ -971,11 +981,12 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
||||||
|
|
||||||
grMipmap->width = (UINT16)textures[texturenum]->width;
|
grMipmap->width = (UINT16)textures[texturenum]->width;
|
||||||
grMipmap->height = (UINT16)textures[texturenum]->height;
|
grMipmap->height = (UINT16)textures[texturenum]->height;
|
||||||
|
size = (grMipmap->width * grMipmap->height);
|
||||||
|
|
||||||
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data);
|
flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->grInfo.data);
|
||||||
memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height);
|
converted = (UINT8 *)Picture_TextureToFlat(texturenum);
|
||||||
|
M_Memcpy(flat, converted, size);
|
||||||
R_TextureToFlat(texturenum, flat);
|
Z_Free(converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
||||||
|
|
|
||||||
|
|
@ -639,7 +639,7 @@ flatfound:
|
||||||
/* This could be a flat, patch, or PNG. */
|
/* This could be a flat, patch, or PNG. */
|
||||||
flatpatch = W_CacheLumpNum(flatnum, PU_STATIC);
|
flatpatch = W_CacheLumpNum(flatnum, PU_STATIC);
|
||||||
lumplength = W_LumpLength(flatnum);
|
lumplength = W_LumpLength(flatnum);
|
||||||
if (R_CheckIfPatch(flatpatch, lumplength))
|
if (Picture_CheckIfPatch(flatpatch, lumplength))
|
||||||
levelflat->type = LEVELFLAT_PATCH;
|
levelflat->type = LEVELFLAT_PATCH;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -651,7 +651,7 @@ flatfound:
|
||||||
if (flatpatch)
|
if (flatpatch)
|
||||||
Z_Free(flatpatch);
|
Z_Free(flatpatch);
|
||||||
W_ReadLumpHeader(flatnum, buffer, 8, 0);
|
W_ReadLumpHeader(flatnum, buffer, 8, 0);
|
||||||
if (R_IsLumpPNG(buffer, lumplength))
|
if (Picture_IsLumpPNG(buffer, lumplength))
|
||||||
levelflat->type = LEVELFLAT_PNG;
|
levelflat->type = LEVELFLAT_PNG;
|
||||||
else
|
else
|
||||||
#endif/*NO_PNG_LUMPS*/
|
#endif/*NO_PNG_LUMPS*/
|
||||||
|
|
|
||||||
24
src/r_data.c
24
src/r_data.c
|
|
@ -473,7 +473,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
realpatch = (patch_t *)pdata;
|
realpatch = (patch_t *)pdata;
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||||
goto multipatch;
|
goto multipatch;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WALLFLATS
|
#ifdef WALLFLATS
|
||||||
|
|
@ -570,13 +570,17 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
dealloc = true;
|
dealloc = true;
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||||
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false);
|
{
|
||||||
|
// Dummy variables.
|
||||||
|
INT32 pngwidth, pngheight;
|
||||||
|
realpatch = (patch_t *)Picture_PNGConvert((UINT8 *)realpatch, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, lumplength, NULL, 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef WALLFLATS
|
#ifdef WALLFLATS
|
||||||
if (texture->type == TEXTURETYPE_FLAT)
|
if (texture->type == TEXTURETYPE_FLAT)
|
||||||
realpatch = R_FlatToPatch(pdata, texture->width, texture->height, 0, 0, NULL, false);
|
realpatch = (patch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_PATCH, 0, NULL, texture->width, texture->height, 0, 0, 0);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
@ -896,10 +900,10 @@ countflats:
|
||||||
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)patchlump, lumplength))
|
if (Picture_IsLumpPNG((UINT8 *)patchlump, lumplength))
|
||||||
{
|
{
|
||||||
INT16 width, height;
|
INT16 width = 0, height = 0;
|
||||||
R_PNGDimensions((UINT8 *)patchlump, &width, &height, lumplength);
|
Picture_PNGDimensions((UINT8 *)patchlump, &width, &height, lumplength);
|
||||||
texture->width = width;
|
texture->width = width;
|
||||||
texture->height = height;
|
texture->height = height;
|
||||||
}
|
}
|
||||||
|
|
@ -999,10 +1003,10 @@ checkflats:
|
||||||
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)flatlump, lumplength))
|
if (Picture_IsLumpPNG((UINT8 *)flatlump, lumplength))
|
||||||
{
|
{
|
||||||
INT16 width, height;
|
INT16 width = 0, height = 0;
|
||||||
R_PNGDimensions((UINT8 *)flatlump, &width, &height, lumplength);
|
Picture_PNGDimensions((UINT8 *)flatlump, &width, &height, lumplength);
|
||||||
texture->width = width;
|
texture->width = width;
|
||||||
texture->height = height;
|
texture->height = height;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ fixed_t sinang2rad[ROTANGLES];
|
||||||
* \param picture Input picture data.
|
* \param picture Input picture data.
|
||||||
* \param outformat Output picture format.
|
* \param outformat Output picture format.
|
||||||
* \param insize Input picture size.
|
* \param insize Input picture size.
|
||||||
* \param outsize Output picture size.
|
* \param outsize Output picture size, as a pointer.
|
||||||
* \param inwidth Input picture width.
|
* \param inwidth Input picture width.
|
||||||
* \param inheight Input picture height.
|
* \param inheight Input picture height.
|
||||||
* \param inleftoffset Input picture left offset, for patches.
|
* \param inleftoffset Input picture left offset, for patches.
|
||||||
|
|
@ -73,8 +73,12 @@ void *Picture_Convert(
|
||||||
INT32 inwidth, INT32 inheight, INT32 inleftoffset, INT32 intopoffset,
|
INT32 inwidth, INT32 inheight, INT32 inleftoffset, INT32 intopoffset,
|
||||||
pictureflags_t flags)
|
pictureflags_t flags)
|
||||||
{
|
{
|
||||||
if (informat == outformat) // wut?
|
if (informat == PICFMT_NONE)
|
||||||
I_Error("Picture_Convert: input and output formats are the same!");
|
I_Error("Picture_Convert: input format was PICFMT_NONE!");
|
||||||
|
else if (outformat == PICFMT_NONE)
|
||||||
|
I_Error("Picture_Convert: output format was PICFMT_NONE!");
|
||||||
|
else if (informat == outformat)
|
||||||
|
I_Error("Picture_Convert: input and output formats were the same!");
|
||||||
|
|
||||||
if (Picture_IsPatchFormat(outformat))
|
if (Picture_IsPatchFormat(outformat))
|
||||||
return Picture_PatchConvert(informat, picture, outformat, insize, outsize, inwidth, inheight, inleftoffset, intopoffset, flags);
|
return Picture_PatchConvert(informat, picture, outformat, insize, outsize, inwidth, inheight, inleftoffset, intopoffset, flags);
|
||||||
|
|
@ -92,7 +96,7 @@ void *Picture_Convert(
|
||||||
* \param picture Input picture data.
|
* \param picture Input picture data.
|
||||||
* \param outformat Output picture format.
|
* \param outformat Output picture format.
|
||||||
* \param insize Input picture size.
|
* \param insize Input picture size.
|
||||||
* \param outsize Output picture size.
|
* \param outsize Output picture size, as a pointer.
|
||||||
* \param inwidth Input picture width.
|
* \param inwidth Input picture width.
|
||||||
* \param inheight Input picture height.
|
* \param inheight Input picture height.
|
||||||
* \param inleftoffset Input picture left offset, for patches.
|
* \param inleftoffset Input picture left offset, for patches.
|
||||||
|
|
@ -116,8 +120,12 @@ void *Picture_PatchConvert(
|
||||||
|
|
||||||
(void)insize; // ignore
|
(void)insize; // ignore
|
||||||
|
|
||||||
if (informat == outformat)
|
if (informat == PICFMT_NONE)
|
||||||
I_Error("Picture_PatchConvert: input and output formats are the same!");
|
I_Error("Picture_PatchConvert: input format was PICFMT_NONE!");
|
||||||
|
else if (outformat == PICFMT_NONE)
|
||||||
|
I_Error("Picture_PatchConvert: output format was PICFMT_NONE!");
|
||||||
|
else if (informat == outformat)
|
||||||
|
I_Error("Picture_PatchConvert: input and output formats were the same!");
|
||||||
|
|
||||||
if (!inbpp)
|
if (!inbpp)
|
||||||
I_Error("Picture_PatchConvert: unknown input bits per pixel?!");
|
I_Error("Picture_PatchConvert: unknown input bits per pixel?!");
|
||||||
|
|
@ -334,7 +342,7 @@ void *Picture_PatchConvert(
|
||||||
* \param picture Input picture data.
|
* \param picture Input picture data.
|
||||||
* \param outformat Output picture format.
|
* \param outformat Output picture format.
|
||||||
* \param insize Input picture size.
|
* \param insize Input picture size.
|
||||||
* \param outsize Output picture size.
|
* \param outsize Output picture size, as a pointer.
|
||||||
* \param inwidth Input picture width.
|
* \param inwidth Input picture width.
|
||||||
* \param inheight Input picture height.
|
* \param inheight Input picture height.
|
||||||
* \param inleftoffset Input picture left offset, for patches.
|
* \param inleftoffset Input picture left offset, for patches.
|
||||||
|
|
@ -359,8 +367,12 @@ void *Picture_FlatConvert(
|
||||||
(void)inleftoffset; // ignore
|
(void)inleftoffset; // ignore
|
||||||
(void)intopoffset; // ignore
|
(void)intopoffset; // ignore
|
||||||
|
|
||||||
if (informat == outformat)
|
if (informat == PICFMT_NONE)
|
||||||
I_Error("Picture_FlatConvert: input and output formats are the same!");
|
I_Error("Picture_FlatConvert: input format was PICFMT_NONE!");
|
||||||
|
else if (outformat == PICFMT_NONE)
|
||||||
|
I_Error("Picture_FlatConvert: output format was PICFMT_NONE!");
|
||||||
|
else if (informat == outformat)
|
||||||
|
I_Error("Picture_FlatConvert: input and output formats were the same!");
|
||||||
|
|
||||||
if (!inbpp)
|
if (!inbpp)
|
||||||
I_Error("Picture_FlatConvert: unknown input bits per pixel?!");
|
I_Error("Picture_FlatConvert: unknown input bits per pixel?!");
|
||||||
|
|
@ -587,7 +599,7 @@ boolean Picture_IsFlatFormat(pictureformat_t format)
|
||||||
* \param picture Input patch size.
|
* \param picture Input patch size.
|
||||||
* \return True if the input patch is valid.
|
* \return True if the input patch is valid.
|
||||||
*/
|
*/
|
||||||
boolean R_CheckIfPatch(patch_t *patch, size_t size)
|
boolean Picture_CheckIfPatch(patch_t *patch, size_t size)
|
||||||
{
|
{
|
||||||
INT16 width, height;
|
INT16 width, height;
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
@ -624,26 +636,40 @@ boolean R_CheckIfPatch(patch_t *patch, size_t size)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/** Converts a texture to a flat.
|
||||||
// R_TextureToFlat
|
*
|
||||||
//
|
* \param trickytex The texture number.
|
||||||
// Convert a texture to a flat.
|
* \return The converted flat.
|
||||||
//
|
*/
|
||||||
void R_TextureToFlat(size_t tex, UINT8 *flat)
|
void *Picture_TextureToFlat(size_t trickytex)
|
||||||
{
|
{
|
||||||
texture_t *texture = textures[tex];
|
texture_t *texture;
|
||||||
|
size_t tex;
|
||||||
|
|
||||||
|
UINT8 *converted;
|
||||||
|
size_t flatsize;
|
||||||
fixed_t col, ofs;
|
fixed_t col, ofs;
|
||||||
column_t *column;
|
column_t *column;
|
||||||
UINT8 *desttop, *dest, *deststop;
|
UINT8 *desttop, *dest, *deststop;
|
||||||
UINT8 *source;
|
UINT8 *source;
|
||||||
|
|
||||||
// yea
|
if (trickytex >= (unsigned)numtextures)
|
||||||
|
I_Error("Picture_TextureToFlat: invalid texture number!");
|
||||||
|
|
||||||
|
// Check the texture cache
|
||||||
|
// If the texture's not there, it'll be generated right now
|
||||||
|
tex = trickytex;
|
||||||
|
texture = textures[tex];
|
||||||
R_CheckTextureCache(tex);
|
R_CheckTextureCache(tex);
|
||||||
|
|
||||||
desttop = flat;
|
// Allocate the flat
|
||||||
deststop = desttop + (texture->width * texture->height);
|
flatsize = (texture->width * texture->height);
|
||||||
|
converted = Z_Malloc(flatsize, PU_STATIC, NULL);
|
||||||
|
memset(converted, TRANSPARENTPIXEL, flatsize);
|
||||||
|
|
||||||
|
// Now we're gonna write to it
|
||||||
|
desttop = converted;
|
||||||
|
deststop = desttop + flatsize;
|
||||||
for (col = 0; col < texture->width; col++, desttop++)
|
for (col = 0; col < texture->width; col++, desttop++)
|
||||||
{
|
{
|
||||||
// no post_t info
|
// no post_t info
|
||||||
|
|
@ -682,61 +708,17 @@ void R_TextureToFlat(size_t tex, UINT8 *flat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/** Returns true if the lump is a valid PNG.
|
||||||
// R_PatchToFlat
|
*
|
||||||
//
|
* \param d The lump to be checked.
|
||||||
// Convert a patch to a flat.
|
* \param s The lump size.
|
||||||
//
|
* \return True if the lump is a PNG image.
|
||||||
void R_PatchToFlat(patch_t *patch, UINT8 *flat)
|
*/
|
||||||
{
|
boolean Picture_IsLumpPNG(const UINT8 *d, size_t s)
|
||||||
size_t outsize = 0;
|
|
||||||
UINT8 *converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT, 0, &outsize, 0, 0, 0, 0, 0);
|
|
||||||
M_Memcpy(flat, converted, outsize);
|
|
||||||
Z_Free(converted);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// R_PatchToFlat_16bpp
|
|
||||||
//
|
|
||||||
// Convert a patch to a 16-bit flat.
|
|
||||||
//
|
|
||||||
void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip)
|
|
||||||
{
|
|
||||||
size_t outsize = 0;
|
|
||||||
UINT16 *converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT16, 0, &outsize, 0, 0, 0, 0, (flip) ? PICFLAGS_XFLIP : 0);
|
|
||||||
M_Memcpy(raw, converted, outsize);
|
|
||||||
Z_Free(converted);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// R_FlatToPatch
|
|
||||||
//
|
|
||||||
// Convert a flat to a patch.
|
|
||||||
//
|
|
||||||
patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency)
|
|
||||||
{
|
|
||||||
(void)transparency;
|
|
||||||
return (patch_t *)Picture_Convert(PICFMT_FLAT, raw, PICFMT_PATCH, 0, destsize, width, height, leftoffset, topoffset, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// R_FlatToPatch_16bpp
|
|
||||||
//
|
|
||||||
// Convert a 16-bit flat to a patch.
|
|
||||||
//
|
|
||||||
patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size)
|
|
||||||
{
|
|
||||||
return (patch_t *)Picture_Convert(PICFMT_FLAT16, raw, PICFMT_PATCH, 0, size, width, height, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// R_IsLumpPNG
|
|
||||||
//
|
|
||||||
// Returns true if the lump is a valid PNG.
|
|
||||||
//
|
|
||||||
boolean R_IsLumpPNG(const UINT8 *d, size_t s)
|
|
||||||
{
|
{
|
||||||
if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/
|
if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -803,7 +785,7 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext)
|
||||||
CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
|
CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static png_bytep *PNG_Read(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
|
static png_bytep *PNG_Read(const UINT8 *png, INT32 *w, INT32 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
|
||||||
{
|
{
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop png_info_ptr;
|
png_infop png_info_ptr;
|
||||||
|
|
@ -824,17 +806,13 @@ static png_bytep *PNG_Read(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoff
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
{
|
I_Error("PNG_Load: Couldn't initialize libpng!");
|
||||||
CONS_Debug(DBG_RENDER, "PNG_Load: Error on initialize libpng\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
png_info_ptr = png_create_info_struct(png_ptr);
|
png_info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (!png_info_ptr)
|
if (!png_info_ptr)
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_RENDER, "PNG_Load: Error on allocate for libpng\n");
|
|
||||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||||
return NULL;
|
I_Error("PNG_Load: libpng couldn't allocate memory!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
|
|
@ -921,22 +899,44 @@ static png_bytep *PNG_Read(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoff
|
||||||
return row_pointers;
|
return row_pointers;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a PNG to a raw image.
|
/** Converts a PNG to a picture.
|
||||||
static void *PNG_Convert(const UINT8 *png, INT32 outbpp, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
|
*
|
||||||
|
* \param png The PNG image.
|
||||||
|
* \param outformat The output picture's format.
|
||||||
|
* \param w The output picture's width, as a pointer.
|
||||||
|
* \param h The output picture's height, as a pointer.
|
||||||
|
* \param topoffset The output picture's top offset, for sprites, as a pointer.
|
||||||
|
* \param leftoffset The output picture's left offset, for sprites, as a pointer.
|
||||||
|
* \param insize The input picture's size.
|
||||||
|
* \param outsize A pointer to the output picture's size.
|
||||||
|
* \param flags Input picture flags.
|
||||||
|
* \return A pointer to the converted picture.
|
||||||
|
*/
|
||||||
|
void *Picture_PNGConvert(
|
||||||
|
const UINT8 *png, pictureformat_t outformat,
|
||||||
|
INT32 *w, INT32 *h,
|
||||||
|
INT16 *topoffset, INT16 *leftoffset,
|
||||||
|
size_t insize, size_t *outsize,
|
||||||
|
pictureflags_t flags)
|
||||||
{
|
{
|
||||||
void *flat;
|
void *flat;
|
||||||
|
INT32 outbpp;
|
||||||
|
size_t flatsize;
|
||||||
png_uint_32 x, y;
|
png_uint_32 x, y;
|
||||||
png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, size);
|
png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, insize);
|
||||||
png_uint_32 width = *w, height = *h;
|
png_uint_32 width = *w, height = *h;
|
||||||
|
|
||||||
|
outbpp = Picture_FormatBPP(outformat);
|
||||||
if (!outbpp)
|
if (!outbpp)
|
||||||
I_Error("PNG_Convert: unknown output bits per pixel?!");
|
I_Error("Picture_PNGConvert: unknown output bits per pixel?!");
|
||||||
|
|
||||||
if (!row_pointers)
|
// Figure out the size
|
||||||
I_Error("PNG_Convert: conversion failed!");
|
flatsize = (width * height) * (outbpp / 8);
|
||||||
|
if (outsize)
|
||||||
|
*outsize = flatsize;
|
||||||
|
|
||||||
// Convert the image
|
// Convert the image
|
||||||
flat = Z_Malloc((width * height) * (outbpp / 8), PU_STATIC, NULL);
|
flat = Z_Malloc(flatsize, PU_STATIC, NULL);
|
||||||
if (outbpp == 8)
|
if (outbpp == 8)
|
||||||
memset(flat, TRANSPARENTPIXEL, (width * height));
|
memset(flat, TRANSPARENTPIXEL, (width * height));
|
||||||
|
|
||||||
|
|
@ -979,48 +979,55 @@ static void *PNG_Convert(const UINT8 *png, INT32 outbpp, UINT16 *w, UINT16 *h, I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free the row pointers that libpng allocated.
|
||||||
free(row_pointers);
|
free(row_pointers);
|
||||||
|
|
||||||
|
// But wait, there's more!
|
||||||
|
if (Picture_IsPatchFormat(outformat))
|
||||||
|
{
|
||||||
|
void *converted;
|
||||||
|
pictureformat_t informat = PICFMT_NONE;
|
||||||
|
INT16 patleftoffset = 0, pattopoffset = 0;
|
||||||
|
|
||||||
|
// Figure out the input format, from the bitdepth of the input format
|
||||||
|
switch (outbpp)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
informat = PICFMT_FLAT32;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
informat = PICFMT_FLAT16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
informat = PICFMT_FLAT; // Assumed 8bpp
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also find out if leftoffset and topoffset aren't pointing to NULL.
|
||||||
|
if (leftoffset)
|
||||||
|
patleftoffset = *leftoffset;
|
||||||
|
if (topoffset)
|
||||||
|
pattopoffset = *topoffset;
|
||||||
|
|
||||||
|
// Now, convert it!
|
||||||
|
converted = Picture_PatchConvert(informat, flat, outformat, insize, outsize, (INT16)width, (INT16)height, patleftoffset, pattopoffset, flags);
|
||||||
|
Z_Free(flat);
|
||||||
|
return converted;
|
||||||
|
}
|
||||||
|
|
||||||
return flat;
|
return flat;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/** Returns the dimensions of a PNG image, but doesn't perform any conversions.
|
||||||
// R_PNGToFlat
|
*
|
||||||
//
|
* \param png The PNG image.
|
||||||
// Convert a PNG to a flat.
|
* \param width A pointer to the input picture's width.
|
||||||
//
|
* \param height A pointer to the input picture's height.
|
||||||
UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size)
|
* \param size The input picture's size.
|
||||||
{
|
* \return True if reading the file succeeded, false if it failed.
|
||||||
return PNG_Convert(png, 8, width, height, NULL, NULL, size);
|
*/
|
||||||
}
|
boolean Picture_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size)
|
||||||
|
|
||||||
//
|
|
||||||
// R_PNGToPatch
|
|
||||||
//
|
|
||||||
// Convert a PNG to a patch.
|
|
||||||
//
|
|
||||||
patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency)
|
|
||||||
{
|
|
||||||
UINT16 width, height;
|
|
||||||
INT16 topoffset = 0, leftoffset = 0;
|
|
||||||
UINT8 *raw = PNG_Convert(png, 32, &width, &height, &topoffset, &leftoffset, size);
|
|
||||||
patch_t *output;
|
|
||||||
|
|
||||||
(void)transparency;
|
|
||||||
if (!raw)
|
|
||||||
I_Error("R_PNGToPatch: conversion failed");
|
|
||||||
|
|
||||||
output = Picture_Convert(PICFMT_FLAT32, raw, PICFMT_PATCH, 0, destsize, width, height, leftoffset, topoffset, 0);
|
|
||||||
Z_Free(raw);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// R_PNGDimensions
|
|
||||||
//
|
|
||||||
// Get the dimensions of a PNG file.
|
|
||||||
//
|
|
||||||
boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size)
|
|
||||||
{
|
{
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop png_info_ptr;
|
png_infop png_info_ptr;
|
||||||
|
|
@ -1449,7 +1456,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
lumplength = W_LumpLength(lump);
|
lumplength = W_LumpLength(lump);
|
||||||
|
|
||||||
// Because there's something wrong with SPR_DFLM, I guess
|
// Because there's something wrong with SPR_DFLM, I guess
|
||||||
if (!R_CheckIfPatch(patch, lumplength))
|
if (!Picture_CheckIfPatch(patch, lumplength))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
width = patch->width;
|
width = patch->width;
|
||||||
|
|
@ -1567,7 +1574,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
}
|
}
|
||||||
|
|
||||||
// make patch
|
// make patch
|
||||||
newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, &size);
|
newpatch = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0);
|
||||||
{
|
{
|
||||||
newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px);
|
newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px);
|
||||||
newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py);
|
newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py);
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,12 @@ void *Picture_GetPatchPixel(
|
||||||
INT32 x, INT32 y,
|
INT32 x, INT32 y,
|
||||||
pictureflags_t flags);
|
pictureflags_t flags);
|
||||||
|
|
||||||
|
void *Picture_TextureToFlat(size_t trickytex);
|
||||||
|
|
||||||
INT32 Picture_FormatBPP(pictureformat_t format);
|
INT32 Picture_FormatBPP(pictureformat_t format);
|
||||||
boolean Picture_IsPatchFormat(pictureformat_t format);
|
boolean Picture_IsPatchFormat(pictureformat_t format);
|
||||||
boolean Picture_IsFlatFormat(pictureformat_t format);
|
boolean Picture_IsFlatFormat(pictureformat_t format);
|
||||||
|
boolean Picture_CheckIfPatch(patch_t *patch, size_t size);
|
||||||
|
|
||||||
// Structs
|
// Structs
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
|
|
@ -92,22 +95,18 @@ typedef struct
|
||||||
boolean available;
|
boolean available;
|
||||||
} spriteinfo_t;
|
} spriteinfo_t;
|
||||||
|
|
||||||
// Conversions between patches / flats / textures...
|
|
||||||
boolean R_CheckIfPatch(patch_t *patch, size_t size);
|
|
||||||
void R_TextureToFlat(size_t tex, UINT8 *flat);
|
|
||||||
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
|
|
||||||
void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip);
|
|
||||||
patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency);
|
|
||||||
patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size);
|
|
||||||
|
|
||||||
// Portable Network Graphics
|
// Portable Network Graphics
|
||||||
boolean R_IsLumpPNG(const UINT8 *d, size_t s);
|
boolean Picture_IsLumpPNG(const UINT8 *d, size_t s);
|
||||||
#define W_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic
|
#define Picture_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size);
|
void *Picture_PNGConvert(
|
||||||
patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency);
|
const UINT8 *png, pictureformat_t outformat,
|
||||||
boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
|
INT32 *w, INT32 *h,
|
||||||
|
INT16 *topoffset, INT16 *leftoffset,
|
||||||
|
size_t insize, size_t *outsize,
|
||||||
|
pictureflags_t flags);
|
||||||
|
boolean Picture_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SpriteInfo
|
// SpriteInfo
|
||||||
|
|
|
||||||
|
|
@ -764,18 +764,6 @@ void R_CheckFlatLength(size_t size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// R_GenerateFlat
|
|
||||||
//
|
|
||||||
// Generate a flat from specified width and height.
|
|
||||||
//
|
|
||||||
static UINT8 *R_GenerateFlat(UINT16 width, UINT16 height)
|
|
||||||
{
|
|
||||||
UINT8 *flat = Z_Malloc(width * height, PU_LEVEL, NULL);
|
|
||||||
memset(flat, TRANSPARENTPIXEL, width * height);
|
|
||||||
return flat;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_GetTextureFlat
|
// R_GetTextureFlat
|
||||||
//
|
//
|
||||||
|
|
@ -810,12 +798,17 @@ static UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boo
|
||||||
// Level texture
|
// Level texture
|
||||||
if (leveltexture)
|
if (leveltexture)
|
||||||
{
|
{
|
||||||
|
UINT8 *converted;
|
||||||
|
size_t size;
|
||||||
texture_t *texture = textures[levelflat->u.texture.num];
|
texture_t *texture = textures[levelflat->u.texture.num];
|
||||||
texflat->width = ds_flatwidth = texture->width;
|
texflat->width = ds_flatwidth = texture->width;
|
||||||
texflat->height = ds_flatheight = texture->height;
|
texflat->height = ds_flatheight = texture->height;
|
||||||
|
|
||||||
texflat->flat = R_GenerateFlat(ds_flatwidth, ds_flatheight);
|
size = (texflat->width * texflat->height);
|
||||||
R_TextureToFlat(levelflat->u.texture.num, texflat->flat);
|
texflat->flat = Z_Malloc(size, PU_LEVEL, NULL);
|
||||||
|
converted = (UINT8 *)Picture_TextureToFlat(levelflat->u.texture.num);
|
||||||
|
M_Memcpy(texflat->flat, converted, size);
|
||||||
|
Z_Free(converted);
|
||||||
flat = texflat->flat;
|
flat = texflat->flat;
|
||||||
|
|
||||||
levelflat->flatpatch = flat;
|
levelflat->flatpatch = flat;
|
||||||
|
|
@ -829,22 +822,31 @@ static UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boo
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (ispng)
|
if (ispng)
|
||||||
{
|
{
|
||||||
levelflat->flatpatch = R_PNGToFlat(&levelflat->width, &levelflat->height, ds_source, W_LumpLength(levelflat->u.flat.lumpnum));
|
INT32 pngwidth, pngheight;
|
||||||
|
|
||||||
|
levelflat->flatpatch = Picture_PNGConvert(ds_source, PICFMT_FLAT32, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
|
||||||
levelflat->topoffset = levelflat->leftoffset = 0;
|
levelflat->topoffset = levelflat->leftoffset = 0;
|
||||||
|
levelflat->width = (UINT16)pngwidth;
|
||||||
|
levelflat->height = (UINT16)pngheight;
|
||||||
|
|
||||||
ds_flatwidth = levelflat->width;
|
ds_flatwidth = levelflat->width;
|
||||||
ds_flatheight = levelflat->height;
|
ds_flatheight = levelflat->height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
UINT8 *converted;
|
||||||
|
size_t size;
|
||||||
levelflat->width = ds_flatwidth = SHORT(patch->width);
|
levelflat->width = ds_flatwidth = SHORT(patch->width);
|
||||||
levelflat->height = ds_flatheight = SHORT(patch->height);
|
levelflat->height = ds_flatheight = SHORT(patch->height);
|
||||||
|
|
||||||
levelflat->topoffset = patch->topoffset * FRACUNIT;
|
levelflat->topoffset = patch->topoffset * FRACUNIT;
|
||||||
levelflat->leftoffset = patch->leftoffset * FRACUNIT;
|
levelflat->leftoffset = patch->leftoffset * FRACUNIT;
|
||||||
|
|
||||||
levelflat->flatpatch = R_GenerateFlat(ds_flatwidth, ds_flatheight);
|
levelflat->flatpatch = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL);
|
||||||
R_PatchToFlat(patch, levelflat->flatpatch);
|
converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0);
|
||||||
|
M_Memcpy(levelflat->flatpatch, converted, size);
|
||||||
|
Z_Free(converted);
|
||||||
}
|
}
|
||||||
flat = levelflat->flatpatch;
|
flat = levelflat->flatpatch;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -282,10 +282,14 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
|
||||||
patch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC);
|
patch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC);
|
||||||
size_t len = W_LumpLengthPwad(wadnum, l);
|
size_t len = W_LumpLengthPwad(wadnum, l);
|
||||||
// lump is a png so convert it
|
// lump is a png so convert it
|
||||||
if (R_IsLumpPNG((UINT8 *)png, len))
|
if (Picture_IsLumpPNG((UINT8 *)png, len))
|
||||||
{
|
{
|
||||||
png = R_PNGToPatch((UINT8 *)png, len, NULL, true);
|
// Dummy variables.
|
||||||
M_Memcpy(&patch, png, sizeof(INT16)*4);
|
INT32 pngwidth, pngheight;
|
||||||
|
INT16 topoffset, leftoffset;
|
||||||
|
patch_t *converted = (patch_t *)Picture_PNGConvert((UINT8 *)png, PICFMT_PATCH, &pngwidth, &pngheight, &topoffset, &leftoffset, len, NULL, 0);
|
||||||
|
M_Memcpy(&patch, converted, sizeof(INT16)*4); // only copy the header because that's all we need
|
||||||
|
Z_Free(converted);
|
||||||
}
|
}
|
||||||
Z_Free(png);
|
Z_Free(png);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
src/w_wad.c
18
src/w_wad.c
|
|
@ -1213,8 +1213,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||||
#ifdef NO_PNG_LUMPS
|
#ifdef NO_PNG_LUMPS
|
||||||
{
|
{
|
||||||
size_t bytesread = fread(dest, 1, size, handle);
|
size_t bytesread = fread(dest, 1, size, handle);
|
||||||
if (R_IsLumpPNG((UINT8 *)dest, bytesread))
|
if (Picture_IsLumpPNG((UINT8 *)dest, bytesread))
|
||||||
W_ThrowPNGError(l->name2, wadfiles[wad]->filename);
|
Picture_ThrowPNGError(l->name2, wadfiles[wad]->filename);
|
||||||
return bytesread;
|
return bytesread;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
@ -1255,8 +1255,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||||
Z_Free(rawData);
|
Z_Free(rawData);
|
||||||
Z_Free(decData);
|
Z_Free(decData);
|
||||||
#ifdef NO_PNG_LUMPS
|
#ifdef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)dest, size))
|
if (Picture_IsLumpPNG((UINT8 *)dest, size))
|
||||||
W_ThrowPNGError(l->name2, wadfiles[wad]->filename);
|
Picture_ThrowPNGError(l->name2, wadfiles[wad]->filename);
|
||||||
#endif
|
#endif
|
||||||
return size;
|
return size;
|
||||||
#else
|
#else
|
||||||
|
|
@ -1318,8 +1318,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||||
Z_Free(decData);
|
Z_Free(decData);
|
||||||
|
|
||||||
#ifdef NO_PNG_LUMPS
|
#ifdef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)dest, size))
|
if (Picture_IsLumpPNG((UINT8 *)dest, size))
|
||||||
W_ThrowPNGError(l->name2, wadfiles[wad]->filename);
|
Picture_ThrowPNGError(l->name2, wadfiles[wad]->filename);
|
||||||
#endif
|
#endif
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
@ -1538,10 +1538,12 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
// lump is a png so convert it
|
// lump is a png so convert it
|
||||||
if (R_IsLumpPNG((UINT8 *)lumpdata, len))
|
if (Picture_IsLumpPNG((UINT8 *)lumpdata, len))
|
||||||
{
|
{
|
||||||
|
// Dummy variables.
|
||||||
size_t newlen;
|
size_t newlen;
|
||||||
srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen, true);
|
INT32 pngwidth, pngheight;
|
||||||
|
srcdata = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, len, &newlen, 0);
|
||||||
ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]);
|
ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]);
|
||||||
M_Memcpy(ptr, srcdata, newlen);
|
M_Memcpy(ptr, srcdata, newlen);
|
||||||
Z_Free(srcdata);
|
Z_Free(srcdata);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue