since there's been a lot of related discussion in h3ro's thread, i wanted to post this in hopes i could likewise get some help in optimizing this code that draws a translucent rectangle
lastX,lastY and startX,startY are set in a mousemove event. last is guaranteed to be > start
the follow code takes place in an onmouseup event.
Code:
Graphics::TBitmap *b = new Graphics::TBitmap;
b->Height = lastY-startY;
b->Width = lastX-startX;
b->Canvas->Brush->Color = 0x00FF0000;
b->Canvas->FloodFill(0,0,0x000000FF,fsBorder);//fills b with pure blue
for(int i = startY;i<lastY;i++)
{
RGBQUAD *Pixel = (RGBQUAD *) bmp->ScanLine[i];
RGBQUAD *Pixel2 = (RGBQUAD *) b->ScanLine[i-startY];
Pixel+=startX-axesBmp->Width;
for(int j = startX; j < lastX; j++, Pixel++,Pixel2++)
{
Pixel2->rgbBlue = .67*Pixel->rgbBlue+.33*Pixel2->rgbBlue;
Pixel2->rgbGreen = .67*Pixel->rgbGreen+.33*Pixel2->rgbGreen;
Pixel2->rgbRed = .67*Pixel->rgbRed+.33*Pixel2->rgbRed;
}
}
this performs the desired function, but it is just too slow.
i'm open to totally redoing this if someone knows of a totally different strategy that would work better. i realize that breaking the scanlines into pixels also yields no better performance than just indexing the pixels correctly, but i haven't been able to find any documentation on how to perform operations on scanlines as a whole, so i don't know what other choice i have.