Exemplo n.º 1
0
        /// <summary>
        /// Start rendering a region of a display list to the specified destination.
        /// </summary>
        /// <param name="context">The rendering context.</param>
        /// <param name="displayList">The native display list that should be rendered.</param>
        /// <param name="region">The region that should be rendered.</param>
        /// <param name="zoom">The scale at which the region will be rendered. This will determine the size in pixel of the image.</param>
        /// <param name="pixelStorage">The address of the buffer where the pixel data will be written. There must be enough space available to write the values for all the pixels, otherwise this will fail catastrophically!</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        /// <param name="pageBounds">The bounds of the page being rendererd.</param>
        /// <param name="clipToPageBounds">A boolean value indicating whether the rendered image should be clipped to the original page's bounds. This can be relevant if the page has been "cropped" by altering its mediabox, but otherwise leaving the contents untouched.</param>
        public void Render(IntPtr context, MuPDFDisplayList displayList, Rectangle region, float zoom, IntPtr pixelStorage, PixelFormats pixelFormat, Rectangle pageBounds, bool clipToPageBounds)
        {
            lock (RenderDataLock)
            {
                //Reset the cookie.
                unsafe
                {
                    Cookie *cookie = (Cookie *)Cookie;

                    cookie->abort        = 0;
                    cookie->errors       = 0;
                    cookie->incomplete   = 0;
                    cookie->progress     = 0;
                    cookie->progress_max = 0;
                }

                //Set up all the rendering data.
                CurrentRenderData.Context          = context;
                CurrentRenderData.DisplayList      = displayList;
                CurrentRenderData.Region           = region;
                CurrentRenderData.Zoom             = zoom;
                CurrentRenderData.PixelStorage     = pixelStorage;
                CurrentRenderData.PixelFormat      = pixelFormat;
                CurrentRenderData.PageBounds       = pageBounds;
                CurrentRenderData.ClipToPageBounds = clipToPageBounds;
                SignalToThread.Set();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Abort the current rendering operation.
 /// </summary>
 public void AbortRendering()
 {
     lock (RenderDataLock)
     {
         unsafe
         {
             Cookie *cookie = (Cookie *)Cookie;
             cookie->abort = 1;
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Get the progress of the current rendering operation.
        /// </summary>
        /// <returns>A <see cref="RenderProgress.ThreadRenderProgress"/> object containing the progress of the current rendering operation.</returns>
        public RenderProgress.ThreadRenderProgress GetProgress()
        {
            int   progress;
            ulong maxProgress;

            unsafe
            {
                Cookie *cookie = (Cookie *)Cookie;

                progress    = cookie->progress;
                maxProgress = cookie->progress_max;
            }

            return(new RenderProgress.ThreadRenderProgress(progress, maxProgress));
        }