2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2008-06-07 20:16:52 +03:00
|
|
|
#include "CCreatureAnimation.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2011-12-17 21:59:59 +03:00
|
|
|
#include "../../lib/CLodHandler.h"
|
|
|
|
#include "../../lib/VCMI_Lib.h"
|
|
|
|
#include "../../lib/vcmi_endian.h"
|
2011-12-22 16:05:19 +03:00
|
|
|
#include "../UIFramework/SDL_Extensions.h"
|
2012-05-17 13:44:48 +03:00
|
|
|
#include "../UIFramework/SDL_Pixels.h"
|
2009-04-15 17:03:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CCreatureAnimation.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-02-09 15:56:30 +02:00
|
|
|
CCreatureAnim::EAnimType CCreatureAnimation::getType() const
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2011-02-09 15:56:30 +02:00
|
|
|
void CCreatureAnimation::setType(CCreatureAnim::EAnimType type)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-09-16 13:09:08 +03:00
|
|
|
assert(framesInGroup(type) > 0 && "Bad type for void CCreatureAnimation::setType(int type)!");
|
2008-06-07 20:16:52 +03:00
|
|
|
this->type = type;
|
2009-02-20 15:06:20 +02:00
|
|
|
internalFrame = 0;
|
2008-06-07 20:16:52 +03:00
|
|
|
if(type!=-1)
|
|
|
|
{
|
2009-02-20 15:06:20 +02:00
|
|
|
curFrame = frameGroups[type][0];
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-23 15:59:03 +02:00
|
|
|
if(curFrame>=frames)
|
|
|
|
{
|
2008-06-07 20:16:52 +03:00
|
|
|
curFrame = 0;
|
2008-12-23 15:59:03 +02:00
|
|
|
}
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 15:50:00 +03:00
|
|
|
CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), once(false)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2010-11-09 13:27:58 +02:00
|
|
|
FDef = spriteh->giveFile(name, FILE_ANIMATION); //load main file
|
2008-06-07 20:16:52 +03:00
|
|
|
|
|
|
|
//init anim data
|
|
|
|
int i,j, totalInBlock;
|
2010-10-31 00:53:41 +03:00
|
|
|
|
2008-06-07 20:16:52 +03:00
|
|
|
defName=name;
|
|
|
|
i = 0;
|
2011-10-08 04:23:46 +03:00
|
|
|
DEFType = read_le_u32(FDef + i); i+=4;
|
|
|
|
fullWidth = read_le_u32(FDef + i); i+=4;
|
|
|
|
fullHeight = read_le_u32(FDef + i); i+=4;
|
2008-06-07 20:16:52 +03:00
|
|
|
i=0xc;
|
2011-10-08 04:23:46 +03:00
|
|
|
totalBlocks = read_le_u32(FDef + i); i+=4;
|
2008-06-07 20:16:52 +03:00
|
|
|
|
|
|
|
i=0x10;
|
|
|
|
for (int it=0;it<256;it++)
|
|
|
|
{
|
|
|
|
palette[it].R = FDef[i++];
|
|
|
|
palette[it].G = FDef[i++];
|
|
|
|
palette[it].B = FDef[i++];
|
|
|
|
palette[it].F = 0;
|
|
|
|
}
|
|
|
|
i=0x310;
|
|
|
|
totalEntries=0;
|
|
|
|
for (int z=0; z<totalBlocks; z++)
|
|
|
|
{
|
2009-02-20 15:06:20 +02:00
|
|
|
std::vector<int> frameIDs;
|
2011-10-08 04:23:46 +03:00
|
|
|
int group = read_le_u32(FDef + i); i+=4; //block ID
|
|
|
|
totalInBlock = read_le_u32(FDef + i); i+=4;
|
2008-06-07 20:16:52 +03:00
|
|
|
for (j=SEntries.size(); j<totalEntries+totalInBlock; j++)
|
2008-08-07 03:38:44 +03:00
|
|
|
{
|
2008-06-07 20:16:52 +03:00
|
|
|
SEntries.push_back(SEntry());
|
2008-08-07 03:38:44 +03:00
|
|
|
SEntries[j].group = group;
|
2009-02-20 15:06:20 +02:00
|
|
|
frameIDs.push_back(j);
|
2008-08-07 03:38:44 +03:00
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
/*int unknown2 = read_le_u32(FDef + i);*/ i+=4; //TODO use me
|
|
|
|
/*int unknown3 = read_le_u32(FDef + i);*/ i+=4; //TODO use me
|
2011-09-24 04:15:36 +03:00
|
|
|
i+=13*totalInBlock; //omitting names
|
2008-06-07 20:16:52 +03:00
|
|
|
for (j=0; j<totalInBlock; j++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
SEntries[totalEntries+j].offset = read_le_u32(FDef + i); i+=4;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
//totalEntries+=totalInBlock;
|
|
|
|
for(int hh=0; hh<totalInBlock; ++hh)
|
|
|
|
{
|
|
|
|
++totalEntries;
|
|
|
|
}
|
2009-02-20 15:06:20 +02:00
|
|
|
frameGroups[group] = frameIDs;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//init vars
|
|
|
|
curFrame = 0;
|
2011-02-09 15:56:30 +02:00
|
|
|
type = CCreatureAnim::WHOLE_ANIM;
|
2008-06-07 20:16:52 +03:00
|
|
|
frames = totalEntries;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-02-21 17:43:28 +02:00
|
|
|
return nextFrame(dest, x-fullWidth/2, y-fullHeight/2, attacker, animCount, incrementFrame, yellowBorder, blueBorder, destRect);
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2010-02-12 17:04:01 +02:00
|
|
|
|
2008-08-07 03:38:44 +03:00
|
|
|
void CCreatureAnimation::incrementFrame()
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-03-12 20:06:02 +02:00
|
|
|
if(type!=-1) //when a specific part of animation is played
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-03-19 21:04:46 +02:00
|
|
|
++internalFrame;
|
2009-02-20 15:06:20 +02:00
|
|
|
if(internalFrame == frameGroups[type].size()) //rewind
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-03-19 21:04:46 +02:00
|
|
|
internalFrame = 0;
|
2009-03-12 20:06:02 +02:00
|
|
|
if(once) //playing animation once - return to standing animation
|
2009-02-21 17:43:28 +02:00
|
|
|
{
|
2011-02-09 15:56:30 +02:00
|
|
|
type = CCreatureAnim::HOLDING;
|
2009-02-21 17:43:28 +02:00
|
|
|
once = false;
|
|
|
|
curFrame = frameGroups[2][0];
|
|
|
|
}
|
2009-03-12 20:06:02 +02:00
|
|
|
else //
|
2009-02-21 17:43:28 +02:00
|
|
|
{
|
|
|
|
curFrame = frameGroups[type][0];
|
|
|
|
}
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2009-03-19 21:04:46 +02:00
|
|
|
curFrame = frameGroups[type][internalFrame];
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2009-03-12 20:06:02 +02:00
|
|
|
else //when whole animation is played
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-03-12 20:06:02 +02:00
|
|
|
++curFrame;
|
2008-08-07 03:38:44 +03:00
|
|
|
if(curFrame>=frames)
|
|
|
|
curFrame = 0;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2008-08-07 03:38:44 +03:00
|
|
|
}
|
2008-09-24 19:25:14 +03:00
|
|
|
|
|
|
|
int CCreatureAnimation::getFrame() const
|
|
|
|
{
|
|
|
|
return curFrame;
|
|
|
|
}
|
|
|
|
|
2011-05-26 17:47:45 +03:00
|
|
|
int CCreatureAnimation::getAnimationFrame() const
|
|
|
|
{
|
|
|
|
return internalFrame;
|
|
|
|
}
|
|
|
|
|
2009-10-13 05:01:29 +03:00
|
|
|
bool CCreatureAnimation::onFirstFrameInGroup()
|
|
|
|
{
|
|
|
|
return internalFrame == 0;
|
|
|
|
}
|
|
|
|
|
2009-03-05 19:57:26 +02:00
|
|
|
bool CCreatureAnimation::onLastFrameInGroup()
|
|
|
|
{
|
|
|
|
if(internalFrame == frameGroups[type].size() - 1)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-09 15:56:30 +02:00
|
|
|
void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
|
2009-02-21 17:43:28 +02:00
|
|
|
{
|
|
|
|
setType(type);
|
|
|
|
once = true;
|
|
|
|
}
|
|
|
|
|
2008-08-07 03:38:44 +03:00
|
|
|
|
2010-08-12 08:22:48 +03:00
|
|
|
template<int bpp>
|
2011-12-14 00:23:17 +03:00
|
|
|
int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
|
2010-08-12 08:22:48 +03:00
|
|
|
{
|
2011-05-11 19:08:37 +03:00
|
|
|
//increasing frame number
|
2008-08-07 03:38:44 +03:00
|
|
|
int SIndex = curFrame;
|
2011-05-11 19:08:37 +03:00
|
|
|
if (IncrementFrame)
|
2008-08-07 03:38:44 +03:00
|
|
|
incrementFrame();
|
2008-06-07 20:16:52 +03:00
|
|
|
|
2011-10-13 07:33:19 +03:00
|
|
|
#if 0
|
|
|
|
long SpriteWidth, SpriteHeight, //sprite format
|
2008-06-07 20:16:52 +03:00
|
|
|
LeftMargin, RightMargin, TopMargin,BottomMargin,
|
2011-10-13 07:33:19 +03:00
|
|
|
i, FullHeight,
|
|
|
|
|
|
|
|
#endif
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 SegmentType, SegmentLength;
|
|
|
|
ui32 i;
|
2010-08-12 08:22:48 +03:00
|
|
|
|
2011-10-13 07:33:19 +03:00
|
|
|
i = SEntries[SIndex].offset;
|
2011-10-08 04:23:46 +03:00
|
|
|
|
|
|
|
/*int prSize = read_le_u32(FDef + i);*/ i += 4; //TODO use me
|
2011-12-14 00:23:17 +03:00
|
|
|
const ui32 defType2 = read_le_u32(FDef + i); i += 4;
|
|
|
|
const ui32 FullWidth = read_le_u32(FDef + i); i += 4;
|
|
|
|
const ui32 FullHeight = read_le_u32(FDef + i); i += 4;
|
|
|
|
const ui32 SpriteWidth = read_le_u32(FDef + i); i += 4;
|
|
|
|
const ui32 SpriteHeight = read_le_u32(FDef + i); i += 4;
|
2011-10-13 07:33:19 +03:00
|
|
|
const int LeftMargin = read_le_u32(FDef + i); i += 4;
|
|
|
|
const int TopMargin = read_le_u32(FDef + i); i += 4;
|
|
|
|
const int RightMargin = FullWidth - SpriteWidth - LeftMargin;
|
|
|
|
const int BottomMargin = FullHeight - SpriteHeight - TopMargin;
|
2008-06-07 20:16:52 +03:00
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
if (defType2 == 1) //as it should be always in creature animations
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-10-13 07:33:19 +03:00
|
|
|
const int BaseOffsetor = i;
|
|
|
|
int ftcp = 0;
|
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
if (TopMargin > 0)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-05-11 19:08:37 +03:00
|
|
|
ftcp += FullWidth * TopMargin;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2011-10-13 07:33:19 +03:00
|
|
|
ui32 *RLEntries = (ui32 *)(FDef + BaseOffsetor);
|
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
for (int i = 0; i < SpriteHeight; i++)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-10-13 07:33:19 +03:00
|
|
|
int BaseOffset = BaseOffsetor + read_le_u32(RLEntries + i);
|
|
|
|
int TotalRowLength; // length of read segment
|
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
if (LeftMargin > 0)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-05-11 19:08:37 +03:00
|
|
|
ftcp += LeftMargin;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2011-05-11 19:08:37 +03:00
|
|
|
|
|
|
|
TotalRowLength = 0;
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
// Note: Bug fixed (Rev 2115): The implementation of omitting lines was false.
|
|
|
|
// We've to calculate several things so not showing/putting pixels should suffice.
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
int yB = ftcp / FullWidth + y;
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2008-06-07 20:16:52 +03:00
|
|
|
do
|
|
|
|
{
|
2011-05-11 19:08:37 +03:00
|
|
|
SegmentType = FDef[BaseOffset++];
|
|
|
|
SegmentLength = FDef[BaseOffset++];
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2011-10-13 07:33:19 +03:00
|
|
|
const int remainder = ftcp % FullWidth;
|
|
|
|
int xB = (attacker ? remainder : FullWidth - remainder - 1) + x;
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
const ui8 aCountMod = (animCount & 0x20) ? ((animCount & 0x1e) >> 1) << 4 : (0x0f - ((animCount & 0x1e) >> 1)) << 4;
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2011-05-11 19:08:37 +03:00
|
|
|
for (int k = 0; k <= SegmentLength; k++)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-05-11 19:08:37 +03:00
|
|
|
if(xB >= 0 && xB < dest->w && yB >= 0 && yB < dest->h)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-06-27 20:11:17 +03:00
|
|
|
if(!destRect || (destRect->x <= xB && destRect->x + destRect->w > xB && destRect->y <= yB && destRect->y + destRect->h > yB))
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2010-08-12 08:22:48 +03:00
|
|
|
const ui8 colorNr = SegmentType == 0xff ? FDef[BaseOffset+k] : SegmentType;
|
2011-02-06 19:26:27 +02:00
|
|
|
putPixel<bpp>(dest, xB, yB, palette[colorNr], colorNr, yellowBorder, blueBorder, aCountMod);
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
2010-04-04 11:47:00 +03:00
|
|
|
ftcp++; //increment pos
|
|
|
|
if(attacker)
|
|
|
|
xB++;
|
|
|
|
else
|
|
|
|
xB--;
|
|
|
|
if ( SegmentType == 0xFF && TotalRowLength+k+1 >= SpriteWidth )
|
|
|
|
break;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2010-04-04 11:47:00 +03:00
|
|
|
if (SegmentType == 0xFF)
|
|
|
|
{
|
|
|
|
BaseOffset += SegmentLength+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
TotalRowLength+=SegmentLength+1;
|
2011-05-11 19:08:37 +03:00
|
|
|
} while(TotalRowLength < SpriteWidth);
|
|
|
|
if (RightMargin > 0)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2011-05-11 19:08:37 +03:00
|
|
|
ftcp += RightMargin;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
2011-05-11 19:08:37 +03:00
|
|
|
if (BottomMargin > 0)
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2008-09-26 17:16:01 +03:00
|
|
|
ftcp += BottomMargin * FullWidth;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect)
|
2010-08-12 08:22:48 +03:00
|
|
|
{
|
|
|
|
switch(dest->format->BytesPerPixel)
|
|
|
|
{
|
|
|
|
case 2: return nextFrameT<2>(dest, x, y, attacker, animCount, IncrementFrame, yellowBorder, blueBorder, destRect);
|
|
|
|
case 3: return nextFrameT<3>(dest, x, y, attacker, animCount, IncrementFrame, yellowBorder, blueBorder, destRect);
|
|
|
|
case 4: return nextFrameT<4>(dest, x, y, attacker, animCount, IncrementFrame, yellowBorder, blueBorder, destRect);
|
|
|
|
default:
|
|
|
|
tlog1 << (int)dest->format->BitsPerPixel << " bpp is not supported!!!\n";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-09 15:56:30 +02:00
|
|
|
int CCreatureAnimation::framesInGroup(CCreatureAnim::EAnimType group) const
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-02-20 15:06:20 +02:00
|
|
|
if(frameGroups.find(group) == frameGroups.end())
|
|
|
|
return 0;
|
|
|
|
return frameGroups.find(group)->second.size();
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CCreatureAnimation::~CCreatureAnimation()
|
|
|
|
{
|
|
|
|
delete [] FDef;
|
|
|
|
}
|
|
|
|
|
2010-08-12 08:22:48 +03:00
|
|
|
template<int bpp>
|
2008-12-21 21:17:35 +02:00
|
|
|
inline void CCreatureAnimation::putPixel(
|
2009-08-01 15:54:05 +03:00
|
|
|
SDL_Surface * dest,
|
2011-02-06 19:26:27 +02:00
|
|
|
const int & ftcpX,
|
|
|
|
const int & ftcpY,
|
2009-08-01 15:54:05 +03:00
|
|
|
const BMPPalette & color,
|
2011-12-14 00:23:17 +03:00
|
|
|
const ui8 & palc,
|
2009-08-01 15:54:05 +03:00
|
|
|
const bool & yellowBorder,
|
|
|
|
const bool & blueBorder,
|
2011-12-14 00:23:17 +03:00
|
|
|
const ui8 & animCount
|
2009-02-20 15:06:20 +02:00
|
|
|
) const
|
|
|
|
{
|
2011-01-01 22:26:39 +02:00
|
|
|
if(palc!=0)
|
2008-12-23 15:59:03 +02:00
|
|
|
{
|
2011-02-06 19:26:27 +02:00
|
|
|
Uint8 * p = (Uint8*)dest->pixels + ftcpX*dest->format->BytesPerPixel + ftcpY*dest->pitch;
|
2008-06-07 20:16:52 +03:00
|
|
|
if(palc > 7) //normal color
|
|
|
|
{
|
2010-08-12 08:22:48 +03:00
|
|
|
ColorPutter<bpp, 0>::PutColor(p, color.R, color.G, color.B);
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2011-01-01 22:26:39 +02:00
|
|
|
else if((yellowBorder || blueBorder) && (palc == 6 || palc == 7)) //selection highlight
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-02-21 17:43:28 +02:00
|
|
|
if(blueBorder)
|
2010-08-12 08:22:48 +03:00
|
|
|
ColorPutter<bpp, 0>::PutColor(p, 0, 0x0f + animCount, 0x0f + animCount);
|
2009-02-21 17:43:28 +02:00
|
|
|
else
|
2010-08-12 08:22:48 +03:00
|
|
|
ColorPutter<bpp, 0>::PutColor(p, 0x0f + animCount, 0x0f + animCount, 0);
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2011-01-01 22:26:39 +02:00
|
|
|
else if (palc == 5) //selection highlight or transparent
|
2008-06-07 20:16:52 +03:00
|
|
|
{
|
2009-02-21 17:43:28 +02:00
|
|
|
if(blueBorder)
|
2011-09-24 04:15:36 +03:00
|
|
|
ColorPutter<bpp, 0>::PutColor(p, color.B, color.G - 0xf0 + animCount, color.R - 0xf0 + animCount); //shouldn't it be reversed? its bgr instead of rgb
|
2011-01-01 22:26:39 +02:00
|
|
|
else if (yellowBorder)
|
2010-08-12 08:22:48 +03:00
|
|
|
ColorPutter<bpp, 0>::PutColor(p, color.R - 0xf0 + animCount, color.G - 0xf0 + animCount, color.B);
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
2011-01-01 22:26:39 +02:00
|
|
|
else //shadow
|
|
|
|
{
|
|
|
|
//determining transparency value, 255 or 0 should be already filtered
|
|
|
|
static Uint16 colToAlpha[8] = {255,192,128,128,128,255,128,192};
|
2011-02-06 19:26:27 +02:00
|
|
|
Uint16 alpha = colToAlpha[palc];
|
2010-08-12 08:22:48 +03:00
|
|
|
|
|
|
|
if(bpp != 3 && bpp != 4)
|
|
|
|
{
|
|
|
|
ColorPutter<bpp, 0>::PutColor(p, 0, 0, 0, alpha);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p[0] = (p[0] * alpha)>>8;
|
|
|
|
p[1] = (p[1] * alpha)>>8;
|
|
|
|
p[2] = (p[2] * alpha)>>8;
|
|
|
|
}
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|