/// <summary> /// Filter processing. /// </summary> /// <param name="rOriginal">Original raster.</param> /// <returns>Raster.</returns> public override Raster ProcessWithoutWorker(Raster rOriginal) { int width = rOriginal.Width; int height = rOriginal.Height; Raster raster = new Raster(width, height); VectorHsi hsi; float fIntensity = (float)this.intensity / 255f; float fSaturation = (float)this.saturation / 255f; float fHue = (float)this.hue / 255f; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { hsi = new VectorHsi(rOriginal[i, j]); hsi.ChangeSaturation(fSaturation); hsi.ChangeIntensity(fIntensity); hsi.ChangeHue(fHue); hsi = VectorHsi.Clamp(hsi, 0f, 1f); raster[i, j] = hsi.ToVectorRGB(); } } return raster; }
/// <summary> /// Filter processing, with BackgroundWorker. /// </summary> /// <param name="rOriginal">Original raster.</param> /// <param name="worker">BackgroundWorker.</param> /// <returns>Raster.</returns> public override Raster ProcessRaster(Raster rOriginal, System.ComponentModel.BackgroundWorker worker) { worker.WorkerReportsProgress = true; int width = rOriginal.Width; int height = rOriginal.Height; Raster raster = new Raster(width, height); VectorHsi hsi; float fIntensity = (float)this.intensity / 255f; float fSaturation = (float)this.saturation / 255f; float fHue = (float)this.hue / 255f; DateTime startTime = DateTime.Now; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { hsi = new VectorHsi(rOriginal[i, j]); hsi.ChangeSaturation(fSaturation); hsi.ChangeIntensity(fIntensity); hsi.ChangeHue(fHue); hsi = VectorHsi.Clamp(hsi, 0.0f, 1.0f); raster[i, j] = hsi.ToVectorRGB(); } worker.ReportProgress((int)(100f * j / height), DateTime.Now - startTime); } return raster; }