/* Callback from ghostscript with the rendered image. */ private void MainPageCallback(int width, int height, int raster, double zoom_in, int page_num, IntPtr data) { Byte[] bitmap = new byte[raster * height]; idata_t image_data = new idata_t(); Marshal.Copy(data, bitmap, 0, raster * height); image_data.bitmap = bitmap; image_data.page_num = page_num; image_data.width = width; image_data.height = height; image_data.raster = raster; image_data.zoom = zoom_in; m_images_rendered.Add(image_data); /* Get the 1.0 page scalings */ if (m_firstime) { pagesizes_t page_size = new pagesizes_t(); page_size.size.X = width; page_size.size.Y = height; m_page_sizes.Add(page_size); } /* Dispatch progress bar update on UI thread */ System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { m_page_progress_count += 1; xaml_RenderProgress.Value = ((double)m_page_progress_count / (double)m_numpages) * 100.0; })); }
/* Callback from ghostscript with the rendered thumbnail. Also update progress */ private void ThumbPageCallback(int width, int height, int raster, double zoom_in, int page_num, IntPtr data) { Byte[] bitmap = new byte[raster * height]; idata_t thumb = new idata_t(); Marshal.Copy(data, bitmap, 0, raster * height); thumb.bitmap = bitmap; thumb.page_num = page_num; thumb.width = width; thumb.height = height; thumb.raster = raster; thumb.zoom = zoom_in; m_list_thumb.Add(thumb); /* Dispatch progress bar update on UI thread */ System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { /* Logrithmic but it will show progress */ xaml_RenderProgress.Value = ((double)page_num / ((double)page_num + 1)) * 100.0; })); }