Загрузить рисунок из файла в объект Pictureobject
Добрый день.
Помогите, пож-та, разобраться с загрузкой рисунка из файла в объект PictureObject.
Делаю следующим образом.
в событии Picture.beforeprint
{
System.IO.FileStream FlStream;
FlStream = System.IO.File.OpenRead(path); //путь к файлу
Picture1.Image = Image.FromStream(FlStream);
FlStream.Close();
}
в результате получаю следующую ошибку
FastReport.Net v1.2.33
A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at k7kRG0SmNYKZumjB0ga.9AWuFFSoGANPe5qjyNy.1VgQmqwbH(Image , Stream , ImageFormat )
at FastReport.PictureObject.Serialize(FRWriter writer)
at FastReport.Utils.FRWriter.Write(IFRSerializable obj, Object diff)
at FastReport.Utils.FRWriter.Write(IFRSerializable obj)
at VoZZJpyjW82vLT1CbbW.aLcXP1y3Mt7aAXSY0dM.ULeRjW6xX(Base , XmlItem )
at VoZZJpyjW82vLT1CbbW.aLcXP1y3Mt7aAXSY0dM.ULeRjW6xX(Base , XmlItem )
at VoZZJpyjW82vLT1CbbW.aLcXP1y3Mt7aAXSY0dM.VqIaD2V5V(BandBase )
at FastReport.Preview.PreparedPages.AddBand(BandBase band)
at FastReport.Engine.ReportEngine.VeQeNRfJg(BandBase )
at FastReport.Engine.ReportEngine.Vbk4NnlWt(BandBase , Boolean )
at FastReport.Engine.ReportEngine.xGnXtGwAV(BandBase , Boolean )
at FastReport.Engine.ReportEngine.ShowBand(BandBase band)
at FastReport.Engine.ReportEngine.1415dRF5D(DataBand , Int32 )
at FastReport.Engine.ReportEngine.WULGsALyQ(DataBand , Int32 , Boolean , Boolean , Boolean )
at FastReport.Engine.ReportEngine.SLmH9TXfZ(DataBand )
at FastReport.Engine.ReportEngine.vtkRlAIhJI(BandCollection )
at FastReport.Engine.ReportEngine.ZLYRpCUQpM(ReportPage )
at FastReport.Engine.ReportEngine.JNVRrRMomB()
at FastReport.Engine.ReportEngine.4NiuKUit3(Boolean , Boolean , ReportPage )
at FastReport.Engine.ReportEngine.PvcoyRnGd(Boolean , Boolean )
at FastReport.Report.Prepare(Boolean append)
at FastReport.Report.Prepare()
at qFGOGwZJ2h5cThhZeJA.VAssAkZK7nX0jP5uvvc.VdTCgELbW()
Спасибо.
Помогите, пож-та, разобраться с загрузкой рисунка из файла в объект PictureObject.
Делаю следующим образом.
в событии Picture.beforeprint
{
System.IO.FileStream FlStream;
FlStream = System.IO.File.OpenRead(path); //путь к файлу
Picture1.Image = Image.FromStream(FlStream);
FlStream.Close();
}
в результате получаю следующую ошибку
FastReport.Net v1.2.33
A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at k7kRG0SmNYKZumjB0ga.9AWuFFSoGANPe5qjyNy.1VgQmqwbH(Image , Stream , ImageFormat )
at FastReport.PictureObject.Serialize(FRWriter writer)
at FastReport.Utils.FRWriter.Write(IFRSerializable obj, Object diff)
at FastReport.Utils.FRWriter.Write(IFRSerializable obj)
at VoZZJpyjW82vLT1CbbW.aLcXP1y3Mt7aAXSY0dM.ULeRjW6xX(Base , XmlItem )
at VoZZJpyjW82vLT1CbbW.aLcXP1y3Mt7aAXSY0dM.ULeRjW6xX(Base , XmlItem )
at VoZZJpyjW82vLT1CbbW.aLcXP1y3Mt7aAXSY0dM.VqIaD2V5V(BandBase )
at FastReport.Preview.PreparedPages.AddBand(BandBase band)
at FastReport.Engine.ReportEngine.VeQeNRfJg(BandBase )
at FastReport.Engine.ReportEngine.Vbk4NnlWt(BandBase , Boolean )
at FastReport.Engine.ReportEngine.xGnXtGwAV(BandBase , Boolean )
at FastReport.Engine.ReportEngine.ShowBand(BandBase band)
at FastReport.Engine.ReportEngine.1415dRF5D(DataBand , Int32 )
at FastReport.Engine.ReportEngine.WULGsALyQ(DataBand , Int32 , Boolean , Boolean , Boolean )
at FastReport.Engine.ReportEngine.SLmH9TXfZ(DataBand )
at FastReport.Engine.ReportEngine.vtkRlAIhJI(BandCollection )
at FastReport.Engine.ReportEngine.ZLYRpCUQpM(ReportPage )
at FastReport.Engine.ReportEngine.JNVRrRMomB()
at FastReport.Engine.ReportEngine.4NiuKUit3(Boolean , Boolean , ReportPage )
at FastReport.Engine.ReportEngine.PvcoyRnGd(Boolean , Boolean )
at FastReport.Report.Prepare(Boolean append)
at FastReport.Report.Prepare()
at qFGOGwZJ2h5cThhZeJA.VAssAkZK7nX0jP5uvvc.VdTCgELbW()
Спасибо.
Комментарии
У .net Image есть особенность - при загрузке из файла, файл блокируется.
Поступить можно проще: укажите имя файла в св-ве PictureObject.ImageLocation:
Picture.beforeprint
{
Picture1.ImageLocation = path;
}