📄 cspety.cpp
字号:
#include <ddraw.h>
#include "CSpety.h"
#include "CDraw.h"
#include "CAlpha.h"
void CSpety::Grays(LPDIRECTDRAWSURFACE7 SS)
{
//灰度算法
//算法思想来自:http://www.goufun.com/gpgame/docs/program/rgb2gray_2.htm
//R = G = B = 0.3R + 0.6G + 0.1B; //第二版改正后的公式
BeginDraw(SS); //Sour锁屏
WORD *pSour=GraphBuffer;
int Pitch=GraphPitch;
int Width=GraphWidth;//宽度
int Height=GraphHeight; //高度
int sy,r,g,b;
WORD Color;
for (int y=0;y<Height;y++)
{
sy=y*Pitch;
for(int x=0;x<Width;x++)
{
if (Is555==true)
{
r=pSour[sy+x]>>10;
g=(pSour[sy+x]&GMask5)>>5;
}
else
{
r=pSour[sy+x]>>11;
g=(pSour[sy+x]&GMask6)>>6;
}
b=pSour[sy+x]&BMask;
Color=(3*r+6*g+b)>>1;
//24
pSour[sy+x]=RGB16(Color,Color,Color);
}
}
EndDraw(SS);
}
void CSpety::Dusks(LPDIRECTDRAWSURFACE7 SS)
{
BeginDraw(SS); //Sour锁屏
WORD *pSour=GraphBuffer;
int Pitch=GraphPitch;
int Width=GraphWidth;//宽度
int Height=GraphHeight; //高度
int sy,r,g,b;
for (int y=0;y<Height;y++)
{
sy=y*Pitch;
for(int x=0;x<Width;x++)
{
if (Is555==true)
{
r=pSour[sy+x]>>10;
g=(pSour[sy+x]&GMask5)>>5;
}
else
{
r=pSour[sy+x]>>11;
g=(pSour[sy+x]&GMask6)>>6;
}
b=pSour[sy+x]&BMask;
//24
pSour[sy+x]=RGB16(7*r,4*g,7*b);
}
}
EndDraw(SS);
}
void CSpety::Glares(LPDIRECTDRAWSURFACE7 SS)
{
BeginDraw(SS); //Sour锁屏
WORD *pSour=GraphBuffer;
int Pitch=GraphPitch;
int Width=GraphWidth;//宽度
int Height=GraphHeight; //高度
EndDraw(SS);
CreateSurface(AlphaDDS,NULL,Width,Height);
Clrscr(AlphaDDS,RGB16(255,255,255));
AlphaS(SS,AlphaDDS,Glare_Value,NULL);
if (AlphaDDS!=NULL)
{
AlphaDDS->Release();
AlphaDDS=NULL;
}
}
void CSpety::Show(LPDIRECTDRAWSURFACE7 SS)
{
if (Gray==true) Grays(SS);
else if (Dusk==true) Dusks(SS);
else if (Glare==true) Glares(SS);
}
void CSpety::SetSpety(int ID,bool FT) //设定一个特效
{
if (ID==0) Gray=FT;
else if(ID==1) Glare=FT;
else if(ID==2) Dusk=FT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -