mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-18 01:21:32 +00:00
- made some changes to the FImageSource interface that allows forwarding the bRemap0 flag, but do it so that it doesn't permanently alter how the image looks.
In ZDoom this would affect everything using a patch that got used in a front sky layer, even if the texture was totally unrelated. It is only owed to the low usability of such patches for other purposes that this hasn't caused problems.
This commit is contained in:
parent
583a740441
commit
91f7121452
18 changed files with 90 additions and 105 deletions
|
@ -52,8 +52,8 @@ class FVoxelTexture : public FImageSource
|
||||||
public:
|
public:
|
||||||
FVoxelTexture(FVoxel *voxel);
|
FVoxelTexture(FVoxel *voxel);
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FVoxel *SourceVox;
|
FVoxel *SourceVox;
|
||||||
|
@ -79,7 +79,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FVoxelTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FVoxelTexture::GetPalettedPixels(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);
|
||||||
|
@ -94,7 +94,7 @@ TArray<uint8_t> FVoxelTexture::Get8BitPixels(bool alphatex)
|
||||||
pe.g = (pp[1] << 2) | (pp[1] >> 4);
|
pe.g = (pp[1] << 2) | (pp[1] >> 4);
|
||||||
pe.b = (pp[2] << 2) | (pp[2] >> 4);
|
pe.b = (pp[2] << 2) | (pp[2] >> 4);
|
||||||
// Alphatexture handling is just for completeness, but rather unlikely to be used ever.
|
// Alphatexture handling is just for completeness, but rather unlikely to be used ever.
|
||||||
Pixels[i] = alphatex? pe.r : ColorMatcher.Pick(pe);
|
Pixels[i] = conversion == luminance ? pe.r : ColorMatcher.Pick(pe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -116,7 +116,7 @@ TArray<uint8_t> FVoxelTexture::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FVoxelTexture::CopyPixels(FBitmap *bmp)
|
int FVoxelTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
uint8_t bitmap[256];
|
uint8_t bitmap[256];
|
||||||
|
|
|
@ -52,7 +52,7 @@ class FAutomapTexture : public FImageSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FAutomapTexture(int lumpnum);
|
FAutomapTexture(int lumpnum);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex);
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ FAutomapTexture::FAutomapTexture (int lumpnum)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FAutomapTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FAutomapTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
FMemLump data = Wads.ReadLump (SourceLump);
|
FMemLump data = Wads.ReadLump (SourceLump);
|
||||||
|
@ -99,7 +99,7 @@ TArray<uint8_t> FAutomapTexture::Get8BitPixels(bool alphatex)
|
||||||
|
|
||||||
TArray<uint8_t> Pixels(Width * Height, true);
|
TArray<uint8_t> Pixels(Width * Height, true);
|
||||||
|
|
||||||
const uint8_t *remap = ImageHelpers::GetRemap(alphatex);
|
const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
|
||||||
for (x = 0; x < Width; ++x)
|
for (x = 0; x < Width; ++x)
|
||||||
{
|
{
|
||||||
for (y = 0; y < Height; ++y)
|
for (y = 0; y < Height; ++y)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class FBrightmapTexture : public FImageSource
|
||||||
public:
|
public:
|
||||||
FBrightmapTexture (FImageSource *source);
|
FBrightmapTexture (FImageSource *source);
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FImageSource *SourcePic;
|
FImageSource *SourcePic;
|
||||||
|
@ -68,7 +68,7 @@ FBrightmapTexture::FBrightmapTexture (FImageSource *source)
|
||||||
bMasked = false;
|
bMasked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FBrightmapTexture::CopyPixels(FBitmap *bmp)
|
int FBrightmapTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
SourcePic->CopyTranslatedPixels(bmp, TexMan.GlobalBrightmap.Palette);
|
SourcePic->CopyTranslatedPixels(bmp, TexMan.GlobalBrightmap.Palette);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -57,8 +57,8 @@ class FBuildTexture : public FImageSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FBuildTexture (const FString &pathprefix, int tilenum, const uint8_t *pixels, int translation, int width, int height, int left, int top);
|
FBuildTexture (const FString &pathprefix, int tilenum, const uint8_t *pixels, int translation, int width, int height, int left, int top);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const uint8_t *RawPixels;
|
const uint8_t *RawPixels;
|
||||||
|
@ -81,19 +81,19 @@ FBuildTexture::FBuildTexture(const FString &pathprefix, int tilenum, const uint8
|
||||||
TopOffset = top;
|
TopOffset = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
TArray<uint8_t> FBuildTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FBuildTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
TArray<uint8_t> Pixels(Width * Height, true);
|
TArray<uint8_t> Pixels(Width * Height, true);
|
||||||
FRemapTable *Remap = translationtables[TRANSLATION_Standard][Translation];
|
FRemapTable *Remap = translationtables[TRANSLATION_Standard][Translation];
|
||||||
for (int i = 0; i < Width*Height; i++)
|
for (int i = 0; i < Width*Height; i++)
|
||||||
{
|
{
|
||||||
auto c = RawPixels[i];
|
auto c = RawPixels[i];
|
||||||
Pixels[i] = alphatex ? Remap->Palette[c].Luminance() : Remap->Remap[c];
|
Pixels[i] = conversion == luminance ? Remap->Palette[c].Luminance() : Remap->Remap[c];
|
||||||
}
|
}
|
||||||
return Pixels;
|
return Pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FBuildTexture::CopyPixels(FBitmap *bmp)
|
int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry *Remap = translationtables[TRANSLATION_Standard][Translation]->Palette;
|
PalEntry *Remap = translationtables[TRANSLATION_Standard][Translation]->Palette;
|
||||||
bmp->CopyPixelData(0, 0, RawPixels, Width, Height, Height, 1, 0, Remap);
|
bmp->CopyPixelData(0, 0, RawPixels, Width, Height, Height, 1, 0, Remap);
|
||||||
|
|
|
@ -164,7 +164,7 @@ class FDDSTexture : public FImageSource
|
||||||
public:
|
public:
|
||||||
FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc);
|
FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc);
|
||||||
|
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t Format;
|
uint32_t Format;
|
||||||
|
@ -183,7 +183,7 @@ protected:
|
||||||
void DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t *buffer, int pixelmode);
|
void DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t *buffer, int pixelmode);
|
||||||
void DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t *buffer, int pixelmode);
|
void DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t *buffer, int pixelmode);
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
bool UseBasePalette();
|
bool UseBasePalette();
|
||||||
|
|
||||||
friend class FTexture;
|
friend class FTexture;
|
||||||
|
@ -373,7 +373,7 @@ void FDDSTexture::CalcBitShift (uint32_t mask, uint8_t *lshiftp, uint8_t *rshift
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FDDSTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FDDSTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ TArray<uint8_t> FDDSTexture::Get8BitPixels(bool alphatex)
|
||||||
|
|
||||||
lump.Seek (sizeof(DDSURFACEDESC2) + 4, FileReader::SeekSet);
|
lump.Seek (sizeof(DDSURFACEDESC2) + 4, FileReader::SeekSet);
|
||||||
|
|
||||||
int pmode = alphatex ? PIX_Alphatex : PIX_Palette;
|
int pmode = conversion == luminance ? PIX_Alphatex : PIX_Palette;
|
||||||
if (Format >= 1 && Format <= 4) // RGB: Format is # of bytes per pixel
|
if (Format >= 1 && Format <= 4) // RGB: Format is # of bytes per pixel
|
||||||
{
|
{
|
||||||
ReadRGB (lump, Pixels.Data(), pmode);
|
ReadRGB (lump, Pixels.Data(), pmode);
|
||||||
|
@ -782,7 +782,7 @@ void FDDSTexture::DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FDDSTexture::CopyPixels(FBitmap *bmp)
|
int FDDSTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class FEmptyTexture : public FImageSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FEmptyTexture (int lumpnum);
|
FEmptyTexture (int lumpnum);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -91,7 +91,7 @@ FEmptyTexture::FEmptyTexture (int lumpnum)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FEmptyTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FEmptyTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
TArray<uint8_t> Pixel(1, true);
|
TArray<uint8_t> Pixel(1, true);
|
||||||
Pixel[0] = 0;
|
Pixel[0] = 0;
|
||||||
|
|
|
@ -50,7 +50,7 @@ class FFlatTexture : public FImageSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FFlatTexture (int lumpnum);
|
FFlatTexture (int lumpnum);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ FFlatTexture::FFlatTexture (int lumpnum)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FFlatTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FFlatTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
TArray<uint8_t> Pixels(Width*Height, true);
|
TArray<uint8_t> Pixels(Width*Height, true);
|
||||||
|
@ -113,7 +113,7 @@ TArray<uint8_t> FFlatTexture::Get8BitPixels(bool alphatex)
|
||||||
{
|
{
|
||||||
memset (Pixels.Data() + numread, 0xBB, Width*Height - numread);
|
memset (Pixels.Data() + numread, 0xBB, Width*Height - numread);
|
||||||
}
|
}
|
||||||
ImageHelpers::FlipSquareBlockRemap(Pixels.Data(), Width, ImageHelpers::GetRemap(alphatex));
|
ImageHelpers::FlipSquareBlockRemap(Pixels.Data(), Width, ImageHelpers::GetRemap(conversion == luminance));
|
||||||
return Pixels;
|
return Pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ class FIMGZTexture : public FImageSource
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t, bool isalpha);
|
FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t, bool isalpha);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int1
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FIMGZTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FIMGZTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
FMemLump lump = Wads.ReadLump (SourceLump);
|
FMemLump lump = Wads.ReadLump (SourceLump);
|
||||||
const ImageHeader *imgz = (const ImageHeader *)lump.GetMem();
|
const ImageHeader *imgz = (const ImageHeader *)lump.GetMem();
|
||||||
|
@ -133,7 +133,7 @@ TArray<uint8_t> FIMGZTexture::Get8BitPixels(bool alphatex)
|
||||||
TArray<uint8_t> Pixels(Width*Height, true);
|
TArray<uint8_t> Pixels(Width*Height, true);
|
||||||
dest_p = Pixels.Data();
|
dest_p = Pixels.Data();
|
||||||
|
|
||||||
const uint8_t *remap = ImageHelpers::GetRemap(alphatex, isalpha);
|
const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance, isalpha);
|
||||||
|
|
||||||
// Convert the source image from row-major to column-major format and remap it
|
// Convert the source image from row-major to column-major format and remap it
|
||||||
if (!imgz->Compression)
|
if (!imgz->Compression)
|
||||||
|
@ -200,9 +200,9 @@ TArray<uint8_t> FIMGZTexture::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int FIMGZTexture::CopyPixels(FBitmap *bmp)
|
int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
if (!isalpha) return FImageSource::CopyPixels(bmp);
|
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||||
else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette);
|
else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,8 +185,8 @@ class FJPEGTexture : public FImageSource
|
||||||
public:
|
public:
|
||||||
FJPEGTexture (int lumpnum, int width, int height);
|
FJPEGTexture (int lumpnum, int width, int height);
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -260,7 +260,7 @@ FJPEGTexture::FJPEGTexture (int lumpnum, int width, int height)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FJPEGTexture::Get8BitPixels(bool doalpha)
|
TArray<uint8_t> FJPEGTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
JSAMPLE *buff = NULL;
|
JSAMPLE *buff = NULL;
|
||||||
|
@ -279,6 +279,7 @@ TArray<uint8_t> FJPEGTexture::Get8BitPixels(bool doalpha)
|
||||||
FLumpSourceMgr sourcemgr(&lump, &cinfo);
|
FLumpSourceMgr sourcemgr(&lump, &cinfo);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
bool doalpha = conversion == luminance;
|
||||||
jpeg_read_header(&cinfo, TRUE);
|
jpeg_read_header(&cinfo, TRUE);
|
||||||
if (!((cinfo.out_color_space == JCS_RGB && cinfo.num_components == 3) ||
|
if (!((cinfo.out_color_space == JCS_RGB && cinfo.num_components == 3) ||
|
||||||
(cinfo.out_color_space == JCS_CMYK && cinfo.num_components == 4) ||
|
(cinfo.out_color_space == JCS_CMYK && cinfo.num_components == 4) ||
|
||||||
|
@ -381,7 +382,7 @@ TArray<uint8_t> FJPEGTexture::Get8BitPixels(bool doalpha)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FJPEGTexture::CopyPixels(FBitmap *bmp)
|
int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,10 @@ class FPatchTexture : public FImageSource
|
||||||
{
|
{
|
||||||
bool badflag = false;
|
bool badflag = false;
|
||||||
bool isalpha = false;
|
bool isalpha = false;
|
||||||
bool bNoRemap0 = false; // Unfortunately this was done as a very bad hack in ZDoom and will need impovement
|
|
||||||
public:
|
public:
|
||||||
FPatchTexture (int lumpnum, patch_t *header, bool isalphatex);
|
FPatchTexture (int lumpnum, patch_t *header, bool isalphatex);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
void DetectBadPatches();
|
void DetectBadPatches();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -164,7 +163,7 @@ FPatchTexture::FPatchTexture (int lumpnum, patch_t * header, bool isalphatex)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FPatchTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FPatchTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
uint8_t *remap, remaptable[256];
|
uint8_t *remap, remaptable[256];
|
||||||
int numspans;
|
int numspans;
|
||||||
|
@ -176,9 +175,9 @@ TArray<uint8_t> FPatchTexture::Get8BitPixels(bool alphatex)
|
||||||
|
|
||||||
maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3);
|
maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3);
|
||||||
|
|
||||||
remap = ImageHelpers::GetRemap(alphatex, isalpha);
|
remap = ImageHelpers::GetRemap(conversion == luminance, isalpha);
|
||||||
// Special case for skies
|
// Special case for skies
|
||||||
if (bNoRemap0 && remap == GPalette.Remap)
|
if (conversion == noremap0 && remap == GPalette.Remap)
|
||||||
{
|
{
|
||||||
memcpy(remaptable, GPalette.Remap, 256);
|
memcpy(remaptable, GPalette.Remap, 256);
|
||||||
remaptable[0] = 0;
|
remaptable[0] = 0;
|
||||||
|
@ -261,9 +260,9 @@ TArray<uint8_t> FPatchTexture::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int FPatchTexture::CopyPixels(FBitmap *bmp)
|
int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
if (!isalpha) return FImageSource::CopyPixels(bmp);
|
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||||
else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette);
|
else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ class FPCXTexture : public FImageSource
|
||||||
public:
|
public:
|
||||||
FPCXTexture (int lumpnum, PCXHeader &);
|
FPCXTexture (int lumpnum, PCXHeader &);
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||||
|
@ -93,7 +93,7 @@ protected:
|
||||||
void ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
void ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||||
void ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes);
|
void ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes);
|
||||||
|
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FPCXTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FPCXTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
uint8_t PaletteMap[256];
|
uint8_t PaletteMap[256];
|
||||||
PCXHeader header;
|
PCXHeader header;
|
||||||
|
@ -371,6 +371,7 @@ TArray<uint8_t> FPCXTexture::Get8BitPixels(bool alphatex)
|
||||||
bitcount = header.bitsPerPixel * header.numColorPlanes;
|
bitcount = header.bitsPerPixel * header.numColorPlanes;
|
||||||
TArray<uint8_t> Pixels(Width*Height, true);
|
TArray<uint8_t> Pixels(Width*Height, true);
|
||||||
|
|
||||||
|
bool alphatex = conversion == luminance;
|
||||||
if (bitcount < 24)
|
if (bitcount < 24)
|
||||||
{
|
{
|
||||||
if (bitcount < 8)
|
if (bitcount < 8)
|
||||||
|
@ -446,7 +447,7 @@ TArray<uint8_t> FPCXTexture::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FPCXTexture::CopyPixels(FBitmap *bmp)
|
int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
PCXHeader header;
|
PCXHeader header;
|
||||||
|
|
|
@ -54,9 +54,8 @@ public:
|
||||||
FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, uint8_t bitdepth, uint8_t colortype, uint8_t interlace);
|
FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, uint8_t bitdepth, uint8_t colortype, uint8_t interlace);
|
||||||
~FPNGTexture();
|
~FPNGTexture();
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
bool UseBasePalette() override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ReadAlphaRemap(FileReader *lump, uint8_t *alpharemap);
|
void ReadAlphaRemap(FileReader *lump, uint8_t *alpharemap);
|
||||||
|
@ -182,7 +181,7 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FPNGTexture (png->File, -1, filename, width, height, bitdepth, colortype, interlace);
|
return new FImageTexture(new FPNGTexture (png->File, -1, filename, width, height, bitdepth, colortype, interlace));
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -193,7 +192,7 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
|
||||||
|
|
||||||
FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
|
FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
|
||||||
uint8_t depth, uint8_t colortype, uint8_t interlace)
|
uint8_t depth, uint8_t colortype, uint8_t interlace)
|
||||||
: FWorldTexture(NULL, lumpnum), SourceFile(filename),
|
: FImageSource(lumpnum), SourceFile(filename),
|
||||||
BitDepth(depth), ColorType(colortype), Interlace(interlace), HaveTrans(false)
|
BitDepth(depth), ColorType(colortype), Interlace(interlace), HaveTrans(false)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
|
@ -205,7 +204,6 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
|
||||||
uint32_t len, id;
|
uint32_t len, id;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
UseType = ETextureType::MiscPatch;
|
|
||||||
bMasked = false;
|
bMasked = false;
|
||||||
|
|
||||||
Width = width;
|
Width = width;
|
||||||
|
@ -247,8 +245,8 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
|
||||||
Printf ("Y-Offset for PNG texture %s is bad: %d (0x%08x)\n", Wads.GetLumpFullName (lumpnum), ihoty, ihoty);
|
Printf ("Y-Offset for PNG texture %s is bad: %d (0x%08x)\n", Wads.GetLumpFullName (lumpnum), ihoty, ihoty);
|
||||||
ihoty = 0;
|
ihoty = 0;
|
||||||
}
|
}
|
||||||
_LeftOffset[1] = _LeftOffset[0] = ihotx;
|
LeftOffset = ihotx;
|
||||||
_TopOffset[1] = _TopOffset[0] = ihoty;
|
TopOffset = ihoty;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -369,7 +367,7 @@ void FPNGTexture::ReadAlphaRemap(FileReader *lump, uint8_t *alpharemap)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FPNGTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FPNGTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
FileReader *lump;
|
FileReader *lump;
|
||||||
FileReader lfr;
|
FileReader lfr;
|
||||||
|
@ -396,13 +394,14 @@ TArray<uint8_t> FPNGTexture::Get8BitPixels(bool alphatex)
|
||||||
lump->Read(&len, 4);
|
lump->Read(&len, 4);
|
||||||
lump->Read(&id, 4);
|
lump->Read(&id, 4);
|
||||||
|
|
||||||
|
bool alphatex = conversion == luminance;
|
||||||
if (ColorType == 0 || ColorType == 3) /* Grayscale and paletted */
|
if (ColorType == 0 || ColorType == 3) /* Grayscale and paletted */
|
||||||
{
|
{
|
||||||
M_ReadIDAT (*lump, Pixels.Data(), Width, Height, Width, BitDepth, ColorType, Interlace, BigLong((unsigned int)len));
|
M_ReadIDAT (*lump, Pixels.Data(), Width, Height, Width, BitDepth, ColorType, Interlace, BigLong((unsigned int)len));
|
||||||
|
|
||||||
if (Width == Height)
|
if (Width == Height)
|
||||||
{
|
{
|
||||||
if (!alphatex)
|
if (conversion != luminance)
|
||||||
{
|
{
|
||||||
ImageHelpers::FlipSquareBlockRemap (Pixels.Data(), Width, PaletteMap);
|
ImageHelpers::FlipSquareBlockRemap (Pixels.Data(), Width, PaletteMap);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +419,7 @@ TArray<uint8_t> FPNGTexture::Get8BitPixels(bool alphatex)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TArray<uint8_t> newpix(Width*Height, true);
|
TArray<uint8_t> newpix(Width*Height, true);
|
||||||
if (!alphatex)
|
if (conversion != luminance)
|
||||||
{
|
{
|
||||||
ImageHelpers::FlipNonSquareBlockRemap (newpix.Data(), Pixels.Data(), Width, Height, Width, PaletteMap);
|
ImageHelpers::FlipNonSquareBlockRemap (newpix.Data(), Pixels.Data(), Width, Height, Width, PaletteMap);
|
||||||
}
|
}
|
||||||
|
@ -513,7 +512,7 @@ TArray<uint8_t> FPNGTexture::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FPNGTexture::CopyPixels(FBitmap *bmp)
|
int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
|
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
|
@ -631,17 +630,3 @@ int FPNGTexture::CopyPixels(FBitmap *bmp)
|
||||||
delete[] Pixels;
|
delete[] Pixels;
|
||||||
return transpal;
|
return transpal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// This doesn't check if the palette is identical with the base palette
|
|
||||||
// I don't think it's worth the hassle because it's only of importance
|
|
||||||
// when compositing multipatch textures.
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
bool FPNGTexture::UseBasePalette()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ class FRawPageTexture : public FImageSource
|
||||||
int mPaletteLump = -1;
|
int mPaletteLump = -1;
|
||||||
public:
|
public:
|
||||||
FRawPageTexture (int lumpnum);
|
FRawPageTexture (int lumpnum);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -173,7 +173,7 @@ FRawPageTexture::FRawPageTexture (int lumpnum)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FRawPageTexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FRawPageTexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
FMemLump lump = Wads.ReadLump (SourceLump);
|
FMemLump lump = Wads.ReadLump (SourceLump);
|
||||||
const uint8_t *source = (const uint8_t *)lump.GetMem();
|
const uint8_t *source = (const uint8_t *)lump.GetMem();
|
||||||
|
@ -183,7 +183,7 @@ TArray<uint8_t> FRawPageTexture::Get8BitPixels(bool alphatex)
|
||||||
TArray<uint8_t> Pixels(Width*Height, true);
|
TArray<uint8_t> Pixels(Width*Height, true);
|
||||||
dest_p = Pixels.Data();
|
dest_p = Pixels.Data();
|
||||||
|
|
||||||
const uint8_t *remap = ImageHelpers::GetRemap(alphatex);
|
const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
|
||||||
|
|
||||||
// This does not handle the custom palette.
|
// This does not handle the custom palette.
|
||||||
// User maps are encouraged to use a real image format when replacing E2END and the original could never be used anywhere else.
|
// User maps are encouraged to use a real image format when replacing E2END and the original could never be used anywhere else.
|
||||||
|
@ -202,9 +202,9 @@ TArray<uint8_t> FRawPageTexture::Get8BitPixels(bool alphatex)
|
||||||
return Pixels;
|
return Pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FRawPageTexture::CopyPixels(FBitmap *bmp)
|
int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp);
|
if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp, conversion);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FMemLump lump = Wads.ReadLump(SourceLump);
|
FMemLump lump = Wads.ReadLump(SourceLump);
|
||||||
|
|
|
@ -100,10 +100,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override
|
TArray<uint8_t> GetPalettedPixels(int conversion) override
|
||||||
{
|
{
|
||||||
TArray<uint8_t> Pix(512, true);
|
TArray<uint8_t> Pix(512, true);
|
||||||
if (alphatex)
|
if (conversion == luminance)
|
||||||
{
|
{
|
||||||
memcpy(Pix.Data(), Pixels, 512);
|
memcpy(Pix.Data(), Pixels, 512);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public:
|
||||||
return Pix;
|
return Pix;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override
|
int CopyPixels(FBitmap *bmp, int conversion) override
|
||||||
{
|
{
|
||||||
bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, translationtables[TRANSLATION_Standard][8]->Palette);
|
bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, translationtables[TRANSLATION_Standard][8]->Palette);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -134,5 +134,6 @@ private:
|
||||||
FTexture *CreateShaderTexture(bool vertical, bool reverse)
|
FTexture *CreateShaderTexture(bool vertical, bool reverse)
|
||||||
{
|
{
|
||||||
FStringf name("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f');
|
FStringf name("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f');
|
||||||
auto tex = new FImageTexture(new FBarShader(vertical, reverse), name.GetChars());
|
return new FImageTexture(new FBarShader(vertical, reverse), name.GetChars());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,11 +81,11 @@ class FTGATexture : public FImageSource
|
||||||
public:
|
public:
|
||||||
FTGATexture (int lumpnum, TGAHeader *);
|
FTGATexture (int lumpnum, TGAHeader *);
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp) override;
|
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel);
|
void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel);
|
||||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
TArray<uint8_t> GetPalettedPixels(int conversion) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -179,7 +179,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FTGATexture::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
uint8_t PaletteMap[256];
|
uint8_t PaletteMap[256];
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
|
@ -232,7 +232,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
r=g=b=a=0;
|
r=g=b=a=0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PaletteMap[i] = ImageHelpers::RGBToPalettePrecise(alphatex, r, g, b, a);
|
PaletteMap[i] = ImageHelpers::RGBToPalettePrecise(conversion == luminance, r, g, b, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
for(int x=0;x<Width;x++)
|
for(int x=0;x<Width;x++)
|
||||||
{
|
{
|
||||||
int v = LittleShort(*p);
|
int v = LittleShort(*p);
|
||||||
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(alphatex, ((v >> 10) & 0x1f) * 8, ((v >> 5) & 0x1f) * 8, (v & 0x1f) * 8);
|
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(conversion == luminance, ((v >> 10) & 0x1f) * 8, ((v >> 5) & 0x1f) * 8, (v & 0x1f) * 8);
|
||||||
p+=step_x;
|
p+=step_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
uint8_t * p = ptr + y * Pitch;
|
uint8_t * p = ptr + y * Pitch;
|
||||||
for(int x=0;x<Width;x++)
|
for(int x=0;x<Width;x++)
|
||||||
{
|
{
|
||||||
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(alphatex, p[2], p[1], p[0]);
|
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(conversion == luminance, p[2], p[1], p[0]);
|
||||||
p+=step_x;
|
p+=step_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
uint8_t * p = ptr + y * Pitch;
|
uint8_t * p = ptr + y * Pitch;
|
||||||
for(int x=0;x<Width;x++)
|
for(int x=0;x<Width;x++)
|
||||||
{
|
{
|
||||||
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(alphatex, p[2], p[1], p[0]);
|
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(conversion == luminance, p[2], p[1], p[0]);
|
||||||
p+=step_x;
|
p+=step_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
uint8_t * p = ptr + y * Pitch;
|
uint8_t * p = ptr + y * Pitch;
|
||||||
for(int x=0;x<Width;x++)
|
for(int x=0;x<Width;x++)
|
||||||
{
|
{
|
||||||
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(alphatex, p[2], p[1], p[0], p[3]);
|
Pixels[x*Height + y] = ImageHelpers::RGBToPalette(conversion == luminance, p[2], p[1], p[0], p[3]);
|
||||||
p+=step_x;
|
p+=step_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
|
|
||||||
case 3: // Grayscale
|
case 3: // Grayscale
|
||||||
{
|
{
|
||||||
auto remap = ImageHelpers::GetRemap(alphatex, true);
|
auto remap = ImageHelpers::GetRemap(conversion == luminance, true);
|
||||||
switch (hdr.bpp)
|
switch (hdr.bpp)
|
||||||
{
|
{
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -388,7 +388,7 @@ TArray<uint8_t> FTGATexture::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FTGATexture::CopyPixels(FBitmap *bmp)
|
int FTGATexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry pe[256];
|
PalEntry pe[256];
|
||||||
auto lump = Wads.OpenLumpReader (SourceLump);
|
auto lump = Wads.OpenLumpReader (SourceLump);
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
TArray<uint8_t> FImageSource::Get8BitPixels(bool alphatex)
|
TArray<uint8_t> FImageSource::GetPalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
TArray<uint8_t> Pixels(Width * Height, true);
|
TArray<uint8_t> Pixels(Width * Height, true);
|
||||||
memset(Pixels.Data(), 0, Width * Height);
|
memset(Pixels.Data(), 0, Width * Height);
|
||||||
|
@ -65,11 +65,12 @@ TArray<uint8_t> FImageSource::Get8BitPixels(bool alphatex)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int FImageSource::CopyPixels(FBitmap *bmp)
|
int FImageSource::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
|
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
||||||
PalEntry *palette = screen->GetPalette();
|
PalEntry *palette = screen->GetPalette();
|
||||||
for(int i=1;i<256;i++) palette[i].a = 255; // set proper alpha values
|
for(int i=1;i<256;i++) palette[i].a = 255; // set proper alpha values
|
||||||
auto ppix = Get8BitPixels(false); // should use composition cache
|
auto ppix = GetPalettedPixels(conversion); // should use composition cache
|
||||||
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, palette, nullptr);
|
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, palette, nullptr);
|
||||||
for(int i=1;i<256;i++) palette[i].a = 0;
|
for(int i=1;i<256;i++) palette[i].a = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -77,8 +78,7 @@ int FImageSource::CopyPixels(FBitmap *bmp)
|
||||||
|
|
||||||
int FImageSource::CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap)
|
int FImageSource::CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap)
|
||||||
{
|
{
|
||||||
auto ppix = Get8BitPixels(false); // should use composition cache
|
auto ppix = GetPalettedPixels(false); // should use composition cache
|
||||||
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, remap, nullptr);
|
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, remap, nullptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,14 @@ protected:
|
||||||
int LeftOffset = 0, TopOffset = 0; // Offsets stored in the image.
|
int LeftOffset = 0, TopOffset = 0; // Offsets stored in the image.
|
||||||
bool bUseGamePalette = false; // true if this is an image without its own color set.
|
bool bUseGamePalette = false; // true if this is an image without its own color set.
|
||||||
|
|
||||||
// internal builder functions for true color textures.
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool bMasked = true; // Image (might) have holes (Assume true unless proven otherwise!)
|
bool bMasked = true; // Image (might) have holes (Assume true unless proven otherwise!)
|
||||||
int8_t bTranslucent = -1; // Image has pixels with a non-0/1 value. (-1 means the user needs to do a real check)
|
int8_t bTranslucent = -1; // Image has pixels with a non-0/1 value. (-1 means the user needs to do a real check)
|
||||||
|
|
||||||
// Returns the whole texture, paletted and true color versions respectively.
|
// Returns the whole texture, paletted and true color versions respectively.
|
||||||
virtual TArray<uint8_t> Get8BitPixels(bool alphatex);
|
virtual TArray<uint8_t> GetPalettedPixels(int conversion); // 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture.
|
||||||
virtual int CopyPixels(FBitmap *bmp);
|
virtual int CopyPixels(FBitmap *bmp, int conversion); // This will always ignore 'luminance'.
|
||||||
int CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap);
|
int CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap);
|
||||||
|
|
||||||
// Conversion option
|
// Conversion option
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FImageTexture::FImageTexture(FImageSource *img, const char *name)
|
FImageTexture::FImageTexture(FImageSource *img, const char *name)
|
||||||
: FWorldTexture(name, img->LumpNum())
|
: FTexture(name, img->LumpNum())
|
||||||
{
|
{
|
||||||
mImage = img;
|
mImage = img;
|
||||||
Wads.GetLumpName (Name, img->LumpNum());
|
Wads.GetLumpName (Name, img->LumpNum());
|
||||||
|
@ -72,7 +72,7 @@ FImageTexture::FImageTexture(FImageSource *img, const char *name)
|
||||||
|
|
||||||
int FImageTexture::CopyPixels(FBitmap *bmp)
|
int FImageTexture::CopyPixels(FBitmap *bmp)
|
||||||
{
|
{
|
||||||
return mImage->CopyPixels(bmp);
|
return mImage->CopyPixels(bmp, bNoRemap0? FImageSource::noremap0 : FImageSource::normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -83,7 +83,7 @@ int FImageTexture::CopyPixels(FBitmap *bmp)
|
||||||
|
|
||||||
TArray<uint8_t> FImageTexture::Get8BitPixels(bool alpha)
|
TArray<uint8_t> FImageTexture::Get8BitPixels(bool alpha)
|
||||||
{
|
{
|
||||||
return mImage->Get8BitPixels(alpha);
|
return mImage->GetPalettedPixels(alpha? alpha : bNoRemap0 ? FImageSource::noremap0 : FImageSource::normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
Loading…
Reference in a new issue