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); } }
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()); } } }
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()); } } }
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); }