Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fast "clearing" of Image pixels

0 views
Skip to first unread message

windywinter

unread,
Jun 12, 2006, 7:11:01 AM6/12/06
to
Hi,

I want to ask about fast "clearing" image to transparency color.
Something like: FillRect(Brushes.Transparent, 10, 20, 16, 16), but
because all new pixels are transparent then... all will be ignored.

Generally I have buffer (Bitmap) object. This buffer is divided on
tiles. At any time I want to "clear" specified tile (ex. it could be
buffer rectangle, x:30, y:70, w:10, w:10.

Right now I'm using:

BitmapData bData = _mapBuffers[layerLevel].LockBits(new Rectangle(bx,
by, tileWidth, tileHeight), ImageLockMode.WriteOnly,
PixelFormat.Format32bppArgb);
for (int i = 0; i < tileHeight; i++) {
int* ptrData = (int*)bData.Scan0 + (i * bData.Stride /
sizeof(int));
for (int j = 0; j < tileWidth; j++) {
(*ptrData++) = 0;
//ptrData++;
}
}
_mapBuffers[layerLevel].UnlockBits(bData);

Unfortunatelly other drawing is using Graphics object and I have to
release locked bits.

Does anyone know how to make it better (faster)?

Wojciech Gebczyk

Rickard

unread,
Jun 14, 2006, 5:25:29 AM6/14/06
to
g.CompositingMode = CompositingMode.SourceCopy
g.FillRect(Brushes.Transparent, 10, 20, 16, 16)

Should work.

windywinter

unread,
Jun 14, 2006, 9:01:48 AM6/14/06
to
Yes! it works. Thank you!

v

0 new messages