📄 mgcsoftcolor.cpp
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement. The various license agreements may be found at
// the Magic Software web site. This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf
#include "MgcSoftASM.h"
#include "MgcSoftColor.h"
const MgcSoftColor MgcSoftColor::WHITE(0x7FFF);
const MgcSoftColor MgcSoftColor::BLACK(0x0000);
const MgcReal MgcSoftColor::SCALE = 255.0;
MgcReal MgcSoftColor::ms_fInverse31 = 1.0/31.0;
//----------------------------------------------------------------------------
MgcSoftColor::MgcSoftColor (MgcReal fR, MgcReal fG, MgcReal fB)
{
int iR = MgcSoftASM::FloatToInt(31.0*fR);
int iG = MgcSoftASM::FloatToInt(31.0*fG);
int iB = MgcSoftASM::FloatToInt(31.0*fB);
m_usColor = (iB | (iG << 5) | (iR << 10));
}
//----------------------------------------------------------------------------
MgcSoftColor::MgcSoftColor (const MgcColor& rkColor)
{
int iR = MgcSoftASM::FloatToInt(31.0*rkColor.r);
int iG = MgcSoftASM::FloatToInt(31.0*rkColor.g);
int iB = MgcSoftASM::FloatToInt(31.0*rkColor.b);
m_usColor = (iB | (iG << 5) | (iR << 10));
}
//----------------------------------------------------------------------------
MgcSoftColor::operator MgcColor ()
{
int iR = (m_usColor & 0x7C00) >> 10;
int iG = (m_usColor & 0x03E0) >> 5;
int iB = (m_usColor & 0x001F);
MgcReal fR = ms_fInverse31*MgcReal(iR);
MgcReal fG = ms_fInverse31*MgcReal(iG);
MgcReal fB = ms_fInverse31*MgcReal(iB);
return MgcColor(fR,fG,fB);
}
//---------------------------------------------------------------------------
MgcSoftColor& MgcSoftColor::operator= (const MgcColor& rkColor)
{
int iR = MgcSoftASM::FloatToInt(31.0*rkColor.r);
int iG = MgcSoftASM::FloatToInt(31.0*rkColor.g);
int iB = MgcSoftASM::FloatToInt(31.0*rkColor.b);
m_usColor = (iB | (iG << 5) | (iR << 10));
return *this;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -