| 155 | } |
| 156 | |
| 157 | void BlurBuffer(COLORREF *pBuffer, int Width, int Height, const int *pColorDecay) |
| 158 | { |
| 159 | for (int x = 1; x < Width - 1; ++x) { |
| 160 | for (int y = 1; y < Height - 1; ++y) { |
| 161 | |
| 162 | COLORREF Col1 = pBuffer[(y + 1) * Width + (x + 0)]; |
| 163 | COLORREF Col2 = pBuffer[(y - 1) * Width + (x + 0)]; |
| 164 | COLORREF Col3 = pBuffer[(y + 0) * Width + (x + 1)]; |
| 165 | COLORREF Col4 = pBuffer[(y + 0) * Width + (x - 1)]; |
| 166 | COLORREF Col5 = pBuffer[(y - 1) * Width + (x + 1)]; |
| 167 | COLORREF Col6 = pBuffer[(y - 1) * Width + (x - 1)]; |
| 168 | COLORREF Col7 = pBuffer[(y + 1) * Width + (x + 1)]; |
| 169 | COLORREF Col8 = pBuffer[(y + 1) * Width + (x - 1)]; |
| 170 | |
| 171 | int r = (GetR(Col1) + GetR(Col2) + GetR(Col3) + GetR(Col4) + GetR(Col5) + GetR(Col6) + GetR(Col7) + GetR(Col8)) >> 3; |
| 172 | int g = (GetG(Col1) + GetG(Col2) + GetG(Col3) + GetG(Col4) + GetG(Col5) + GetG(Col6) + GetG(Col7) + GetG(Col8)) >> 3; |
| 173 | int b = (GetB(Col1) + GetB(Col2) + GetB(Col3) + GetB(Col4) + GetB(Col5) + GetB(Col6) + GetB(Col7) + GetB(Col8)) >> 3; |
| 174 | |
| 175 | r -= pColorDecay[0]; |
| 176 | g -= pColorDecay[1]; |
| 177 | b -= pColorDecay[2]; |
| 178 | |
| 179 | if (r < 0) r = 0; |
| 180 | if (g < 0) g = 0; |
| 181 | if (b < 0) b = 0; |
| 182 | if (r > 255) r = 255; |
| 183 | if (g > 255) g = 255; |
| 184 | if (b > 255) b = 255; |
| 185 | |
| 186 | pBuffer[y * Width + x] = MakeRGB(r, g, b); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | for (int x = 0; x < Width; ++x) { |
| 191 | pBuffer[x] = 0; |
| 192 | pBuffer[x + (Height - 1) * Width] = 0; |
| 193 | } |
| 194 | |
| 195 | for (int y = 0; y < Height; ++y) { |
| 196 | pBuffer[y * Width] = 0; |
| 197 | pBuffer[y * Width + (Width - 1)] = 0; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void PutPixel(COLORREF *pBuffer, int Width, int Height, float x, float y, COLORREF col) |
| 202 | { |
no test coverage detected