protected double RealWidth(RepObj repObj) { if (repObj is RepRect) { RepRect repRect = (RepRect)repObj; return(repRect.rWidth + repRect.penProp.rWidth); } else if (repObj is RepImage) { RepImage repImage = (RepImage)repObj; if (Double.IsNaN(repImage.rWidth)) { using (Image image = Image.FromStream(repImage.stream)) { if (Double.IsNaN(repImage.rHeight)) { repImage.rWidth = image.Width / image.HorizontalResolution * 72; repImage.rHeight = image.Height / image.VerticalResolution * 72; } else { repImage.rWidth = image.Width * repImage.rHeight / image.Height; } } } return(repImage.rWidth); } else { return(repObj.rWidth); } }
//----------------------------------------------------------------------------------------------------x /// <summary>Adds a report object to the container.</summary> /// <param name="rX">X-coordinate of the report object</param> /// <param name="rY">Y-coordinate of the report object</param> /// <param name="repObj">Report object to add to the container</param> public new void Add(Double rX, Double rY, RepObj repObj) { //Added By TechnoGuru - [email protected] - http://www.borie.org/ //Here we handle image comosed of severals images if (repObj is RepImage) { #if !WindowsCE RepImage repImage = repObj as RepImage; using (Image image = Image.FromStream(repImage.stream)) { if (image.RawFormat.Equals(ImageFormat.Tiff)) { Guid objGuid = (image.FrameDimensionsList[0]); System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid); // Numbre of image in the tiff file int totFrame = image.GetFrameCount(objDimension); if (totFrame > 1) { // Saves every frame in a seperate file. for (int i = 0; i < totFrame; i++) { image.SelectActiveFrame(objDimension, i); string tempFile = Path.GetTempFileName() + ".tif"; if (image.PixelFormat.Equals(PixelFormat.Format1bppIndexed)) { ImageCodecInfo myImageCodecInfo; myImageCodecInfo = GetEncoderInfo("image/tiff"); EncoderParameters myEncoderParameters; myEncoderParameters = new EncoderParameters(1); myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionCCITT4); image.Save(tempFile, myImageCodecInfo, myEncoderParameters); } else { image.Save(tempFile, ImageFormat.Tiff); } FileStream stream = new System.IO.FileStream(tempFile, FileMode.Open, FileAccess.Read); if (i == 0) { repImage.stream = stream; repObj = repImage as RepObj; } else { new Page(report); RepImage di = new RepImageMM(stream, Double.NaN, Double.NaN); report.page_Cur.AddMM(0, 0, di); } } } } } #endif } base.Add(rX, rY, repObj); }
//------------------------------------------------------------------------------------------xx.02.2006 /// <summary>Writes the RepObj to the buffer.</summary> /// <param name="e">Environment data</param> public void Write(PdfIndirectObject_PageContents.Environment e) { PdfIndirectObject_PageContents p = e.pdfIndirectObject_PageContents; RepImage repImage = (RepImage)e.repObj; Double rOfsX = repImage.rWidth * repImage.rAlignH; Double rOfsY = repImage.rHeight * (1 - repImage.rAlignV); e.matrixD.Multiply(new MatrixD(1, 0, 0, 1, -rOfsX, rOfsY)); e.matrixD.Scale(repImage.rWidth, repImage.rHeight); p.Command("q"); p.Write_Matrix(e.matrixD); p.Command("cm"); PdfIndirectObject_ImageJpeg pdfIndirectObject_ImageJpeg = (PdfIndirectObject_ImageJpeg)repImage.imageData.oImageResourceX; p.Name("I" + pdfIndirectObject_ImageJpeg.iObjectNumber); p.Command("Do"); p.Command("Q"); }
//----------------------------------------------------------------------------------------------------x /// <summary>Prepares the PDF-object structure for a container.</summary> /// <param name="pdfPageData"></param> /// <param name="iObjId"></param> /// <param name="container"></param> private void PrepareObjIdsForContainer(PdfIndirectObject_Page pdfPageData, Container container) { foreach (RepObj repObj in container) { if (repObj is Container) { PrepareObjIdsForContainer(pdfPageData, (Container)repObj); } else if (repObj is RepArcBase) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepImage) { // RepImage repImage = (RepImage)repObj; // ImageFormat imageFormat = repImage.imageData.image.RawFormat; // if (Object.Equals(imageFormat, ImageFormat.Jpeg)) { // pdfPageData.bProcSet_ImageC = true; // } // else if (Object.Equals(imageFormat, ImageFormat.Tiff)) { // pdfPageData.bProcSet_ImageB = true; // } // else { // Debug.Fail("unknown image type: send image to [email protected]"); // } RepImage repImage = repObj as RepImage; repImage.imageData.stream.Position = 0; //Added By TechnoGuru - [email protected] - http://www.borie.org/ //To support tiff file //I reload Image from stream to be more scalable //(Dont't have like that lots of image object on memeory #if !WindowsCE using (Image image = Image.FromStream(repImage.imageData.stream)) { if (image.RawFormat.Equals(ImageFormat.Tiff) && image.PixelFormat.Equals(PixelFormat.Format1bppIndexed)) { pdfPageData.bProcSet_ImageI = true; // CHANGED } else if (image.RawFormat.Equals(ImageFormat.Tiff) || image.RawFormat.Equals(ImageFormat.Jpeg)) { pdfPageData.bProcSet_ImageC = true; } else { Debug.Fail("unknown image type: send image to [email protected]"); } } #endif } else if (repObj is RepLine) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepRect) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepString) { FontProp fontProp_String = ((RepString)repObj).fontProp; PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp_String.fontPropData; if (pdfFontPropData.pdfIndirectObject_Font == null) { pdfFontPropData.pdfIndirectObject_Font = new PdfIndirectObject_Font(this, fontProp_String); } pdfPageData.RegisterFontProp(fontProp_String); pdfPageData.bProcSet_Text = true; } else { throw new ReportException("unknown report object type [" + repObj.GetType().FullName + "]"); } } }