public static int Write(IntImage x, PdfWriter w) { if (x == null) { return(0); } int maskObj = Write(x.ImageMask, w); byte [] content = x.Data; if (!x.Deflated) { content = PdfWriter.Deflate(content); } int result = w.StartObj(); w.Put("<</Type/XObject/Subtype/Image" + "/Width " + x.Width + "/Height " + x.Height + (maskObj != 0 ? "/SMask " + maskObj + " 0 R" : "") + "/Length " + content.Length + (x.IsMask ? "/ColorSpace/DeviceGray" : "") ); if (x.Additional != null) { x.Additional.OutputInner(w); } w.Put("/BitsPerComponent " + x.BitsPerComponent + "/Filter/FlateDecode>>stream\n"); w.Put(content); w.Put("\nendstream"); w.EndObj(); return(result); }
// Adds an image to the PDF, returns info about the image. Use PdfWriter.CP.DrawImage to draw the Image on a page. public static PdfImage Add(PdfWriter w, byte[] b) { // System.Console.WriteLine( "Reading PNG size=" + b.Length ); IntImage x = Pdf.Png.Reader.GetImage(b); // Only handles PNG format currently. // System.Console.WriteLine( "Got PNG" ); PdfImage result = new PdfImage(x.Width, x.Height, IntImage.Write(x, w)); // System.Console.WriteLine( "Wrote PNG" ); return(result); }