本文整理汇总了C++中Pixel::A方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixel::A方法的具体用法?C++ Pixel::A怎么用?C++ Pixel::A使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixel
的用法示例。
在下文中一共展示了Pixel::A方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debugModulation
static void Decompress4BPP(const Image &imgA, const Image &imgB,
const std::vector<Block> &blocks,
uint8 *const outBuf,
bool bDebugImages = false) {
const uint32 w = imgA.GetWidth();
const uint32 h = imgA.GetHeight();
assert(imgA.GetWidth() == imgB.GetWidth());
assert(imgA.GetHeight() == imgB.GetHeight());
Image debugModulation(w, h);
const uint8 debugModulationBitDepth[4] = { 8, 4, 4, 4 };
debugModulation.ChangeBitDepth(debugModulationBitDepth);
for(uint32 j = 0; j < h; j++) {
for(uint32 i = 0; i < w; i++) {
const uint32 blockWidth = 4;
const uint32 blockHeight = 4;
const uint32 blockIdx =
(j/blockHeight) * (w/blockWidth) + (i/blockWidth);
const Block &b = blocks[blockIdx];
const uint32 texelIndex =
(j % blockHeight) * blockWidth + (i % blockWidth);
const Pixel &pa = imgA(i, j);
const Pixel &pb = imgB(i, j);
bool punchThrough = false;
uint8 lerpVal = 0;
if(b.GetModeBit()) {
const uint8 lerpVals[3] = { 8, 4, 0 };
uint8 modVal = b.GetLerpValue(texelIndex);
if(modVal >= 2) {
if(modVal == 2) {
punchThrough = true;
}
modVal -= 1;
}
lerpVal = lerpVals[modVal];
} else {
const uint8 lerpVals[4] = { 8, 5, 3, 0 };
lerpVal = lerpVals[b.GetLerpValue(texelIndex)];
}
if(bDebugImages) {
Pixel &modPx = debugModulation(i, j);
modPx.A() = 0xFF;
for(uint32 c = 1; c < 4; c++) {
float fv = (static_cast<float>(lerpVal) / 8.0f) * 15.0f;
modPx.Component(c) = static_cast<uint8>(fv);
}
// Make punch through pixels red.
if(punchThrough) {
modPx.G() = modPx.B() = 0;
}
}
Pixel result = (pa * (8 - lerpVal) + pb * lerpVal) / 8;
if(punchThrough) {
result.A() = 0;
}
uint32 *outPixels = reinterpret_cast<uint32 *>(outBuf);
outPixels[(j * w) + i] = result.Pack();
}
}
if(bDebugImages) {
debugModulation.DebugOutput("Modulation");
}
}
示例2: PrintPixel
static void PrintPixel(const char *label, const Pixel &p) {
fprintf(stderr, "%s: <%d, %d, %d, %d>\n", label, p.R(), p.G(), p.B(), p.A());
}