public Update ( |
||
x | The X coordinate. | |
y | The Y coordinate. | |
Résultat | void |
public void WriteColorUsingPixelAt(Pixel pixel, Int32 x, Int32 y, Color color, IColorQuantizer quantizer, Byte[] buffer = null) { // redirects pixel -> [x, y] pixel.Update(x, y); // writes color to bitmap/buffer using pixel WriteColorUsingPixel(pixel, color, quantizer, buffer); }
public void WriteIndexUsingPixelAt(Pixel pixel, Int32 x, Int32 y, Int32 index, Byte[] buffer = null) { // redirects pixel -> [x, y] pixel.Update(x, y); // writes color to bitmap/buffer using pixel WriteIndexUsingPixel(pixel, index, buffer); }
public Color ReadColorUsingPixelFrom(Pixel pixel, Int32 x, Int32 y, Byte[] buffer = null) { // redirects pixel -> [x, y] pixel.Update(x, y); // reads color from a bitmap/buffer using pixel, and stores it in the pixel return(ReadColorUsingPixel(pixel, buffer)); }
private void ProcessPerPixelBase(IList <Point> path, Delegate processingAction, Int32 parallelTaskCount = 4) { // checks parameters Guard.CheckNull(path, "path"); Guard.CheckNull(processingAction, "processPixelFunction"); // determines mode Boolean isAdvanced = processingAction is ProcessPixelAdvancedFunction; // prepares the per pixel task Action <LineTask> processPerPixel = lineTask => { // initializes variables per task Pixel pixel = new Pixel(this); for (Int32 pathOffset = lineTask.StartOffset; pathOffset < lineTask.EndOffset; pathOffset++) { Point point = path[pathOffset]; Boolean allowWrite; // enumerates the pixel, and returns the control to the outside pixel.Update(point.X, point.Y); // when read is allowed, retrieves current value (in bytes) if (CanRead) { ReadPixel(pixel); } // process the pixel by custom user operation if (isAdvanced) { ProcessPixelAdvancedFunction processAdvancedFunction = (ProcessPixelAdvancedFunction)processingAction; allowWrite = processAdvancedFunction(pixel, this); } else // use simplified version with pixel parameter only { ProcessPixelFunction processFunction = (ProcessPixelFunction)processingAction; allowWrite = processFunction(pixel); } // when write is allowed, copies the value back to the row buffer if (CanWrite && allowWrite) { WritePixel(pixel); } } }; // processes image per pixel ProcessInParallel(path, processPerPixel, parallelTaskCount); }
private void TransformPerPixelBase(ImageBuffer target, IList<Point> path, Delegate transformAction, Int32 parallelTaskCount = 4) { // checks parameters Guard.CheckNull(path, "path"); Guard.CheckNull(target, "target"); Guard.CheckNull(transformAction, "transformAction"); // updates the palette UpdatePalette(); target.UpdatePalette(); // checks the dimensions if (Width != target.Width || Height != target.Height) { const String message = "Both images have to have the same dimensions."; throw new ArgumentOutOfRangeException(message); } // determines mode Boolean isAdvanced = transformAction is TransformPixelAdvancedFunction; // process the image in a parallel manner Action<LineTask> transformPerPixel = lineTask => { // creates individual pixel structures per task Pixel sourcePixel = new Pixel(this); Pixel targetPixel = new Pixel(target); // enumerates the pixels row by row for (Int32 pathOffset = lineTask.StartOffset; pathOffset < lineTask.EndOffset; pathOffset++) { Point point = path[pathOffset]; Boolean allowWrite; // enumerates the pixel, and returns the control to the outside sourcePixel.Update(point.X, point.Y); targetPixel.Update(point.X, point.Y); // when read is allowed, retrieves current value (in bytes) if (CanRead) ReadPixel(sourcePixel); if (target.CanRead) target.ReadPixel(targetPixel); // process the pixel by custom user operation if (isAdvanced) { TransformPixelAdvancedFunction transformAdvancedFunction = (TransformPixelAdvancedFunction) transformAction; allowWrite = transformAdvancedFunction(sourcePixel, targetPixel, this, target); } else // use simplified version with pixel parameters only { TransformPixelFunction transformFunction = (TransformPixelFunction) transformAction; allowWrite = transformFunction(sourcePixel, targetPixel); } // when write is allowed, copies the value back to the row buffer if (target.CanWrite && allowWrite) target.WritePixel(targetPixel); } }; // transforms image per pixel ProcessInParallel(path, transformPerPixel, parallelTaskCount); }
private void ProcessPerPixelBase(IList<Point> path, Delegate processingAction, Int32 parallelTaskCount = 4) { // checks parameters Guard.CheckNull(path, "path"); Guard.CheckNull(processingAction, "processPixelFunction"); // determines mode Boolean isAdvanced = processingAction is ProcessPixelAdvancedFunction; // prepares the per pixel task Action<LineTask> processPerPixel = lineTask => { // initializes variables per task Pixel pixel = new Pixel(this); for (Int32 pathOffset = lineTask.StartOffset; pathOffset < lineTask.EndOffset; pathOffset++) { Point point = path[pathOffset]; Boolean allowWrite; // enumerates the pixel, and returns the control to the outside pixel.Update(point.X, point.Y); // when read is allowed, retrieves current value (in bytes) if (CanRead) ReadPixel(pixel); // process the pixel by custom user operation if (isAdvanced) { ProcessPixelAdvancedFunction processAdvancedFunction = (ProcessPixelAdvancedFunction) processingAction; allowWrite = processAdvancedFunction(pixel, this); } else // use simplified version with pixel parameter only { ProcessPixelFunction processFunction = (ProcessPixelFunction) processingAction; allowWrite = processFunction(pixel); } // when write is allowed, copies the value back to the row buffer if (CanWrite && allowWrite) WritePixel(pixel); } }; // processes image per pixel ProcessInParallel(path, processPerPixel, parallelTaskCount); }
public void WriteIndexUsingPixelAt(Pixel pixel, Int32 x, Int32 y, Int32 index, Byte[] buffer = null) { // redirects pixel -> [x, y] pixel.Update(x, y); // writes color to bitmap/buffer using pixel WriteIndexUsingPixel(pixel, index, buffer); }
public void WriteColorUsingPixelAt(Pixel pixel, Int32 x, Int32 y, Color color, IColorQuantizer quantizer, Byte[] buffer = null) { // redirects pixel -> [x, y] pixel.Update(x, y); // writes color to bitmap/buffer using pixel WriteColorUsingPixel(pixel, color, quantizer, buffer); }
public Int32 ReadIndexUsingPixelFrom(Pixel pixel, Int32 x, Int32 y, Byte[] buffer = null) { // redirects pixel -> [x, y] pixel.Update(x, y); // reads index from a bitmap/buffer using pixel, and stores it in the pixel return ReadIndexUsingPixel(pixel, buffer); }
private void TransformPerPixelBase(ImageBuffer target, IList <Point> path, Delegate transformAction, Int32 parallelTaskCount = 4) { // checks parameters Guard.CheckNull(path, "path"); Guard.CheckNull(target, "target"); Guard.CheckNull(transformAction, "transformAction"); // updates the palette UpdatePalette(); target.UpdatePalette(); // checks the dimensions if (Width != target.Width || Height != target.Height) { const String message = "Both images have to have the same dimensions."; throw new ArgumentOutOfRangeException(message); } // determines mode Boolean isAdvanced = transformAction is TransformPixelAdvancedFunction; // process the image in a parallel manner Action <LineTask> transformPerPixel = lineTask => { // creates individual pixel structures per task Pixel sourcePixel = new Pixel(this); Pixel targetPixel = new Pixel(target); // enumerates the pixels row by row for (Int32 pathOffset = lineTask.StartOffset; pathOffset < lineTask.EndOffset; pathOffset++) { Point point = path[pathOffset]; Boolean allowWrite; // enumerates the pixel, and returns the control to the outside sourcePixel.Update(point.X, point.Y); targetPixel.Update(point.X, point.Y); // when read is allowed, retrieves current value (in bytes) if (CanRead) { ReadPixel(sourcePixel); } if (target.CanRead) { target.ReadPixel(targetPixel); } // process the pixel by custom user operation if (isAdvanced) { TransformPixelAdvancedFunction transformAdvancedFunction = (TransformPixelAdvancedFunction)transformAction; allowWrite = transformAdvancedFunction(sourcePixel, targetPixel, this, target); } else // use simplified version with pixel parameters only { TransformPixelFunction transformFunction = (TransformPixelFunction)transformAction; allowWrite = transformFunction(sourcePixel, targetPixel); } // when write is allowed, copies the value back to the row buffer if (target.CanWrite && allowWrite) { target.WritePixel(targetPixel); } } }; // transforms image per pixel ProcessInParallel(path, transformPerPixel, parallelTaskCount); }