Ejemplo n.º 1
0
        /// <summary>
        /// Print image with 24bppRgb pixel format
        /// </summary>
        /// <param name="image">Image with 24bppRgb pixel format</param>
        /// <param name="outputPath">Path to print image</param>
        public static void Print24BppImage(KrecImage image, string outputPath)
        {
            var bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb);

            bmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
            bmp.WithBitmapData(bitmapData =>
            {
                var rgbValues = BitmapProcessor.Reconstruct24To24BppRgbBitmap(bitmapData, image.ImageData);
                IntPtr ptr    = bitmapData.Scan0;
                Marshal.Copy(rgbValues, 0, ptr, rgbValues.Length);
            });
            bmp.Save(outputPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Print image with 8bppIndexed pixel format (before printing convert it to 24bpp)
        /// </summary>
        /// <param name="image">Image with 8bppIndexed pixel format</param>
        /// <param name="outputPath">Path to print image</param>
        public static void Print8BppImage(KrecImage image, string outputPath)
        {
            var bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb);

            bmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);

            int len    = image.Width * image.Height * 3;
            var result = new byte[len];

            for (var i = 0; i < len; i += 3)
            {
                int ind = i / 3;
                result[i] = result[i + 1] = result[i + 2] = image.ImageData[ind];
            }

            bmp.WithBitmapData(bitmapData =>
            {
                var grayscaleValues = BitmapProcessor.Reconstruct24To24BppRgbBitmap(bitmapData, result);
                IntPtr ptr          = bitmapData.Scan0;
                Marshal.Copy(grayscaleValues, 0, ptr, grayscaleValues.Length);
            });
            bmp.Save(outputPath);
        }