示例#1
0
        /// <summary>
        /// Process existing pages
        /// </summary>
        /// <returns>Null if page still painting, PdfBitmap object if page successfully rendered.</returns>
        private bool ProcessExisting(PdfPage page, Rectangle pageRect, PageRotate pageRotate, RenderFlags renderFlags)
        {
            switch (this[page].status)
            {
            case ProgressiveRenderingStatuses.RenderReader:
                this[page].status = page.StartProgressiveRender(CanvasBitmap, pageRect.X, pageRect.Y, pageRect.Width, pageRect.Height, pageRotate, renderFlags, null);
                if (this[page].status == ProgressiveRenderingStatuses.RenderDone)
                {
                    return(true);
                }
                return(false);                        //Start rendering. Return nothing.

            case ProgressiveRenderingStatuses.RenderDone:
                page.CancelProgressiveRender();
                this[page].status = ProgressiveRenderingStatuses.RenderDone + 2;
                return(true);                        //Stop rendering. Return image.

            case ProgressiveRenderingStatuses.RenderDone + 2:
                return(true);                        //Rendering already stoped. return image

            case ProgressiveRenderingStatuses.RenderDone + 3:
                this[page].status = ProgressiveRenderingStatuses.RenderDone + 2;
                page.RenderEx(CanvasBitmap, pageRect.X, pageRect.Y, pageRect.Width, pageRect.Height, pageRotate, renderFlags);
                return(true);                        //Rendering in non progressive mode

            case ProgressiveRenderingStatuses.RenderDone + 4:
                this[page].status = ProgressiveRenderingStatuses.RenderDone + 2;
                DrawThumbnail(page, pageRect, pageRotate, renderFlags);
                return(true);                        //Rendering thumbnails

            case ProgressiveRenderingStatuses.RenderTobeContinued:
                this[page].status = page.ContinueProgressiveRender();
                return(false);                        //Continue rendering. Return nothing.

            case ProgressiveRenderingStatuses.RenderFailed:
            default:
                CanvasBitmap.FillRect(pageRect.X, pageRect.Y, pageRect.Width, pageRect.Height, Color.Red);
                CanvasBitmap.FillRect(pageRect.X + 5, pageRect.Y + 5, pageRect.Width - 10, pageRect.Height - 10, Color.White);
                page.CancelProgressiveRender();
                this[page].status = ProgressiveRenderingStatuses.RenderDone + 2;
                return(true);                        //Error occur. Stop rendering. return image with error
            }
        }