| 199 | } |
| 200 | |
| 201 | void PutPixel(COLORREF *pBuffer, int Width, int Height, float x, float y, COLORREF col) |
| 202 | { |
| 203 | if (x < 0.0f) |
| 204 | x = 0.0f; |
| 205 | if (x > float(Width - 1)) |
| 206 | x = float(Width - 1); |
| 207 | if (y < 0.0f) |
| 208 | y = 0.0f; |
| 209 | if (y > float(Height - 1)) |
| 210 | y = float(Height - 1); |
| 211 | |
| 212 | int x0 = int(x); |
| 213 | int x1 = x0 + 1; |
| 214 | int y0 = int(y); |
| 215 | int y1 = y0 + 1; |
| 216 | |
| 217 | float w_x1 = x - x0; |
| 218 | float w_x0 = 1 - w_x1; |
| 219 | float w_y1 = y - y0; |
| 220 | float w_y0 = 1 - w_y1; |
| 221 | |
| 222 | COLORREF c1 = BLEND(col, pBuffer[y0 * Width + x0], w_x0 * w_y0); |
| 223 | COLORREF c2 = BLEND(col, pBuffer[y0 * Width + x1], w_x1 * w_y0); |
| 224 | COLORREF c3 = BLEND(col, pBuffer[y1 * Width + x0], w_x0 * w_y1); |
| 225 | COLORREF c4 = BLEND(col, pBuffer[y1 * Width + x1], w_x1 * w_y1); |
| 226 | |
| 227 | pBuffer[y0 * Width + x0] = c1; |
| 228 | if (x1 < Width) |
| 229 | pBuffer[y0 * Width + x1] = c2; |
| 230 | if (y1 < Height) |
| 231 | pBuffer[y1 * Width + x0] = c3; |
| 232 | if (x1 < Width && y1 < Height) |
| 233 | pBuffer[y1 * Width + x1] = c4; |
| 234 | } |