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