internal PageImage(Bitmap bmp, bool ConvertTo32Bit) { if (ConvertTo32Bit) { this._sourceBmp = BitmapHelper.CreateCopy32Bit(bmp); } else { this._sourceBmp = BitmapHelper.CreateCopyExact(bmp); } }
/// <summary> /// Draws the given Bitmap into a new Bitmap that has the indicated fax geometry. Always returns /// 32bpp pixel format. /// </summary> /// <param name="bmp">The source bitmap.</param> /// <param name="quality">The Fax Quality. Default is Low.</param> /// <param name="paperSize">The Paper size. Default is Auto.</param> /// <param name="interpolationMode">The Interpolation mode. Default is High, but will use the current value in Image Utility, unless defined here. size.</param> /// <returns>The new PageImageList (always with 32bpp pixel format)</returns> internal static Bitmap CreateCopyFaxGeometry(Bitmap bmp, FaxQuality quality, PaperSize paperSize, InterpolationMode interpolationMode) { bool destroytemp = false; Bitmap tmp = null; Bitmap ret = null; if (bmp.PixelFormat == PixelFormat.Format8bppIndexed) { tmp = Convert8BppTo32Bpp(bmp); destroytemp = true; } else if (bmp.PixelFormat == PixelFormat.Format32bppArgb) { tmp = bmp; } else { tmp = BitmapHelper.CreateCopy32Bit(bmp); destroytemp = true; } //else if (bmp.PixelFormat != PixelFormat.Format32bppArgb) { tmp = bmp; } //else { tmp = BitmapHelper.CreateCopy32Bit(bmp); destroytemp = true; } ret = BitmapHelper.CreateBitMap(paperSize, quality, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(ret); g.InterpolationMode = interpolationMode; GraphicsUnit gu = GraphicsUnit.Pixel; g.DrawImage(tmp, ret.GetBounds(ref gu), tmp.GetBounds(ref gu), GraphicsUnit.Pixel); g.Dispose(); if (destroytemp) { tmp.Dispose(); } return(ret); }