Hi, I'm trying to implement a scaling algorithm which works by inserting an extra blended pixel between each pixel and 80% brightness 'scan-lines' between each horizontal line:
I have two issues here. First, it is extremely slow! Is there any faster alternative reading/writing to E2DSurface than using Get/PutPixel? Or any other obvious way to optimize this code? Second, SetRect() doesn't allow me to set a 1 row tall Rect. Is there any other way I can grab a single row from my source image to blit to my destination buffer?
- Code:
// E2DSurface dest is twice as big as E2DSurface src
for (unsigned char y = 0; y < src.GetHeight(); y++) {
// Row 1: Alternate between source pixel and blended pixel
for (unsigned char x = 0; x < src.GetWidth(); x++) {
dest.PutPixel(x*2, y*2, src.GetPixel(x, y));
COLORREF temp1 = src.GetPixel(x, y);
COLORREF temp2 = src.GetPixel(x+1, y);
dest.PutPixel(x*2+1, y*2, E_RGBX((E_GETR(temp1)+E_GETR(temp2))/2, (E_GETG(temp1)+E_GETG(temp2))/2, (E_GETB(temp1)+E_GETB(temp2))/2);
}
// Row 2: blit line y scaled 2x at 80% brightness
RECT rc;
SetRect(&rc, 0, y, src.GetWidth(), y);
Blt(dest.GetWidth()/2, (y*2)+1, src, &rc, 0, 131072, EFLIP_NONE, EFX_OPACITY, 200);
}
I have two issues here. First, it is extremely slow! Is there any faster alternative reading/writing to E2DSurface than using Get/PutPixel? Or any other obvious way to optimize this code? Second, SetRect() doesn't allow me to set a 1 row tall Rect. Is there any other way I can grab a single row from my source image to blit to my destination buffer?