Fotost negatiivi loomine
29.04.2007 | GunnarNäide sellest, kuidas .Net abil luua fotost negatiiv. Tegelikult võib sellest meetodist läbi lasta suvalist graafikat, mida .Net lugeda oskab.
Bitmap Negative(Bitmap Bmp)
{
for(int y = 0; y <Bmp.Height; y++)
for(int x = 0; x <Bmp.Width; x++)
{
Color c = Bmp.GetPixel(x,y);
Bmp.SetPixel(x,y,Color.FromArgb(255-c.R,255-c.G,255-c.B));
}
return Bmp;
}
{
for(int y = 0; y <Bmp.Height; y++)
for(int x = 0; x <Bmp.Width; x++)
{
Color c = Bmp.GetPixel(x,y);
Bmp.SetPixel(x,y,Color.FromArgb(255-c.R,255-c.G,255-c.B));
}
return Bmp;
}
Nii märkuse korras mainin ära, et pointerite abil saab tunduvalt kiirema koodi. See siin on lihtsalt lahendus, mis kasutab managed code-i.
