Class FileCreateSource

Class FileCreateSource

Namespace: Aspose.Imaging.Sources
Assembly: Aspose.Imaging.dll (25.2.0)

Represents a file source for creation.

[JsonObject(MemberSerialization.OptIn)]
public sealed class FileCreateSource : FileSource

Inheritance

objectSourceFileSourceFileCreateSource

Inherited Members

FileSource.IsTemporal, Source.GetStreamContainer(), object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

FileCreateSource(string)

Initializes a new instance of the Aspose.Imaging.Sources.FileCreateSource class.

public FileCreateSource(string filePath)

Parameters

filePath string

The file path to create.

Examples

This example creates a new Image file at some disk location as specified by Source property of the BmpOptions instance. If second parameter is not passed to the constructor of FileCreateSource, then by default the file to be created has property IsTemporal set to True. With IsTemporal set to True, no file will be saved on disk at the end of execution.```csharp [C#]

                                                                                                                                                                                                                                                                                                                                                                        //Creates an instance of BmpOptions and set its various properties
                                                                                                                                                                                                                                                                                                                                                                        Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                                                                                                                                                                                                                                                                                        bmpOptions.BitsPerPixel = 24;

                                                                                                                                                                                                                                                                                                                                                                        //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
                                                                                                                                                                                                                                                                                                                                                                        //If second parameter is not passed, then by default the file has IsTemporal set to True
                                                                                                                                                                                                                                                                                                                                                                        bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\output.bmp");

                                                                                                                                                                                                                                                                                                                                                                        //Creates an instance of Image 
                                                                                                                                                                                                                                                                                                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                            //do some image processing
                                                                                                                                                                                                                                                                                                                                                                        }

### <a id="Aspose_Imaging_Sources_FileCreateSource__ctor_System_String_System_Boolean_"></a> FileCreateSource\(string, bool\)

Initializes a new instance of the Aspose.Imaging.Sources.FileCreateSource class.

```csharp
[JsonConstructor]
public FileCreateSource(string filePath, bool isTemporal)

Parameters

filePath string

The file path to create.

isTemporal bool

If set to true the created file will be temporal.

Examples

This example creates a new Image file at some disk location as specified by Source property of the BmpOptions instance. Several properties for BmpOptions instance are set before creating the actual image. Especially the Source property, that refers to the actual disk location in this case.```csharp [C#]

                                                                                                                                                                                                                                                                                                         //Create an instance of BmpOptions and set its various properties
                                                                                                                                                                                                                                                                                                         Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                                                                                                                                                                                                                         bmpOptions.BitsPerPixel = 24;

                                                                                                                                                                                                                                                                                                         //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
                                                                                                                                                                                                                                                                                                         //Second Boolean parameter determines if the file to be created IsTemporal or not
                                                                                                                                                                                                                                                                                                         bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\output.bmp", false);

                                                                                                                                                                                                                                                                                                         //Create an instance of Image and initialize it with instance of BmpOptions by calling Create method
                                                                                                                                                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                             //do some image processing

                                                                                                                                                                                                                                                                                                             // save all changes
                                                                                                                                                                                                                                                                                                             image.Save();
                                                                                                                                                                                                                                                                                                         }

## Properties

### <a id="Aspose_Imaging_Sources_FileCreateSource_FilePath"></a> FilePath

Gets the file path to create.

```csharp
[JsonProperty]
public string FilePath { get; }

Property Value

string

IsTemporal

Gets a value indicating whether file will be temporal.

[JsonProperty]
public override bool IsTemporal { get; }

Property Value

bool

Methods

GetStreamContainer()

Gets the stream container.

public override StreamContainer GetStreamContainer()

Returns

StreamContainer

the stream container.

Remarks

Use with caution. You will need to dispose the stream container after retrieval.