28 #ifndef YCL_INC_Video_h_
29 #define YCL_INC_Video_h_ 1
32 #include YFM_YCLib_YCommon
39 using SDst = std::uint16_t;
46 template<
size_t _vX,
size_t _vY,
size_t _vZ,
size_t _vA>
86 template<
size_t _vB,
size_t _vG,
size_t _vR,
size_t _vA>
92 static_assert(Trait::BitsN <= 64,
93 "Width larger than 64 bits is unimplemented");
95 typename Trait::ArrayType
Bytes;
104 BGRA(typename Trait::IntegerType i)
108 BGRA(
typename Trait::BType b,
typename Trait::GType
g,
109 typename Trait::RType
r,
typename Trait::AType a)
110 :
Integer(b | g << Trait::XBitsN | r << Trait::XYBitsN
111 | a << Trait::XYZBitsN)
119 (
Integer & Trait::AMask) >> Trait::XYZBitsN)
124 (
Integer & Trait::YMask) >> Trait::XBitsN)
127 (
Integer & Trait::ZMask) >> Trait::XYBitsN)
139 template<
size_t _vR,
size_t _vG,
size_t _vB,
size_t _vA>
145 static_assert(Trait::BitsN <= 64,
"Width larger than 64 unimplemented");
147 typename Trait::ArrayType
Bytes;
148 typename Trait::IntegerType
Integer;
156 RGBA(typename Trait::IntegerType i)
160 RGBA(
typename Trait::BType
r,
typename Trait::GType
g,
161 typename Trait::RType b,
typename Trait::AType a)
162 : Integer(r | g << Trait::XBitsN | b << Trait::XYBitsN
163 | a << Trait::XYZBitsN)
167 yconstfn DefCvt(
const ynothrow,
typename Trait::IntegerType, Integer)
171 (Integer & Trait::AMask) >> Trait::XYZBitsN)
173 (Integer & Trait::ZMask) >> Trait::XYBitsN)
176 (Integer & Trait::YMask) >> Trait::XBitsN)
179 Integer & Trait::XMask)
195 # define YCL_PIXEL_FORMAT_XYZ555 0xAABBCCDD
202 using PixelType = RGBA<5, 5, 5, 1>;
209 ImplRet(px.GetA() != 0 ? 0xFF : 0)
216 yconstfn PDefH(PixelType, FetchOpaque, PixelType px) ynothrow
225 ImplRet(r >> 3 | std::uint16_t(g >> 3) << 5 | std::uint16_t(b >> 3) << 10)
227 # define DefColorH_(hex, name) name = \
228 (FetchPixel(((hex) >> 16) & 0xFF, ((hex) >> 8) & 0xFF, (hex) & 0xFF) \
230 #elif YCL_Win32 || YCL_Android
236 # define YCL_PIXEL_FORMAT_XYZ888 0xAADDCCBB
248 using PixelType = BGRA<8, 8, 8, 8>;
262 yconstfn PDefH(PixelType, FetchOpaque, PixelType px) ynothrow
263 ImplRet({px.GetB(), px.GetG(), px.GetR(), 0xFF})
272 ImplRet(r | g << 8 | std::uint32_t(b) << 16)
274 # if YB_HAS_CONSTEXPR
276 # define YCL_FetchPixel(r, g, b) platform::FetchPixel(r, g, b)
278 # define YCL_FetchPixel(r, g, b) ((r) | (g) << 8 | std::uint32_t(b) << 16)
288 # define DefColorH_(hex, name) \
289 name = (YCL_FetchPixel((((hex) >> 16) & 0xFF), \
290 (((hex) >> 8) & 0xFF), ((hex) & 0xFF)) << 8 | 0xFF)
292 # error "Unsupported platform found."
303 #define HexAdd0x(hex) 0x##hex
304 #define DefColorH(hex_, name) DefColorH_(HexAdd0x(hex_), name)
331 #undef YCL_FetchPixel
363 : r(0), g(0), b(0), a(0)
372 :
r(px.GetR() << 3),
g(px.GetG() << 3), b(px.GetB() << 3),
373 a(FetchAlpha(px) ? 0xFF : 0x00)
374 #elif YCL_Win32 || YCL_Android
375 :
r(px.GetR()),
g(px.GetG()), b(px.GetB()), a(px.GetA())
385 :
Color(PixelType(cs))
386 #elif YCL_Win32 || YCL_Android
387 :
r((cs & 0xFF00) >> 8),
g((cs & 0xFF0000) >> 16),
388 b((cs & 0xFF000000) >> 24), a(0xFF)
397 : r(r_), g(g_), b(b_), a(a_)
404 template<
typename _tScalar>
415 operator PixelType() const ynothrow
418 return int(a != 0) << 15 | FetchPixel(r, g, b);
419 #elif YCL_Win32 || YCL_Android
511 namespace platform_ex
540 ScreenSynchronize(platform::PixelType*,
const platform::PixelType*) ynothrow;
543 #if YCL_DS || YF_Hosted
553 bool LCD_main_on_top =
true;
558 IsLCDMainOnTop()
const;
561 SetLCDMainOnTop(
bool);
#define DefColorH(hex_, name)
ystdex::byte[BytesN] ArrayType
static yconstexpr size_t BitsN
YF_API bool InitVideo()
初始化视频输出。
static yconstexpr size_t BytesN
yconstfn Color(ColorSet cs) ynothrow
构造:使用默认颜色。
typename ystdex::make_width_int< ZBitsN >::unsigned_least_type RType
yconstfn Color() ynothrow
无参数构造:所有分量为 0 的默认颜色。
static yconstexpr size_t ZBitsN
std::uint16_t SDst
屏幕坐标距离。
union _vA::IntegerType RGBA
static yconstexpr bool RAligned
yconstfn Integer &Trait::AMask Trait::XYZBitsN yconstfn DefGetter(const ynothrow, typename Trait::BType, B, Integer &Trait::XMask) yconstfn DefGetter(const ynothrow
yconstfn DefCvt(const ynothrow, typename Trait::IntegerType, Integer) yconstfn DefGetter(const ynothrow
yconstexpr platform::Color ConsoleColors[]
控制台颜色。
std::size_t size ynothrow
union _vA::IntegerType BGRA
static yconstexpr size_t ABitsN
typename ystdex::make_width_int< YBitsN >::unsigned_least_type GType
typename ystdex::make_width_int< ABitsN >::unsigned_least_type AType
static yconstexpr size_t UIntBitsN
Trait::IntegerType Integer
#define yalignof(_type)
指定特定类型的对齐。
YF_API void YConsoleInit(std::uint8_t dspIndex, Color fc=ColorSpace::White, Color bc=ColorSpace::Black)
启动控制台。
yconstexpr const KeyInput KeyIndex ynothrow ImplRet(char()) namespace KeyCodes
本机按键编码。
#define yconstfn
指定编译时常量函数。
yconstfn Color(_tScalar r_, _tScalar g_, _tScalar b_, AlphaType a_=0xFF) ynothrow
构造:使用相同类型转换为单色的 RGB 值和 alpha位。
typename make_width_int<(_vWidth<=8U?8U:(_vWidth<=16U?16U:(_vWidth<=32U?32U:64U)))>::unsigned_least_type unsigned_least_type
union YB_ATTR(packed) YB_ATTR(aligned(yalignof(typename XYZATrait< _vB
BGRA 四元组。
static yconstexpr size_t YBitsN
yconstfn Color(MonoType r_, MonoType g_, MonoType b_, AlphaType a_=0xFF) ynothrow
构造:使用 RGB 值和 alpha 位。
#define yconstexpr
指定编译时常量表达式。
static yconstexpr size_t XBitsN
yconstfn Integer &Trait::AMask Trait::XYZBitsN yconstfn G
DefDeCtor(BGRA) yconstfn BGRA(typename Trait
static yconstexpr IntegerType XMask
static yconstexpr IntegerType ZMask
const PixelType * ConstBitmapPtr
static yconstexpr bool GAligned
typename ystdex::make_width_int< UIntBitsN >::unsigned_least_type IntegerType
static yconstexpr size_t XYZBitsN
yconstfn Color(PixelType px) ynothrow
构造:使用本机颜色对象。
typename ystdex::make_width_int< XBitsN >::unsigned_least_type BType
static yconstexpr IntegerType AMask
static yconstexpr IntegerType YMask
PDefH(bool, ufexists, const _tString &str) ynothrow ImplRet(ufexists(str.c_str())) YF_API char16_t *u16getcwd_n(char16_t *buf
判断指定字符串为文件名的文件是否存在。
static yconstexpr size_t XYBitsN
static yconstexpr size_t Width