private static void TransformFrame(IBitmapProcessor bitmapProcessor, ImageFrame frame)
		{
			var bitmapCopy = (Bitmap)frame.Bitmap.Clone();
			frame.Bitmap.Dispose();

			frame.Bitmap = bitmapProcessor.Process(bitmapCopy, frame.GetBackgroundColor().Color);

			DefaultQuantizer.Quantize(frame.Bitmap, frame.GetPalette());

			frame.ImageDescriptor.ImageWidth = (short)frame.Bitmap.Width;
			frame.ImageDescriptor.ImageHeight = (short)frame.Bitmap.Height;
		}
		public static void Transform(Stream inputImage, Stream outputImage, IBitmapProcessor bitmapProcessor)
		{
			var image = GifDecoder.Decode(inputImage);

			ProcessDisposalMethod(image);

			image.LogicalScreenDescriptor.LogicalScreenWidth = 1;
			image.LogicalScreenDescriptor.LogicalScreenHeight = 1;

			foreach (var frame in image.Frames)
			{
				TransformFrame(bitmapProcessor, frame);

				image.LogicalScreenDescriptor.LogicalScreenWidth = Math.Max(image.LogicalScreenDescriptor.LogicalScreenWidth, frame.ImageDescriptor.ImageWidth);
				image.LogicalScreenDescriptor.LogicalScreenHeight = Math.Max(image.LogicalScreenDescriptor.LogicalScreenHeight, frame.ImageDescriptor.ImageHeight);
			}

			GifEncoder.Encode(image, outputImage);
		}
Ejemplo n.º 3
0
        public Main(IGenericLoader <Measurement> measurementsLoader,
                    IMaskIntensityResistanceInterpolatorFactory maskIntensityInterpolatorFactory,
                    IGenericGridLoader <int> measurementGridLoader,
                    IMeasurementGridProcessor measurementGridProcessor,
                    IExposureTimeCalculator exposureTimeCalculator,
                    IOutputWriter outputWriter,
                    IBitmapProcessor bitmapProcessor,
                    IErrorReportCreator errorReportCreator,
                    ErrorReportConfiguration errorReportConfiguration,
                    IErrorReportReporter errorReportReporter)
        {
            _measurementsLoader = measurementsLoader;
            _maskIntensityInterpolatorFactory = maskIntensityInterpolatorFactory;
            _measurementGridLoader            = measurementGridLoader;
            _measurementGridProcessor         = measurementGridProcessor;
            _exposureTimeCalculator           = exposureTimeCalculator;
            _outputWriter             = outputWriter;
            _bitmapProcessor          = bitmapProcessor;
            _errorReportCreator       = errorReportCreator;
            _errorReportConfiguration = errorReportConfiguration;

            errorReportReporter.Start();
        }