本文整理汇总了C#中System.IO.FileInfo.LoadAs_Image方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.LoadAs_Image方法的具体用法?C# FileInfo.LoadAs_Image怎么用?C# FileInfo.LoadAs_Image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.LoadAs_Image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadPictureBytes
public byte [] LoadPictureBytes(String NameID)
{
String Extension = VirtualPathUtility.GetExtension( NameID).Replace(".", "").ToLower( );
if (Extension == "jpg")
{
ContentType = "image/jpeg";
if ((Path.IsPathRooted(NameID))
|| (NameID.StartsWith("\\\\")))
{
FileInfo fileInfo = new FileInfo(NameID);
if (fileInfo.Exists)
return fileInfo.LoadAs_Image().ConvertTo_JpgByteArray();
}
return Data.DbServer3.Blob.MaterialienJPG.FindOrLoad_Short_ByNameID(NameID).Value;
}
else
if (Extension == "png")
{
ContentType = "image/png";
return Data.DbServer3.Blob.MaterialienPNG.FindOrLoad_ByNameID(NameID).Value;
}
ContentType = "text/plain";
String FileName = Data.DbServer3.WordUp.Materialien.FindOrLoad_ByNameID(NameID).LastAssignedFilePath;
BinaryReader BinReader = new BinaryReader(File.Open(FileName,
FileMode.Open, FileAccess.Read, FileShare.Read));
byte[] Content = BinReader.BaseStream.ToByteArray((int) BinReader.BaseStream.Length);
BinReader.Close();
return Content;
}
示例2: GatherImage
/// <summary>Opens the dialog to gather an image.</summary>
public static BitmapSource GatherImage(this OpenFileDialog ofd)
{
ofd.Filter = "Bilder|*.png;*.jpg;*.gif;*.bmp;*.tiff;*.wmp";
ofd.CheckFileExists = true;
ofd.Multiselect = false;
var result = ofd.ShowDialog(Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive));
if (result != true)
return null;
var fi = new FileInfo(ofd.FileName);
if (!fi.Exists)
return null;
return fi.LoadAs_Image();
}
示例3: CreatePictureInformationForOneEntry
public void CreatePictureInformationForOneEntry (InformationenSource Source, Guid TypID)
{
Source.InformationToProcess = Data.DbServer3.AltErlaaInfo.CreateNewInformation(TypID, UserName);
Source.InformationToProcess.Titel = NameForThisCollection;
Source.InformationToProcess.BearbeitungsHinweis = "Fertig";
if (Source.ConnectedBildDaten.Count > 1)
{
int GenerationIndex = 1;
InformationAddOn StartSibling = null;
foreach (InformationAddOn Entry in Source.InformationToProcess.InformationenAddOns)
{
if (Entry.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.StandBildMaterialRoot) //Guid.Parse("1186353e-c896-43e4-9921-f976d3a91e95")) // WerbungMaterial
{
StartSibling = Entry;
break;
}
}
if (StartSibling != null)
while (GenerationIndex < Source.ConnectedBildDaten.Count)
{
StartSibling = Data.DbServer3.AltErlaaInfo.InformationenAddOns.InsertNewSibling (StartSibling);
GenerationIndex++;
}
}
List<InformationAddOn> materialInformationAddOns = new List<InformationAddOn>();
foreach (InformationAddOn DefinedMaterialEntry in Source.InformationToProcess.InformationenAddOns)
if (DefinedMaterialEntry.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.StandBildMaterialRoot)
materialInformationAddOns.Add(DefinedMaterialEntry);
int ConnectedBildDatenToProcess = 0;
String OrganisationenNameID = String.Empty;
DbEntities.dbserver3.alterlaainfo.rows.ProcessConnector NewStandBildConnector = null;
Timing NewStandBildAnzTiming = null;
foreach (InformationAddOn InfoAddOn in Source.InformationToProcess.InformationenAddOns)
{
if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.AuftraggeberFirmaRoot) // Guid.Parse("c4194cab-b13d-4207-a945-f37f59ec8146")) // Auftraggeber(Firma)
{
InfoAddOn.Tabelle = "Organisationen";
InfoAddOn.TabelleId = Source.OrganisationToProcess.Id;
InfoAddOn.FreiText = Source.OrganisationToProcess.FreiText;
OrganisationenNameID = Source.OrganisationToProcess.NameId;
if (String.IsNullOrEmpty(Source.InformationToProcess.Titel))
{
Source.InformationToProcess.Titel = Source.OrganisationToProcess.Name;
}
else
{
Source.InformationToProcess.Titel += " - " + Source.OrganisationToProcess.Name;
}
if (String.IsNullOrEmpty(Source.InformationToProcess.NameId))
Source.InformationToProcess.NameId = Basics.ConvertToCorrectFileNameElement
(NameForThisCollection + "_" + OrganisationenNameID).Replace(" ", "");
continue;
}
if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.StandBildMaterialRoot) //Guid.Parse("1186353e-c896-43e4-9921-f976d3a91e95")) // WerbungMaterial
{
Material NewMaterial = InfoAddOn.GetOrCreate_ConnectedMaterial();
String NameID = String.Format("{0}_{1}_Seite{2:D1}_Bild1",
NameForThisCollection, OrganisationenNameID, ConnectedBildDatenToProcess + 1);
NewMaterial.NameId = NameID;
NewMaterial.SubEntryId = String.Format("Seite{0:D1}_Bild1",
ConnectedBildDatenToProcess + 1);
NewMaterial.OriginalMaterialName = Source.ConnectedBildDaten [ConnectedBildDatenToProcess].BildDatenSource;
FileInfo pictureFileInfo = new FileInfo(NewMaterial.OriginalMaterialName);
if (pictureFileInfo.Exists)
{
NewMaterial.BlobContent = pictureFileInfo.LoadAs_Image().ConvertTo_JpgByteArray();
NewMaterial.BlobLength = (int) NewMaterial.BlobContent.Length;
}
NewMaterial.ModifyTimeStamp = DateTime.Now;
NewMaterial.NameId = Path.GetFileNameWithoutExtension (NewMaterial.OriginalMaterialName);
NewMaterial.Typ = Path.GetExtension (NewMaterial.OriginalMaterialName).Replace (".", "").ToUpper( );
NewMaterial.OriginalMaterialName = Path.GetFileNameWithoutExtension(NewMaterial.OriginalMaterialName);
InfoAddOn.FreiText = NewMaterial.FreiText;
InfoAddOn.TechnicalAddOn = "BackGround(" + NewMaterial.MaterialLink + ")";
ConnectedBildDatenToProcess++;
continue;
}
if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.ConnectorStandBildRoot) // Guid.Parse("d48e159b-a985-4c23-8d8c-0fc75852a79d")) // WerbungMultiMedia
{
NewStandBildConnector = InfoAddOn.GetOrCreate_ConnectedProcessConnector();
NewStandBildConnector.TableName = SelectedTableDefinitionToCreate.TableName;
NewStandBildConnector.Redaktion = "StandBild";
NewStandBildConnector.ConnectionStringName = "WPMediaAddOnDataConnectionString";
NewStandBildConnector.NameId = Basics.ConvertToCorrectFileNameElement(Source.InformationToProcess.Titel);
NewStandBildConnector.TemplateId = DbBasics.TemplateBildOnlyGuidId;
continue;
}
if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.AktivVonBisRoot) //Guid.Parse("2b854b0a-b2f3-46e9-b273-79fd1568ac07")) // AktivZeitVonBis
{
Timing NewTiming = InfoAddOn.GetOrCreate_ConnectedTiming();
NewTiming.ConnectedType = "Informationen";
NewTiming.TimingTypId = "AktivVonBis";
//NewTiming.TimeA = Source.Von;
//NewTiming.TimeB = Source.Bis;
//.........这里部分代码省略.........
示例4: foreach
public static void LoadPersonenPictures
(List<Guid> InformationenIDs, ref DbEntities.CustomClasses.StandardModelle.CommonSearchClass SelectedEntry)
{
String PictureRoot = "\\\\master4\\Daten\\Bilder Hausschirm\\Wohnpark\\KAE\\AV\\Personen";
foreach (Person person in Data.DbServer3.AltErlaaInfo.Personen.Load_WithFilledMaterialConnector())
{
String MaterialConnector = person.MaterialConnector;
if (String.IsNullOrEmpty(MaterialConnector))
continue;
String[] Elemente = MaterialConnector.Split(',');
if (Elemente.Length < 5)
continue;
Guid MaterialID = Guid.Parse(Elemente[2]);
Material material = Data.DbServer3.AltErlaaInfo.Materialien.FindOrLoad(MaterialID);
if (material == null)
{
material = Data.DbServer3.AltErlaaInfo.Materialien.NewRow();
material.Id = MaterialID;
material.NameId = person.Name + " " + person.Vorname;
Data.DbServer3.AltErlaaInfo.Materialien.Rows.Add(material);
}
String PictureFileName = Path.Combine(PictureRoot, person.Vorname + " " + person.Name + ".png");
FileInfo fileInfo = new FileInfo(PictureFileName);
if (!fileInfo.Exists)
continue;
material.OriginalMaterialName = PictureFileName;
material.BlobLength = (int?) fileInfo.Length;
material.BlobContent = fileInfo.LoadAs_Image().ConvertTo_PngByteArray();
}
Data.DbServer3.AltErlaaInfo.SaveAnabolic(new Object());
Data.DbServer3.AltErlaaInfo.AcceptChanges();
}