private unsafe void Adjust(Bitmap bitmap, double factor, ApplyToPixel applyToPixel) { LockedBitmap lockedBitmap = new LockedBitmap(bitmap); Parallel.For(0, lockedBitmap.HeightInPixels, iY => { byte *pixel = lockedBitmap.FirstByte + (iY * lockedBitmap.Stride); for (int iX = 0; iX < lockedBitmap.WidthInBytes; iX += lockedBitmap.BytesPerPixel) { applyToPixel(pixel, factor); pixel += lockedBitmap.BytesPerPixel; } }); lockedBitmap.Unlock(bitmap); }
public Adjustment(ApplyToPixel applyToPixel, double f) { adjustment = applyToPixel; factor = f; }
public unsafe void Threshold(Bitmap source, int factor) { ApplyToPixel adjustment = new ApplyToPixel(ApplyThresholdToPixel); Adjust(source, factor, adjustment); }
public unsafe void BlackAndWhite(Bitmap source, int factor) { ApplyToPixel adjustment = new ApplyToPixel(ApplyBlackAndWhiteToPixel); Adjust(source, factor, adjustment); }
public unsafe void Invert(Bitmap source, int factor) { ApplyToPixel adjustment = new ApplyToPixel(ApplyInversionToPixel); Adjust(source, factor, adjustment); }
public unsafe void Sepia(Bitmap source, int factor) { ApplyToPixel adjustment = new ApplyToPixel(ApplySepiaToPixel); Adjust(source, factor, adjustment); }