private static Image GetModifiedImage(IPageReader pageReader)
        {
            var rawBytes = pageReader.GetImage();

            var width  = pageReader.GetPageWidth();
            var height = pageReader.GetPageHeight();

            var characters = pageReader.GetCharacters();

            using (var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb))
            {
                var background = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                bmp.AddBytes(rawBytes);

                using (var g = Graphics.FromImage(background))
                {
                    g.Clear(Color.White);
                    g.DrawImageUnscaled(bmp, Point.Empty);
                }


                //bmp.DrawRectangles(characters);

                return(background);
            }
        }
예제 #2
0
파일: ExampleFour.cs 프로젝트: bseay/docnet
        private static byte[] GetModifiedImage(IPageReader pageReader)
        {
            var rawBytes = pageReader.GetImage(RenderFlags.RenderAnnotations | RenderFlags.Grayscale);

            var width  = pageReader.GetPageWidth();
            var height = pageReader.GetPageHeight();

            using (var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb))
            {
                bmp.AddBytes(rawBytes);

                using (var stream = new MemoryStream())
                {
                    bmp.Save(stream, ImageFormat.Png);

                    return(stream.ToArray());
                }
            }
        }
예제 #3
0
        private static byte[] GetModifiedImage(IPageReader pageReader)
        {
            var rawBytes = pageReader.GetImage();

            var width  = pageReader.GetPageWidth();
            var height = pageReader.GetPageHeight();

            var characters = pageReader.GetCharacters();

            using (var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb))
            {
                bmp.AddBytes(rawBytes);

                //bmp.DrawRectangles(characters);

                using (var stream = new MemoryStream())
                {
                    bmp.Save(stream, ImageFormat.Png);

                    return(stream.ToArray());
                }
            }
        }
예제 #4
0
        public void PageToImage(int pageIndex, int width, int height)
        {
            IDocReader  docReader  = DocLib.Instance.GetDocReader(Context.Document, new PageDimensions(width, height));
            IPageReader pageReader = docReader.GetPageReader(pageIndex);

            MemoryStream mem = new MemoryStream();

            Image <Bgra32> image = Image.LoadPixelData <Bgra32>(pageReader.GetImage(), pageReader.GetPageWidth(), pageReader.GetPageHeight());

            image.SaveAsPng(mem);

            Context.Result = new ImageResult(mem.ToArray(), MimeTypes.Png);
        }