public static void EncodeAsync(byte[] dataRgba, int stride, Action <Exception, byte[]> callback)
 {
     ThreadPool.QueueUserWorkItem((state) =>
     {
         try
         {
             byte[] png = PngEncoder.Encode(dataRgba, stride);
             callback(null, png);
         }
         catch (Exception ex)
         {
             callback(ex, null);
             throw;
         }
     }, null);
 }
Exemple #2
0
            private void EncodeCallback(object state)
            {
                byte[] byteData = this.NativeData.ToArray();
                int    downsampledStride;

                byteData = Downsampler.Downsample(byteData, this.Width * 4, this.MaximumWidth, this.MaximumHeight, out downsampledStride);
                if (this.Type == ScreenshotType.Png)
                {
                    byteData = PngEncoder.Encode(byteData, downsampledStride);
                }
                if (this.Callback != null)
                {
                    this.Callback(byteData, this.State);
                }
                this.NativeData.Dispose();
                this.IsInUse = false;
            }