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); }
private unsafe void Adjust(Bitmap bitmap, List <Adjustment> adjustmentsPack) { 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) { foreach (Adjustment adjustment in adjustmentsPack) { adjustment.adjustment(pixel, adjustment.factor); } pixel += lockedBitmap.BytesPerPixel; } }); lockedBitmap.Unlock(bitmap); }
protected void Apply(Bitmap input, Bitmap output) { if (!IsValid()) { return; } bytesPerPixel = Bitmap.GetPixelFormatSize(input.PixelFormat) / (int)Bits.bitsInByte; gapInBytes = gap * bytesPerPixel; IntermediateImage intermediate = new IntermediateImage(input, gap); intermediate.FillIn(); LockedBitmap lockedBitmap = new LockedBitmap(output); LockedBitmap lockedIntermediate = new LockedBitmap(intermediate.OutputImage); ApplyFilterToBitmap(lockedIntermediate, lockedBitmap); lockedBitmap.Unlock(output); lockedIntermediate.Unlock(intermediate.OutputImage); }
public void UnlockArea() { sourceData.Unlock(sourceImage); intermediateData.Unlock(intermediateImage); }