public Image Extract( Stream[] streamsToAnimatedGif, DestinationShape destinationShape) { var images = new List<Image>(); int count = 0; foreach (Stream stream in streamsToAnimatedGif) { if (Progress != null) { var bs = new byte[stream.Length]; stream.Read(bs, 0, bs.Length); stream.Seek(0, SeekOrigin.Begin); Image img = Image.FromStream(new MemoryStream(bs)); var args = new ProgressArgs( ProgressEvent.StartingToProcessSourceImage, string.Format( @"Processing image {0} of {1} - file: {2}", count, streamsToAnimatedGif.Length, stream), img); Progress(this, args); } List<Frame> frames = getFrames(stream); Image i = writeFramesToImage(frames, destinationShape); images.Add(i); count++; } return combineImages(images, destinationShape); }
static void onExtractionProgress(object sender, ProgressArgs args) { Image i = args.Image; }
void onProgress(object sender, ProgressArgs args) { if (InvokeRequired) { BeginInvoke(new ImageExtractionHandler(onProgress), sender, args); return; } toolStripStatusLabel1.Text = args.Message; _labelDest.Text = args.Message; adjustControlPlacement(); if (args.ProgressEvent == ProgressEvent.FinishedProcessingDestinationImage) { Close(); } if (args.ProgressEvent == ProgressEvent.StartingToProcessSourceImage) { pictureBoxSource.Image = args.Image; toolStripProgressBar1.Increment(1); } if (args.ProgressEvent == ProgressEvent.StartingToProcessFrameFromSourceImage) { pictureBoxDestination.Image = args.Image; } }