Beispiel #1
0
        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);
        }
Beispiel #2
0
 public Adjustment(ApplyToPixel applyToPixel, double f)
 {
     adjustment = applyToPixel;
     factor     = f;
 }
Beispiel #3
0
        public unsafe void Threshold(Bitmap source, int factor)
        {
            ApplyToPixel adjustment = new ApplyToPixel(ApplyThresholdToPixel);

            Adjust(source, factor, adjustment);
        }
Beispiel #4
0
        public unsafe void BlackAndWhite(Bitmap source, int factor)
        {
            ApplyToPixel adjustment = new ApplyToPixel(ApplyBlackAndWhiteToPixel);

            Adjust(source, factor, adjustment);
        }
Beispiel #5
0
        public unsafe void Invert(Bitmap source, int factor)
        {
            ApplyToPixel adjustment = new ApplyToPixel(ApplyInversionToPixel);

            Adjust(source, factor, adjustment);
        }
Beispiel #6
0
        public unsafe void Sepia(Bitmap source, int factor)
        {
            ApplyToPixel adjustment = new ApplyToPixel(ApplySepiaToPixel);

            Adjust(source, factor, adjustment);
        }