mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- replaced several explicit allocations with TArrays.
This commit is contained in:
parent
d68cd3aa80
commit
a73c065811
10 changed files with 66 additions and 115 deletions
|
@ -240,30 +240,29 @@ void I_DebugPrint(const char *cp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_PrintStr (const char *cp)
|
void I_PrintStr(const char *cp)
|
||||||
{
|
{
|
||||||
// Strip out any color escape sequences before writing to the log file
|
// Strip out any color escape sequences before writing to debug output
|
||||||
char * copy = new char[strlen(cp)+1];
|
TArray<char> copy(strlen(cp) + 1, true);
|
||||||
const char * srcp = cp;
|
const char * srcp = cp;
|
||||||
char * dstp = copy;
|
char * dstp = copy.Data();
|
||||||
|
|
||||||
while (*srcp != 0)
|
while (*srcp != 0)
|
||||||
{
|
{
|
||||||
if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f)
|
if (*srcp != 0x1c && *srcp != 0x1d && *srcp != 0x1e && *srcp != 0x1f)
|
||||||
{
|
{
|
||||||
*dstp++=*srcp++;
|
*dstp++ = *srcp++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (srcp[1]!=0) srcp+=2;
|
if (srcp[1] != 0) srcp += 2;
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*dstp=0;
|
*dstp = 0;
|
||||||
|
|
||||||
fputs (copy, stdout);
|
fputs(copy.Data(), stdout);
|
||||||
delete [] copy;
|
fflush(stdout);
|
||||||
fflush (stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
|
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
|
||||||
|
|
|
@ -83,7 +83,7 @@ TArray<uint8_t> FVoxelTexture::CreatePalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
// GetPixels gets called when a translated palette is used so we still need to implement it here.
|
// GetPixels gets called when a translated palette is used so we still need to implement it here.
|
||||||
TArray<uint8_t> Pixels(256, true);
|
TArray<uint8_t> Pixels(256, true);
|
||||||
uint8_t *pp = SourceVox->Palette;
|
uint8_t *pp = SourceVox->Palette.Data();
|
||||||
|
|
||||||
if(pp != NULL)
|
if(pp != NULL)
|
||||||
{
|
{
|
||||||
|
@ -120,9 +120,9 @@ int FVoxelTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
uint8_t bitmap[256];
|
uint8_t bitmap[256];
|
||||||
uint8_t *pp = SourceVox->Palette;
|
uint8_t *pp = SourceVox->Palette.Data();
|
||||||
|
|
||||||
if(pp != NULL)
|
if(pp != nullptr)
|
||||||
{
|
{
|
||||||
for(int i=0;i<256;i++, pp+=3)
|
for(int i=0;i<256;i++, pp+=3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -392,7 +392,7 @@ static void AddToVertex(const sector_t * sec, TArray<int> & list)
|
||||||
|
|
||||||
static void InitVertexData()
|
static void InitVertexData()
|
||||||
{
|
{
|
||||||
auto vt_sectorlists = new TArray<int>[level.vertexes.Size()];
|
TArray<TArray<int>> vt_sectorlists(level.vertexes.Size(), true);
|
||||||
|
|
||||||
for(auto &line : level.lines)
|
for(auto &line : level.lines)
|
||||||
{
|
{
|
||||||
|
@ -437,8 +437,6 @@ static void InitVertexData()
|
||||||
vert.numsectors=0;
|
vert.numsectors=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] vt_sectorlists;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -478,15 +476,15 @@ static int segcmp(const void *a, const void *b)
|
||||||
static void PrepareSegs()
|
static void PrepareSegs()
|
||||||
{
|
{
|
||||||
auto numsides = level.sides.Size();
|
auto numsides = level.sides.Size();
|
||||||
int *segcount = new int[numsides];
|
TArray<int> segcount(numsides, true);
|
||||||
int realsegs = 0;
|
int realsegs = 0;
|
||||||
|
|
||||||
// count the segs
|
// count the segs
|
||||||
memset(segcount, 0, numsides * sizeof(int));
|
memset(segcount.Data(), 0, numsides * sizeof(int));
|
||||||
|
|
||||||
for(auto &seg : level.segs)
|
for(auto &seg : level.segs)
|
||||||
{
|
{
|
||||||
if (seg.sidedef == NULL) continue; // miniseg
|
if (seg.sidedef == nullptr) continue; // miniseg
|
||||||
int sidenum = seg.sidedef->Index();
|
int sidenum = seg.sidedef->Index();
|
||||||
|
|
||||||
realsegs++;
|
realsegs++;
|
||||||
|
@ -509,7 +507,6 @@ static void PrepareSegs()
|
||||||
level.sides[i].segs = level.sides[i-1].segs + segcount[i-1];
|
level.sides[i].segs = level.sides[i-1].segs + segcount[i-1];
|
||||||
level.sides[i].numsegs = 0;
|
level.sides[i].numsegs = 0;
|
||||||
}
|
}
|
||||||
delete [] segcount;
|
|
||||||
|
|
||||||
// assign the segs
|
// assign the segs
|
||||||
for (auto &seg : level.segs)
|
for (auto &seg : level.segs)
|
||||||
|
|
|
@ -303,8 +303,8 @@ FVoxel *R_LoadKVX(int lumpnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
voxel->LumpNum = lumpnum;
|
voxel->LumpNum = lumpnum;
|
||||||
voxel->Palette = new uint8_t[768];
|
voxel->Palette.Resize(768);
|
||||||
memcpy(voxel->Palette, rawvoxel + voxelsize - 768, 768);
|
memcpy(voxel->Palette.Data(), rawvoxel + voxelsize - 768, 768);
|
||||||
|
|
||||||
return voxel;
|
return voxel;
|
||||||
}
|
}
|
||||||
|
@ -382,22 +382,6 @@ uint8_t *FVoxelMipLevel::GetSlabData(bool wantremapped) const
|
||||||
return SlabData;
|
return SlabData;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// FVoxel Constructor
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FVoxel::FVoxel()
|
|
||||||
{
|
|
||||||
Palette = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVoxel::~FVoxel()
|
|
||||||
{
|
|
||||||
if (Palette != NULL) delete [] Palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Create true color version of the slab data
|
// Create true color version of the slab data
|
||||||
|
@ -430,7 +414,7 @@ void FVoxel::CreateBgraSlabData()
|
||||||
int colorIndex = src->col[j];
|
int colorIndex = src->col[j];
|
||||||
|
|
||||||
uint32_t red, green, blue;
|
uint32_t red, green, blue;
|
||||||
if (Palette)
|
if (Palette.Size())
|
||||||
{
|
{
|
||||||
red = (Palette[colorIndex * 3 + 0] << 2) | (Palette[colorIndex * 3 + 0] >> 4);
|
red = (Palette[colorIndex * 3 + 0] << 2) | (Palette[colorIndex * 3 + 0] >> 4);
|
||||||
green = (Palette[colorIndex * 3 + 1] << 2) | (Palette[colorIndex * 3 + 1] >> 4);
|
green = (Palette[colorIndex * 3 + 1] << 2) | (Palette[colorIndex * 3 + 1] >> 4);
|
||||||
|
@ -464,9 +448,9 @@ void FVoxel::Remap()
|
||||||
{
|
{
|
||||||
if (Remapped) return;
|
if (Remapped) return;
|
||||||
Remapped = true;
|
Remapped = true;
|
||||||
if (Palette != NULL)
|
if (Palette.Size())
|
||||||
{
|
{
|
||||||
uint8_t *remap = GetVoxelRemap(Palette);
|
uint8_t *remap = GetVoxelRemap(Palette.Data());
|
||||||
for (int i = 0; i < NumMips; ++i)
|
for (int i = 0; i < NumMips; ++i)
|
||||||
{
|
{
|
||||||
int size = Mips[i].OffsetX[Mips[i].SizeX];
|
int size = Mips[i].OffsetX[Mips[i].SizeX];
|
||||||
|
@ -487,11 +471,7 @@ void FVoxel::Remap()
|
||||||
|
|
||||||
void FVoxel::RemovePalette()
|
void FVoxel::RemovePalette()
|
||||||
{
|
{
|
||||||
if (Palette != NULL)
|
Palette.Reset();
|
||||||
{
|
|
||||||
delete [] Palette;
|
|
||||||
Palette = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,16 +50,14 @@ public:
|
||||||
|
|
||||||
struct FVoxel
|
struct FVoxel
|
||||||
{
|
{
|
||||||
|
TArray<uint8_t> Palette;
|
||||||
int LumpNum;
|
int LumpNum;
|
||||||
int NumMips;
|
int NumMips;
|
||||||
int VoxelIndex;
|
int VoxelIndex;
|
||||||
uint8_t *Palette;
|
|
||||||
FVoxelMipLevel Mips[MAXVOXMIPS];
|
FVoxelMipLevel Mips[MAXVOXMIPS];
|
||||||
bool Remapped = false;
|
bool Remapped = false;
|
||||||
bool Bgramade = false;
|
bool Bgramade = false;
|
||||||
|
|
||||||
FVoxel();
|
|
||||||
~FVoxel();
|
|
||||||
void CreateBgraSlabData();
|
void CreateBgraSlabData();
|
||||||
void Remap();
|
void Remap();
|
||||||
void RemovePalette();
|
void RemovePalette();
|
||||||
|
|
|
@ -96,9 +96,9 @@ bool FPakFile::Open(bool quiet)
|
||||||
NumLumps = LittleLong(header.dirlen) / sizeof(dpackfile_t);
|
NumLumps = LittleLong(header.dirlen) / sizeof(dpackfile_t);
|
||||||
header.dirofs = LittleLong(header.dirofs);
|
header.dirofs = LittleLong(header.dirofs);
|
||||||
|
|
||||||
dpackfile_t *fileinfo = new dpackfile_t[NumLumps];
|
TArray<dpackfile_t> fileinfo(NumLumps, true);
|
||||||
Reader.Seek (header.dirofs, FileReader::SeekSet);
|
Reader.Seek (header.dirofs, FileReader::SeekSet);
|
||||||
Reader.Read (fileinfo, NumLumps * sizeof(dpackfile_t));
|
Reader.Read (fileinfo.Data(), NumLumps * sizeof(dpackfile_t));
|
||||||
|
|
||||||
Lumps.Resize(NumLumps);
|
Lumps.Resize(NumLumps);
|
||||||
|
|
||||||
|
@ -113,7 +113,6 @@ bool FPakFile::Open(bool quiet)
|
||||||
Lumps[i].CheckEmbedded();
|
Lumps[i].CheckEmbedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] fileinfo;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,6 @@ int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
|
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
JSAMPLE *buff = NULL;
|
|
||||||
|
|
||||||
jpeg_decompress_struct cinfo;
|
jpeg_decompress_struct cinfo;
|
||||||
jpeg_error_mgr jerr;
|
jpeg_error_mgr jerr;
|
||||||
|
@ -414,12 +413,11 @@ int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
jpeg_start_decompress(&cinfo);
|
jpeg_start_decompress(&cinfo);
|
||||||
|
|
||||||
int yc = 0;
|
int yc = 0;
|
||||||
buff = new uint8_t[cinfo.output_height * cinfo.output_width * cinfo.output_components];
|
TArray<uint8_t> buff(cinfo.output_height * cinfo.output_width * cinfo.output_components, true);
|
||||||
|
|
||||||
|
|
||||||
while (cinfo.output_scanline < cinfo.output_height)
|
while (cinfo.output_scanline < cinfo.output_height)
|
||||||
{
|
{
|
||||||
uint8_t * ptr = buff + cinfo.output_width * cinfo.output_components * yc;
|
uint8_t * ptr = buff.Data() + cinfo.output_width * cinfo.output_components * yc;
|
||||||
jpeg_read_scanlines(&cinfo, &ptr, 1);
|
jpeg_read_scanlines(&cinfo, &ptr, 1);
|
||||||
yc++;
|
yc++;
|
||||||
}
|
}
|
||||||
|
@ -427,23 +425,23 @@ int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
switch (cinfo.out_color_space)
|
switch (cinfo.out_color_space)
|
||||||
{
|
{
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
bmp->CopyPixelDataRGB(0, 0, buff, cinfo.output_width, cinfo.output_height,
|
bmp->CopyPixelDataRGB(0, 0, buff.Data(), cinfo.output_width, cinfo.output_height,
|
||||||
3, cinfo.output_width * cinfo.output_components, 0, CF_RGB);
|
3, cinfo.output_width * cinfo.output_components, 0, CF_RGB);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
for (int i = 0; i < 256; i++) pe[i] = PalEntry(255, i, i, i); // default to a gray map
|
for (int i = 0; i < 256; i++) pe[i] = PalEntry(255, i, i, i); // default to a gray map
|
||||||
bmp->CopyPixelData(0, 0, buff, cinfo.output_width, cinfo.output_height,
|
bmp->CopyPixelData(0, 0, buff.Data(), cinfo.output_width, cinfo.output_height,
|
||||||
1, cinfo.output_width, 0, pe);
|
1, cinfo.output_width, 0, pe);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
bmp->CopyPixelDataRGB(0, 0, buff, cinfo.output_width, cinfo.output_height,
|
bmp->CopyPixelDataRGB(0, 0, buff.Data(), cinfo.output_width, cinfo.output_height,
|
||||||
4, cinfo.output_width * cinfo.output_components, 0, CF_CMYK);
|
4, cinfo.output_width * cinfo.output_components, 0, CF_CMYK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
bmp->CopyPixelDataRGB(0, 0, buff, cinfo.output_width, cinfo.output_height,
|
bmp->CopyPixelDataRGB(0, 0, buff.Data(), cinfo.output_width, cinfo.output_height,
|
||||||
4, cinfo.output_width * cinfo.output_components, 0, CF_YCbCr);
|
4, cinfo.output_width * cinfo.output_components, 0, CF_YCbCr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -459,7 +457,6 @@ int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
Printf(TEXTCOLOR_ORANGE "JPEG error in %s\n", Wads.GetLumpFullPath(SourceLump).GetChars());
|
Printf(TEXTCOLOR_ORANGE "JPEG error in %s\n", Wads.GetLumpFullPath(SourceLump).GetChars());
|
||||||
}
|
}
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
if (buff != NULL) delete [] buff;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,9 +161,8 @@ void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
int rle_count = 0;
|
int rle_count = 0;
|
||||||
uint8_t rle_value = 0;
|
uint8_t rle_value = 0;
|
||||||
|
|
||||||
uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
|
TArray<uint8_t> srcp = lump.Read(lump.GetLength() - sizeof(PCXHeader));
|
||||||
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
|
uint8_t * src = srcp.Data();
|
||||||
uint8_t * src = srcp;
|
|
||||||
|
|
||||||
for (y = 0; y < Height; ++y)
|
for (y = 0; y < Height; ++y)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +195,6 @@ void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] srcp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -210,12 +208,11 @@ void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
int rle_count = 0, rle_value = 0;
|
int rle_count = 0, rle_value = 0;
|
||||||
int x, y, c;
|
int x, y, c;
|
||||||
int bytes;
|
int bytes;
|
||||||
uint8_t * line = new uint8_t[hdr->bytesPerScanLine];
|
TArray<uint8_t> line(hdr->bytesPerScanLine, true);
|
||||||
uint8_t * colorIndex = new uint8_t[Width];
|
TArray<uint8_t> colorIndex(Width, true);
|
||||||
|
|
||||||
uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
|
TArray<uint8_t> srcp = lump.Read(lump.GetLength() - sizeof(PCXHeader));
|
||||||
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
|
uint8_t * src = srcp.Data();
|
||||||
uint8_t * src = srcp;
|
|
||||||
|
|
||||||
for (y = 0; y < Height; ++y)
|
for (y = 0; y < Height; ++y)
|
||||||
{
|
{
|
||||||
|
@ -224,7 +221,7 @@ void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
|
|
||||||
for (c = 0; c < 4; ++c)
|
for (c = 0; c < 4; ++c)
|
||||||
{
|
{
|
||||||
uint8_t * pLine = line;
|
uint8_t * pLine = line.Data();
|
||||||
|
|
||||||
bytes = hdr->bytesPerScanLine;
|
bytes = hdr->bytesPerScanLine;
|
||||||
|
|
||||||
|
@ -255,11 +252,6 @@ void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
ptr[x] += (1 << c);
|
ptr[x] += (1 << c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* release memory */
|
|
||||||
delete [] colorIndex;
|
|
||||||
delete [] line;
|
|
||||||
delete [] srcp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -273,9 +265,8 @@ void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
int rle_count = 0, rle_value = 0;
|
int rle_count = 0, rle_value = 0;
|
||||||
int y, bytes;
|
int y, bytes;
|
||||||
|
|
||||||
uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
|
auto srcp = lump.Read(lump.GetLength() - sizeof(PCXHeader));
|
||||||
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
|
uint8_t * src = srcp.Data();
|
||||||
uint8_t * src = srcp;
|
|
||||||
|
|
||||||
for (y = 0; y < Height; ++y)
|
for (y = 0; y < Height; ++y)
|
||||||
{
|
{
|
||||||
|
@ -301,7 +292,6 @@ void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
*ptr++ = rle_value;
|
*ptr++ = rle_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] srcp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -316,9 +306,8 @@ void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr
|
||||||
int y, c;
|
int y, c;
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)];
|
auto srcp = lump.Read(lump.GetLength() - sizeof(PCXHeader));
|
||||||
lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader));
|
uint8_t * src = srcp.Data();
|
||||||
uint8_t * src = srcp;
|
|
||||||
|
|
||||||
for (y = 0; y < Height; ++y)
|
for (y = 0; y < Height; ++y)
|
||||||
{
|
{
|
||||||
|
@ -349,7 +338,6 @@ void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] srcp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -423,9 +411,9 @@ TArray<uint8_t> FPCXTexture::CreatePalettedPixels(int conversion)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint8_t * buffer = new uint8_t[Width*Height * 3];
|
TArray<uint8_t> buffer(Width*Height * 3, true);
|
||||||
uint8_t * row = buffer;
|
uint8_t * row = buffer.Data();
|
||||||
ReadPCX24bits (buffer, lump, &header, 3);
|
ReadPCX24bits (row, lump, &header, 3);
|
||||||
for(int y=0; y<Height; y++)
|
for(int y=0; y<Height; y++)
|
||||||
{
|
{
|
||||||
for(int x=0; x < Width; x++)
|
for(int x=0; x < Width; x++)
|
||||||
|
@ -434,7 +422,6 @@ TArray<uint8_t> FPCXTexture::CreatePalettedPixels(int conversion)
|
||||||
row+=3;
|
row+=3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete [] buffer;
|
|
||||||
}
|
}
|
||||||
return Pixels;
|
return Pixels;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +439,7 @@ int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
PCXHeader header;
|
PCXHeader header;
|
||||||
int bitcount;
|
int bitcount;
|
||||||
uint8_t * Pixels;
|
TArray<uint8_t> Pixels;
|
||||||
|
|
||||||
auto lump = Wads.OpenLumpReader(SourceLump);
|
auto lump = Wads.OpenLumpReader(SourceLump);
|
||||||
|
|
||||||
|
@ -462,7 +449,7 @@ int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
|
|
||||||
if (bitcount < 24)
|
if (bitcount < 24)
|
||||||
{
|
{
|
||||||
Pixels = new uint8_t[Width*Height];
|
Pixels.Resize(Width*Height);
|
||||||
if (bitcount < 8)
|
if (bitcount < 8)
|
||||||
{
|
{
|
||||||
switch (bitcount)
|
switch (bitcount)
|
||||||
|
@ -471,7 +458,7 @@ int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
case 1:
|
case 1:
|
||||||
pe[0] = PalEntry(255, 0, 0, 0);
|
pe[0] = PalEntry(255, 0, 0, 0);
|
||||||
pe[1] = PalEntry(255, 255, 255, 255);
|
pe[1] = PalEntry(255, 255, 255, 255);
|
||||||
ReadPCX1bit (Pixels, lump, &header);
|
ReadPCX1bit (Pixels.Data(), lump, &header);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -479,7 +466,7 @@ int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
pe[i] = PalEntry(255, header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
|
pe[i] = PalEntry(255, header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
|
||||||
}
|
}
|
||||||
ReadPCX4bits (Pixels, lump, &header);
|
ReadPCX4bits (Pixels.Data(), lump, &header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,17 +487,16 @@ int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
pe[i] = PalEntry(255, r,g,b);
|
pe[i] = PalEntry(255, r,g,b);
|
||||||
}
|
}
|
||||||
lump.Seek(sizeof(header), FileReader::SeekSet);
|
lump.Seek(sizeof(header), FileReader::SeekSet);
|
||||||
ReadPCX8bits (Pixels, lump, &header);
|
ReadPCX8bits (Pixels.Data(), lump, &header);
|
||||||
}
|
}
|
||||||
bmp->CopyPixelData(0, 0, Pixels, Width, Height, 1, Width, 0, pe);
|
bmp->CopyPixelData(0, 0, Pixels.Data(), Width, Height, 1, Width, 0, pe);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pixels = new uint8_t[Width*Height * 3];
|
Pixels.Resize(Width*Height*4);
|
||||||
ReadPCX24bits (Pixels, lump, &header, 3);
|
ReadPCX24bits (Pixels.Data(), lump, &header, 3);
|
||||||
bmp->CopyPixelDataRGB(0, 0, Pixels, Width, Height, 3, Width*3, 0, CF_RGB);
|
bmp->CopyPixelDataRGB(0, 0, Pixels.Data(), Width, Height, 3, Width*3, 0, CF_RGB);
|
||||||
}
|
}
|
||||||
delete [] Pixels;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,6 @@ TArray<uint8_t> FTGATexture::CreatePalettedPixels(int conversion)
|
||||||
TGAHeader hdr;
|
TGAHeader hdr;
|
||||||
uint16_t w;
|
uint16_t w;
|
||||||
uint8_t r,g,b,a;
|
uint8_t r,g,b,a;
|
||||||
uint8_t * buffer;
|
|
||||||
|
|
||||||
TArray<uint8_t> Pixels(Width*Height, true);
|
TArray<uint8_t> Pixels(Width*Height, true);
|
||||||
lump.Read(&hdr, sizeof(hdr));
|
lump.Read(&hdr, sizeof(hdr));
|
||||||
|
@ -237,18 +236,18 @@ TArray<uint8_t> FTGATexture::CreatePalettedPixels(int conversion)
|
||||||
}
|
}
|
||||||
|
|
||||||
int Size = Width * Height * (hdr.bpp>>3);
|
int Size = Width * Height * (hdr.bpp>>3);
|
||||||
buffer = new uint8_t[Size];
|
TArray<uint8_t> buffer(Size, true);
|
||||||
|
|
||||||
if (hdr.img_type < 4) // uncompressed
|
if (hdr.img_type < 4) // uncompressed
|
||||||
{
|
{
|
||||||
lump.Read(buffer, Size);
|
lump.Read(buffer.Data(), Size);
|
||||||
}
|
}
|
||||||
else // compressed
|
else // compressed
|
||||||
{
|
{
|
||||||
ReadCompressed(lump, buffer, hdr.bpp>>3);
|
ReadCompressed(lump, buffer.Data(), hdr.bpp>>3);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * ptr = buffer;
|
uint8_t * ptr = buffer.Data();
|
||||||
int step_x = (hdr.bpp>>3);
|
int step_x = (hdr.bpp>>3);
|
||||||
int Pitch = Width * step_x;
|
int Pitch = Width * step_x;
|
||||||
|
|
||||||
|
@ -378,7 +377,6 @@ TArray<uint8_t> FTGATexture::CreatePalettedPixels(int conversion)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete [] buffer;
|
|
||||||
return Pixels;
|
return Pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +393,6 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
TGAHeader hdr;
|
TGAHeader hdr;
|
||||||
uint16_t w;
|
uint16_t w;
|
||||||
uint8_t r,g,b,a;
|
uint8_t r,g,b,a;
|
||||||
uint8_t * sbuffer;
|
|
||||||
int transval = 0;
|
int transval = 0;
|
||||||
|
|
||||||
lump.Read(&hdr, sizeof(hdr));
|
lump.Read(&hdr, sizeof(hdr));
|
||||||
|
@ -447,18 +444,18 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
}
|
}
|
||||||
|
|
||||||
int Size = Width * Height * (hdr.bpp>>3);
|
int Size = Width * Height * (hdr.bpp>>3);
|
||||||
sbuffer = new uint8_t[Size];
|
TArray<uint8_t> sbuffer(Size);
|
||||||
|
|
||||||
if (hdr.img_type < 4) // uncompressed
|
if (hdr.img_type < 4) // uncompressed
|
||||||
{
|
{
|
||||||
lump.Read(sbuffer, Size);
|
lump.Read(sbuffer.Data(), Size);
|
||||||
}
|
}
|
||||||
else // compressed
|
else // compressed
|
||||||
{
|
{
|
||||||
ReadCompressed(lump, sbuffer, hdr.bpp>>3);
|
ReadCompressed(lump, sbuffer.Data(), hdr.bpp>>3);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * ptr = sbuffer;
|
uint8_t * ptr = sbuffer.Data();
|
||||||
int step_x = (hdr.bpp>>3);
|
int step_x = (hdr.bpp>>3);
|
||||||
int Pitch = Width * step_x;
|
int Pitch = Width * step_x;
|
||||||
|
|
||||||
|
@ -530,6 +527,5 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete [] sbuffer;
|
|
||||||
return transval;
|
return transval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -709,9 +709,9 @@ void I_PrintStr(const char *cp)
|
||||||
if (con_debugoutput)
|
if (con_debugoutput)
|
||||||
{
|
{
|
||||||
// Strip out any color escape sequences before writing to debug output
|
// Strip out any color escape sequences before writing to debug output
|
||||||
char * copy = new char[strlen(cp)+1];
|
TArray<char> copy(strlen(cp) + 1, true);
|
||||||
const char * srcp = cp;
|
const char * srcp = cp;
|
||||||
char * dstp = copy;
|
char * dstp = copy.Data();
|
||||||
|
|
||||||
while (*srcp != 0)
|
while (*srcp != 0)
|
||||||
{
|
{
|
||||||
|
@ -727,8 +727,7 @@ void I_PrintStr(const char *cp)
|
||||||
}
|
}
|
||||||
*dstp=0;
|
*dstp=0;
|
||||||
|
|
||||||
OutputDebugStringA(copy);
|
OutputDebugStringA(copy.Data());
|
||||||
delete [] copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConWindowHidden)
|
if (ConWindowHidden)
|
||||||
|
|
Loading…
Reference in a new issue