Esempio n. 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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public void UnlockArea()
 {
     sourceData.Unlock(sourceImage);
     intermediateData.Unlock(intermediateImage);
 }