本文整理汇总了C++中Pixel::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixel::get方法的具体用法?C++ Pixel::get怎么用?C++ Pixel::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixel
的用法示例。
在下文中一共展示了Pixel::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shadeRect
void Surface::shadeRect(uint16 left, uint16 top, uint16 right, uint16 bottom,
uint32 color, uint8 strength) {
if (_bpp == 1) {
// We can't properly shade in paletted mode, fill the rect instead
fillRect(left, top, right, bottom, color);
return;
}
// Just in case those are swapped
if (left > right)
SWAP(left, right);
if (top > bottom)
SWAP(top, bottom);
if ((left >= _width) || (top >= _height))
// Nothing to do
return;
// Area to actually shade
uint16 width = CLIP<int32>(right - left + 1, 0, _width - left);
uint16 height = CLIP<int32>(bottom - top + 1, 0, _height - top);
if ((width == 0) || (height == 0))
// Nothing to do
return;
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
uint8 cR, cG, cB;
pixelFormat.colorToRGB(color, cR, cG, cB);
int shadeR = cR * (16 - strength);
int shadeG = cG * (16 - strength);
int shadeB = cB * (16 - strength);
Pixel p = get(left, top);
while (height-- > 0) {
for (uint16 i = 0; i < width; i++, ++p) {
uint8 r, g, b;
pixelFormat.colorToRGB(p.get(), r, g, b);
r = CLIP<int>((shadeR + strength * r) >> 4, 0, 255);
g = CLIP<int>((shadeG + strength * g) >> 4, 0, 255);
b = CLIP<int>((shadeB + strength * b) >> 4, 0, 255);
p.set(pixelFormat.RGBToColor(r, g, b));
}
p += _width - width;
}
}
示例2: recolor
void Surface::recolor(uint8 from, uint8 to) {
for (Pixel p = get(); p.isValid(); ++p)
if (p.get() == from)
p.set(to);
}