mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 15:22:08 +00:00
- Fixed: Coordinate handling for multipatch texture compositing was not correct
for true color. Instead of using a clipping rectangle on the destination it tried to alter the source offsets which produced incorrect results for mirrored or rotated patches. SVN r1889 (trunk)
This commit is contained in:
parent
ed8f1ec8db
commit
7e4504f9d6
13 changed files with 158 additions and 102 deletions
|
@ -1,3 +1,9 @@
|
|||
September 30, 2009 (Changes by Graf Zahl)
|
||||
- Fixed: Coordinate handling for multipatch texture compositing was not correct
|
||||
for true color. Instead of using a clipping rectangle on the destination it
|
||||
tried to alter the source offsets which produced incorrect results for
|
||||
mirrored or rotated patches.
|
||||
|
||||
September 29, 2009
|
||||
- Fixed: Alt+F4 no longer quit the program.
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
FWarpTexture (FTexture *source);
|
||||
~FWarpTexture ();
|
||||
|
||||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w=-1, int h=-1, int rotate=0, FCopyInfo *inf = NULL);
|
||||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
|
||||
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
|
||||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
|
@ -93,8 +93,6 @@ public:
|
|||
void Unload ();
|
||||
bool CheckModified ();
|
||||
void RenderView (AActor *viewpoint, int fov);
|
||||
void RenderGLView(AActor *viewpoint, int fov);
|
||||
void NeedUpdate() { bNeedsUpdate=true; }
|
||||
|
||||
protected:
|
||||
DSimpleCanvas *Canvas;
|
||||
|
|
|
@ -280,7 +280,7 @@ static const CopyFunc copyfuncs[][9]={
|
|||
// Clips the copy area for CopyPixelData functions
|
||||
//
|
||||
//===========================================================================
|
||||
bool ClipCopyPixelRect(int texwidth, int texheight, int &originx, int &originy,
|
||||
bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
|
||||
const BYTE *&patch, int &srcwidth, int &srcheight,
|
||||
int &pstep_x, int &pstep_y, int rotate)
|
||||
{
|
||||
|
@ -290,6 +290,7 @@ bool ClipCopyPixelRect(int texwidth, int texheight, int &originx, int &originy,
|
|||
int step_x;
|
||||
int step_y;
|
||||
|
||||
assert(cr != NULL);
|
||||
// First adjust the settings for the intended rotation
|
||||
switch (rotate)
|
||||
{
|
||||
|
@ -362,35 +363,71 @@ bool ClipCopyPixelRect(int texwidth, int texheight, int &originx, int &originy,
|
|||
pstep_y = step_y;
|
||||
|
||||
// clip source rectangle to destination
|
||||
if (originx<0)
|
||||
if (originx < cr->x)
|
||||
{
|
||||
srcwidth+=originx;
|
||||
patch-=originx*step_x;
|
||||
originx=0;
|
||||
int skip = cr->x - originx;
|
||||
|
||||
srcwidth -= skip;
|
||||
patch +=skip * step_x;
|
||||
originx = cr->x;
|
||||
if (srcwidth<=0) return false;
|
||||
}
|
||||
if (originx+srcwidth>texwidth)
|
||||
if (originx + srcwidth > cr->x + cr->width)
|
||||
{
|
||||
srcwidth=texwidth-originx;
|
||||
srcwidth = cr->x + cr->width - originx;
|
||||
if (srcwidth<=0) return false;
|
||||
}
|
||||
|
||||
if (originy<0)
|
||||
if (originy < cr->y)
|
||||
{
|
||||
srcheight+=originy;
|
||||
patch-=originy*step_y;
|
||||
originy=0;
|
||||
if (srcheight<=0) return false;
|
||||
int skip = cr->y - originy;
|
||||
|
||||
srcheight -= skip;
|
||||
patch += skip*step_y;
|
||||
originy = cr->y;
|
||||
if (srcheight <= 0) return false;
|
||||
}
|
||||
if (originy+srcheight>texheight)
|
||||
if (originy + srcheight > cr->y + cr->height)
|
||||
{
|
||||
srcheight=texheight-originy;
|
||||
if (srcheight<=0) return false;
|
||||
srcheight = cr->y + cr->height - originy;
|
||||
if (srcheight <= 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool FClipRect::Intersect(int ix, int iy, int iw, int ih)
|
||||
{
|
||||
if (ix > x)
|
||||
{
|
||||
width -= (ix-x);
|
||||
x = ix;
|
||||
}
|
||||
else
|
||||
{
|
||||
iw -= (x-ix);
|
||||
}
|
||||
if (iy > y)
|
||||
{
|
||||
height -= (iy-y);
|
||||
y = iy;
|
||||
}
|
||||
else
|
||||
{
|
||||
ih -= (x-ih);
|
||||
}
|
||||
if (iw < width) width = iw;
|
||||
if (ih < height) height = ih;
|
||||
return width > 0 && height > 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// True Color texture copy function
|
||||
|
@ -399,7 +436,7 @@ bool ClipCopyPixelRect(int texwidth, int texheight, int &originx, int &originy,
|
|||
void FBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth,
|
||||
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf)
|
||||
{
|
||||
if (ClipCopyPixelRect(Width, Height, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
{
|
||||
BYTE *buffer = data + 4 * originx + Pitch * originy;
|
||||
int op = inf==NULL? OP_COPY : inf->op;
|
||||
|
@ -460,7 +497,7 @@ static const CopyPalettedFunc copypalettedfuncs[]=
|
|||
void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight,
|
||||
int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf)
|
||||
{
|
||||
if (ClipCopyPixelRect(Width, Height, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
{
|
||||
BYTE *buffer = data + 4*originx + Pitch*originy;
|
||||
PalEntry penew[256];
|
||||
|
@ -485,9 +522,9 @@ void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int sr
|
|||
void FBitmap::Zero()
|
||||
{
|
||||
BYTE *buffer = data;
|
||||
for (int y = 0; y < Height; ++y)
|
||||
for (int y = ClipRect.y; y < ClipRect.height; ++y)
|
||||
{
|
||||
memset(buffer, 0, Width*4);
|
||||
memset(buffer + ClipRect.x, 0, ClipRect.width*4);
|
||||
buffer += Pitch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,13 @@
|
|||
|
||||
struct FCopyInfo;
|
||||
|
||||
struct FClipRect
|
||||
{
|
||||
int x, y, width, height;
|
||||
|
||||
bool Intersect(int ix, int iy, int iw, int ih);
|
||||
};
|
||||
|
||||
class FBitmap
|
||||
{
|
||||
protected:
|
||||
|
@ -49,6 +56,8 @@ protected:
|
|||
int Height;
|
||||
int Pitch;
|
||||
bool FreeBuffer;
|
||||
FClipRect ClipRect;
|
||||
|
||||
|
||||
public:
|
||||
FBitmap()
|
||||
|
@ -57,6 +66,7 @@ public:
|
|||
Width = Height = 0;
|
||||
Pitch = 0;
|
||||
FreeBuffer = false;
|
||||
ClipRect.x = ClipRect.y = ClipRect.width = ClipRect.height = 0;
|
||||
}
|
||||
|
||||
FBitmap(BYTE *buffer, int pitch, int width, int height)
|
||||
|
@ -67,6 +77,9 @@ public:
|
|||
Width = width;
|
||||
Height = height;
|
||||
FreeBuffer = false;
|
||||
ClipRect.x = ClipRect.y = 0;
|
||||
ClipRect.width = width;
|
||||
ClipRect.height = height;
|
||||
}
|
||||
|
||||
virtual ~FBitmap()
|
||||
|
@ -88,6 +101,9 @@ public:
|
|||
Height = h;
|
||||
data = new BYTE[4*w*h];
|
||||
FreeBuffer = true;
|
||||
ClipRect.x = ClipRect.y = 0;
|
||||
ClipRect.width = w;
|
||||
ClipRect.height = h;
|
||||
return data != NULL;
|
||||
}
|
||||
|
||||
|
@ -116,8 +132,29 @@ public:
|
|||
return data;
|
||||
}
|
||||
|
||||
void SetClipRect(FClipRect &clip)
|
||||
{
|
||||
ClipRect = clip;
|
||||
}
|
||||
|
||||
void IntersectClipRect(FClipRect &clip)
|
||||
{
|
||||
ClipRect.Intersect(clip.x, clip.y, clip.width, clip.height);
|
||||
}
|
||||
|
||||
void IntersectClipRect(int cx, int cy, int cw, int ch)
|
||||
{
|
||||
ClipRect.Intersect(cx, cy, cw, ch);
|
||||
}
|
||||
|
||||
const FClipRect &GetClipRect() const
|
||||
{
|
||||
return ClipRect;
|
||||
}
|
||||
|
||||
void Zero();
|
||||
|
||||
|
||||
virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth,
|
||||
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL);
|
||||
virtual void CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight,
|
||||
|
@ -126,7 +163,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
bool ClipCopyPixelRect(int texwidth, int texheight, int &originx, int &originy,
|
||||
bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy,
|
||||
const BYTE *&patch, int &srcwidth, int &srcheight,
|
||||
int &step_x, int &step_y, int rotate);
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ protected:
|
|||
void DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL);
|
||||
void DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL);
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
||||
friend class FTexture;
|
||||
|
@ -874,7 +874,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
|
||||
|
@ -899,11 +899,8 @@ int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
DecompressDXT5 (lump, Format == ID_DXT4, TexBuffer);
|
||||
}
|
||||
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
|
||||
// All formats decompress to RGBA.
|
||||
bmp->CopyPixelDataRGB(x, y, TexBuffer, w, h, 4, Width*4, rotate, CF_RGBA, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, TexBuffer, Width, Height, 4, Width*4, rotate, CF_RGBA, inf);
|
||||
delete [] TexBuffer;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
||||
protected:
|
||||
|
@ -445,7 +445,7 @@ void FJPEGTexture::MakeTexture ()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
|
||||
|
@ -460,9 +460,6 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h,
|
|||
cinfo.err->error_exit = JPEG_ErrorExit;
|
||||
jpeg_create_decompress(&cinfo);
|
||||
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
|
||||
try
|
||||
{
|
||||
FLumpSourceMgr sourcemgr(&lump, &cinfo);
|
||||
|
@ -491,18 +488,18 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h,
|
|||
switch (cinfo.out_color_space)
|
||||
{
|
||||
case JCS_RGB:
|
||||
bmp->CopyPixelDataRGB(x, y, buff, w, h,
|
||||
bmp->CopyPixelDataRGB(x, y, buff, cinfo.output_width, cinfo.output_height,
|
||||
3, cinfo.output_width * cinfo.output_components, rotate, CF_RGB, inf);
|
||||
break;
|
||||
|
||||
case JCS_GRAYSCALE:
|
||||
for(int i=0;i<256;i++) pe[i]=PalEntry(255,i,i,i); // default to a gray map
|
||||
bmp->CopyPixelData(x, y, buff, w, h,
|
||||
bmp->CopyPixelData(x, y, buff, cinfo.output_width, cinfo.output_height,
|
||||
1, cinfo.output_width, rotate, pe, inf);
|
||||
break;
|
||||
|
||||
case JCS_CMYK:
|
||||
bmp->CopyPixelDataRGB(x, y, buff, w, h,
|
||||
bmp->CopyPixelDataRGB(x, y, buff, cinfo.output_width, cinfo.output_height,
|
||||
4, cinfo.output_width * cinfo.output_components, rotate, CF_CMYK, inf);
|
||||
break;
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public:
|
|||
void Unload ();
|
||||
virtual void SetFrontSkyLayer ();
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
int GetSourceLump() { return DefinitionLump; }
|
||||
|
||||
protected:
|
||||
|
@ -542,13 +542,15 @@ void FMultiPatchTexture::MakeTexture ()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
int retv = -1;
|
||||
FCopyInfo info;
|
||||
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
// When compositing a multipatch texture with multipatch parts
|
||||
// drawing must be restricted to the actual area which is covered by this texture.
|
||||
FClipRect saved_cr = bmp->GetClipRect();
|
||||
bmp->IntersectClipRect(x, y, Width, Height);
|
||||
|
||||
if (inf != NULL && inf->op == OP_OVERWRITE)
|
||||
{
|
||||
|
@ -568,10 +570,7 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, i
|
|||
if (Parts[i].Translation != NULL)
|
||||
{
|
||||
// Using a translation forces downconversion to the base palette
|
||||
ret = Parts[i].Texture->CopyTrueColorTranslated(bmp,
|
||||
x+Parts[i].OriginX, y+Parts[i].OriginY,
|
||||
Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight(),
|
||||
Parts[i].Rotate, Parts[i].Translation, &info);
|
||||
ret = Parts[i].Texture->CopyTrueColorTranslated(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, Parts[i].Translation, &info);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -599,10 +598,7 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, i
|
|||
info.blend = BLEND_OVERLAY;
|
||||
}
|
||||
}
|
||||
ret = Parts[i].Texture->CopyTrueColorPixels(bmp,
|
||||
x+Parts[i].OriginX, y+Parts[i].OriginY,
|
||||
Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight(),
|
||||
Parts[i].Rotate, &info);
|
||||
ret = Parts[i].Texture->CopyTrueColorPixels(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, &info);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -615,15 +611,15 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, i
|
|||
if (bmp1.Create(Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight()))
|
||||
{
|
||||
Parts[i].Texture->CopyTrueColorPixels(&bmp1, 0, 0);
|
||||
bmp->CopyPixelDataRGB(
|
||||
x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(),
|
||||
bmp1.GetWidth(), bmp1.GetHeight(),
|
||||
4, bmp1.GetPitch()*4, Parts[i].Rotate, CF_BGRA, inf);
|
||||
bmp->CopyPixelDataRGB(x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(),
|
||||
bmp1.GetWidth(), bmp1.GetHeight(), 4, bmp1.GetPitch()*4, Parts[i].Rotate, CF_BGRA, inf);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret > retv) retv = ret;
|
||||
}
|
||||
// Restore previous clipping rectangle.
|
||||
bmp->SetClipRect(saved_cr);
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
||||
protected:
|
||||
|
@ -543,7 +543,7 @@ void FPCXTexture::MakeTexture()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
PCXHeader header;
|
||||
|
@ -556,9 +556,6 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
|
||||
bitcount = header.bitsPerPixel * header.numColorPlanes;
|
||||
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
|
||||
if (bitcount < 24)
|
||||
{
|
||||
Pixels = new BYTE[Width*Height];
|
||||
|
@ -600,13 +597,13 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
lump.Seek(sizeof(header), SEEK_SET);
|
||||
ReadPCX8bits (Pixels, lump, &header);
|
||||
}
|
||||
bmp->CopyPixelData(x, y, Pixels, w, h, 1, Width, rotate, pe, inf);
|
||||
bmp->CopyPixelData(x, y, Pixels, Width, Height, 1, Width, rotate, pe, inf);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pixels = new BYTE[Width*Height * 3];
|
||||
ReadPCX24bits (Pixels, lump, &header, 3);
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 3, Width*3, rotate, CF_RGB, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, Width*3, rotate, CF_RGB, inf);
|
||||
}
|
||||
delete [] Pixels;
|
||||
return 0;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
||||
protected:
|
||||
|
@ -583,7 +583,7 @@ void FPNGTexture::MakeTexture ()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
|
||||
PalEntry pe[256];
|
||||
|
@ -593,9 +593,6 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
int pixwidth = Width * bpp[ColorType];
|
||||
int transpal = false;
|
||||
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
|
||||
if (SourceLump >= 0)
|
||||
{
|
||||
lump = new FWadLump(Wads.OpenLumpNum(SourceLump));
|
||||
|
@ -654,20 +651,20 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
{
|
||||
case 0:
|
||||
case 3:
|
||||
bmp->CopyPixelData(x, y, Pixels, w, h, 1, Width, rotate, pe, inf);
|
||||
bmp->CopyPixelData(x, y, Pixels, Width, Height, 1, Width, rotate, pe, inf);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 3, pixwidth, rotate, CF_RGB, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, pixwidth, rotate, CF_RGB, inf);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 2, pixwidth, rotate, CF_IA, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 2, pixwidth, rotate, CF_IA, inf);
|
||||
transpal = -1;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 4, pixwidth, rotate, CF_RGBA, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 4, pixwidth, rotate, CF_RGBA, inf);
|
||||
transpal = -1;
|
||||
break;
|
||||
|
||||
|
|
|
@ -316,8 +316,9 @@ void FTexture::CopyToBlock (BYTE *dest, int dwidth, int dheight, int xpos, int y
|
|||
int srcheight = Height;
|
||||
int step_x = Height;
|
||||
int step_y = 1;
|
||||
FClipRect cr = {0, 0, dwidth, dheight};
|
||||
|
||||
if (ClipCopyPixelRect(dwidth, dheight, xpos, ypos, pixels, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
if (ClipCopyPixelRect(&cr, xpos, ypos, pixels, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
{
|
||||
dest += ypos + dheight * xpos;
|
||||
if (translation == NULL)
|
||||
|
@ -498,7 +499,7 @@ void FTexture::FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt)
|
|||
{
|
||||
FCopyInfo inf = {OP_OVERWRITE, };
|
||||
FBitmap bmp(buff, pitch, pitch/4, height);
|
||||
CopyTrueColorPixels(&bmp, 0, 0, -1, -1, 0, &inf);
|
||||
CopyTrueColorPixels(&bmp, 0, 0, 0, &inf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -519,23 +520,19 @@ void FTexture::FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
PalEntry *palette = screen->GetPalette();
|
||||
for(int i=1;i<256;i++) palette[i].a = 255; // set proper alpha values
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
bmp->CopyPixelData(x, y, GetPixels(), w, h, Height, 1, rotate, palette, inf);
|
||||
bmp->CopyPixelData(x, y, GetPixels(), Width, Height, Height, 1, rotate, palette, inf);
|
||||
for(int i=1;i<256;i++) palette[i].a = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int w, int h, int rotate, FRemapTable *remap, FCopyInfo *inf)
|
||||
int FTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf)
|
||||
{
|
||||
PalEntry *palette = remap->Palette;
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
bmp->CopyPixelData(x, y, GetPixels(), w, h, Height, 1, rotate, palette, inf);
|
||||
bmp->CopyPixelData(x, y, GetPixels(), Width, Height, Height, 1, rotate, palette, inf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@ public:
|
|||
// Returns the whole texture, stored in column-major order
|
||||
virtual const BYTE *GetPixels () = 0;
|
||||
|
||||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w=-1, int h=-1, int rotate=0, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorTranslated(FBitmap *bmp, int x, int y,int w, int h, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL);
|
||||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL);
|
||||
virtual bool UseBasePalette();
|
||||
virtual int GetSourceLump() { return SourceLump; }
|
||||
virtual FTexture *GetRedirect(bool wantwarped);
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
||||
protected:
|
||||
|
@ -487,12 +487,12 @@ void FTGATexture::MakeTexture ()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
TGAHeader hdr;
|
||||
WORD wr;
|
||||
WORD w;
|
||||
BYTE r,g,b,a;
|
||||
BYTE * sbuffer;
|
||||
int transval = 0;
|
||||
|
@ -500,9 +500,6 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
lump.Read(&hdr, sizeof(hdr));
|
||||
lump.Seek(hdr.id_len, SEEK_CUR);
|
||||
|
||||
if (w < 0 || w > Width) w = Width;
|
||||
if (h < 0 || h > Height) h = Height;
|
||||
|
||||
hdr.width = LittleShort(hdr.width);
|
||||
hdr.height = LittleShort(hdr.height);
|
||||
hdr.cm_first = LittleShort(hdr.cm_first);
|
||||
|
@ -517,10 +514,10 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
{
|
||||
case 15:
|
||||
case 16:
|
||||
lump >> wr;
|
||||
r = (wr & 0x001F) << 3;
|
||||
g = (wr & 0x03E0) >> 2;
|
||||
b = (wr & 0x7C00) >> 7;
|
||||
lump >> w;
|
||||
r = (w & 0x001F) << 3;
|
||||
g = (w & 0x03E0) >> 2;
|
||||
b = (w & 0x7C00) >> 7;
|
||||
a = 255;
|
||||
break;
|
||||
|
||||
|
@ -575,7 +572,7 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
switch (hdr.img_type & 7)
|
||||
{
|
||||
case 1: // paletted
|
||||
bmp->CopyPixelData(x, y, ptr, w, h, step_x, Pitch, rotate, pe, inf);
|
||||
bmp->CopyPixelData(x, y, ptr, Width, Height, step_x, Pitch, rotate, pe, inf);
|
||||
break;
|
||||
|
||||
case 2: // RGB
|
||||
|
@ -583,21 +580,21 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
{
|
||||
case 15:
|
||||
case 16:
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_RGB555, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_RGB555, inf);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_BGR, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_BGR, inf);
|
||||
break;
|
||||
|
||||
case 32:
|
||||
if ((hdr.img_desc&15)!=8) // 32 bits without a valid alpha channel
|
||||
{
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_BGR, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_BGR, inf);
|
||||
}
|
||||
else
|
||||
{
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_BGRA, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_BGRA, inf);
|
||||
transval = -1;
|
||||
}
|
||||
break;
|
||||
|
@ -612,11 +609,11 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i
|
|||
{
|
||||
case 8:
|
||||
for(int i=0;i<256;i++) pe[i]=PalEntry(255,i,i,i); // gray map
|
||||
bmp->CopyPixelData(x, y, ptr, w, h, step_x, Pitch, rotate, pe, inf);
|
||||
bmp->CopyPixelData(x, y, ptr, Width, Height, step_x, Pitch, rotate, pe, inf);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_I16, inf);
|
||||
bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_I16, inf);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -242,8 +242,8 @@ FTexture *FWarpTexture::GetRedirect(bool wantwarped)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf)
|
||||
int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
return SourcePic->CopyTrueColorPixels(bmp, x, y, w, h, rotate, inf);
|
||||
return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue