/// <summary> /// Gets the foreground image for the page /// </summary> /// <param name="resizeToPage"></param> /// <returns></returns> internal System.Drawing.Bitmap GetForegroundImage(int subsample, bool resizeImage = false) { Verify.SubsampleRange(subsample); lock (_LoadingLock) { Bitmap result = null; JB2Image jb2image = null; var iwPixelMap = _Page.ForegroundIWPixelMap; if (iwPixelMap != null) { result = _Page.ForegroundIWPixelMap.GetPixelMap().ToImage(); } else if ((jb2image = _Page.ForegroundJB2Image) != null) { result = jb2image.GetBitmap().ToImage(); } else if (iwPixelMap == null && jb2image == null) { result = DjvuImage.CreateBlankImage(Brushes.Black, _Page.Width / subsample, _Page.Height / subsample); } return(resizeImage == true?DjvuImage.ResizeImage(result, _Page.Width / subsample, _Page.Height / subsample) : result); } }
/// <summary> /// Extracts a thumbnail image for the page /// </summary> /// <returns></returns> public Bitmap ExtractThumbnailImage() { if (_Page.Thumbnail != null) { return(_Page.Thumbnail.Image.ToImage()); } Bitmap result = BuildImage(); var scaleAmount = (double)128 / result.Width; return(DjvuImage.ResizeImage(result, (int)(result.Width * scaleAmount), (int)(result.Height * scaleAmount))); }
/// <summary> /// Gets the background image for the page /// </summary> /// <returns></returns> internal System.Drawing.Bitmap GetBackgroundImage(int subsample, bool resizeImage = false) { Verify.SubsampleRange(subsample); int width = _Page.Width; int height = _Page.Height; BG44Chunk[] backgrounds = _Page.PageForm?.GetChildrenItems <BG44Chunk>(); if ((backgrounds == null || backgrounds.Length == 0) && width > 0 && height > 0) { return(DjvuImage.CreateBlankImage(Brushes.White, width, height)); } // Get the composite background image Wavelet.IInterWavePixelMap backgroundMap = null; lock (LoadingLock) { foreach (BG44Chunk background in backgrounds) { if (backgroundMap == null) { // Get the initial image backgroundMap = background.BackgroundImage; } else { if (!IsBackgroundDecoded) { background.ProgressiveDecodeBackground(backgroundMap); } } } IsBackgroundDecoded = true; } Bitmap result = backgroundMap.GetPixelMap().ToImage(); if (resizeImage) { int newWidth = width / subsample; int newHeight = height / subsample; return(DjvuImage.ResizeImage(result, newWidth, newHeight)); } else { return(result); } }
internal System.Drawing.Bitmap GetMaskImage(int subsample, bool resizeImage = false) { Verify.SubsampleRange(subsample); if (_Page.ForegroundJB2Image == null) { return(new System.Drawing.Bitmap(_Page.Width / subsample, _Page.Height / subsample, PixelFormat.Format8bppIndexed)); } lock (LoadingLock) { Bitmap result = _Page.ForegroundJB2Image.GetBitmap(subsample, GBitmap.BorderSize).ToImage(); return(resizeImage ? DjvuImage.ResizeImage(result, _Page.Width / subsample, _Page.Height / subsample) : result); } }
internal System.Drawing.Bitmap GetTextImage(int subsample, bool resizeImage = false) { Verify.SubsampleRange(subsample); if (_Page.ForegroundJB2Image == null) { return(new System.Drawing.Bitmap(_Page.Width / subsample, _Page.Height / subsample)); } lock (_LoadingLock) { var result = _Page.ForegroundJB2Image.GetBitmap(subsample, 4).ToImage(); return(resizeImage ? DjvuImage.ResizeImage(result, _Page.Width / subsample, _Page.Height / subsample) : result); } }
/// <summary> /// Resizes the pages image to the new dimensions /// </summary> /// <param name="srcImage"></param> /// <param name="newWidth"></param> /// <param name="newHeight"></param> /// <returns></returns> public System.Drawing.Bitmap ResizeImage(int newWidth, int newHeight) { return(DjvuImage.ResizeImage(Image, newWidth, newHeight)); }