sizes remain as were assumed input image is large enough?
| 199 | |
| 200 | //sizes remain as were assumed input image is large enough? |
| 201 | void XImage::CopyScaled(const XImage& Image, float scale) |
| 202 | { |
| 203 | int SrcWidth = (int)Image.GetWidth(); //because Source[] requires int argument, why not long long int? |
| 204 | |
| 205 | int Pixel = sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL); |
| 206 | int Row = SrcWidth * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL); |
| 207 | int W = (int)GetWidth(); |
| 208 | int H = (int)GetHeight(); |
| 209 | |
| 210 | const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& Source = Image.GetData(); |
| 211 | |
| 212 | for (INTN y = 0; y < H; y++) //destination coordinates |
| 213 | { |
| 214 | int ly = (int)(y / scale); //integer part of src coord |
| 215 | float dy = y - ly * scale; //fractional part |
| 216 | for (INTN x = 0; x < W; x++) |
| 217 | { |
| 218 | int lx = (int)(x / scale); |
| 219 | float dx = x - lx * scale; |
| 220 | int a01 = (lx == 0) ? 0 : -Pixel; |
| 221 | int a10 = (ly == 0) ? 0 : -Row; |
| 222 | int a21 = (lx == W - 1) ? 0 : Pixel; |
| 223 | int a12 = (ly == H - 1) ? 0 : Row; |
| 224 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL& dst = *GetPixelPtr(x, y); |
| 225 | dst.Blue = Smooth(&Source[lx + ly * SrcWidth].Blue, a01, a10, a21, a12, dx, dy, scale); |
| 226 | dst.Green = Smooth(&Source[lx + ly * SrcWidth].Green, a01, a10, a21, a12, dx, dy, scale); |
| 227 | dst.Red = Smooth(&Source[lx + ly * SrcWidth].Red, a01, a10, a21, a12, dx, dy, scale); |
| 228 | dst.Reserved = Source[lx + ly * SrcWidth].Reserved; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /* Place Top image over this image at PosX,PosY |
| 234 | * Lowest means final image is opaque |
no test coverage detected