private int DisplayPreClose(IntPtr handle, IntPtr device) { try { ClearProgressiveImage(); } catch (Exception e) { StdErr.Append(e); return(Native.gs_error_Fatal); } return(0); }
private int DisplayPreSize(IntPtr handle, IntPtr device, int width, int height, int raster, uint format) { try { ClearProgressiveImage(); } catch (Exception e) { StdErr.Append(e); return(Native.gs_error_Fatal); } return(0); }
private int DisplaySize(IntPtr handle, IntPtr device, int width, int height, int raster, uint format, IntPtr pimage) { try { // create the new source image _temporaryImage = new Bitmap(width, height, raster, PixelFormat.Format32bppRgb, pimage) { Tag = true }; // notify the update listeners Update?.Invoke(this, new GhostscriptRendererEventArgs(_temporaryImage)); } catch (Exception e) { StdErr.Append(e); return(Native.gs_error_Fatal); } return(0); }
private int DisplayUpdate(IntPtr handle, IntPtr device, int x, int y, int width, int height) { // ensure there are listeners and an image var update = Update; if (update != null && _temporaryImage != null) { try { if (!(bool)_temporaryImage.Tag) { _temporaryImage.Tag = true; update(this, new GhostscriptRendererEventArgs(_temporaryImage)); } } catch (Exception e) { StdErr.Append(e); return(Native.gs_error_Fatal); } } return(0); }
private int DisplayPage(IntPtr handle, IntPtr device, int copies, int flush) { // return an error if display_size has not been called yet if (_temporaryImage == null) { return(Native.gs_error_undefinedresult); } // notify the page handler if any var page = Page; if (page != null) { try { // store the resulting image Bitmap image; lock (_temporaryImage) { var rect = new Rectangle(Point.Empty, _temporaryImage.Size); image = new Bitmap(rect.Width, rect.Height, PixelFormat.Format24bppRgb); using (var gc = Graphics.FromImage(image)) { gc.DrawImage(_temporaryImage, rect, rect, GraphicsUnit.Pixel); } image = new Bitmap(_temporaryImage); } page(this, new GhostscriptRendererEventArgs(image)); } catch (Exception e) { StdErr.Append(e); return(Native.gs_error_Fatal); } } return(0); }