public final class FileCreateSource extends FileSource
Represents a file source for creation.
This example demonstrates the use of Font and SolidBrush class to draw strings on Image surface. The example creates a new Image and draw shapes using Figures and GraphicsPath
//Creates an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpOptions.setBitsPerPixel(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.setSource(new com.aspose.imaging.sources.FileCreateSource("C:\\temp\\sample.bmp", false)); //Creates an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpOptions, 500, 500); try { //Creates and initialize an instance of Graphics class com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); //Clears Graphics surface graphics.clear(com.aspose.imaging.Color.getWheat()); //Creates an instance of Font com.aspose.imaging.Font font = new com.aspose.imaging.Font("Times New Roman", 16); //Create an instance of SolidBrush having Red Color com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed()); //Draw a String graphics.drawString("Created by Aspose.Imaging for Java", font, brush, new com.aspose.imaging.PointF(100, 100)); // save all changes image.save(); } finally { image.dispose(); }
Constructor and Description |
---|
FileCreateSource(String filePath)
Initializes a new instance of the
FileCreateSource class. |
FileCreateSource(String filePath,
boolean isTemporal)
Initializes a new instance of the
FileCreateSource class. |
Modifier and Type | Method and Description |
---|---|
String |
getFilePath()
Gets the file path to create.
|
StreamContainer |
getStreamContainer()
Gets the stream container.
|
boolean |
isTemporal()
Gets a value indicating whether file will be temporal.
|
public FileCreateSource(String filePath)
Initializes a new instance of the FileCreateSource
class.
filePath
- The file path to create.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.
// Creates an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpOptions.setBitsPerPixel(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.setSource(new com.aspose.imaging.sources.FileCreateSource("C:\\temp\\output.bmp")); // Creates an instance of Image com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpOptions, 500, 500); try { // Do some image processing } finally { image.dispose(); }
public FileCreateSource(String filePath, boolean isTemporal)
Initializes a new instance of the FileCreateSource
class.
filePath
- The file path to create.isTemporal
- If set to true
the created file will be temporal.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.
// Create an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpOptions.setBitsPerPixel(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.setSource(new com.aspose.imaging.sources.FileCreateSource("C:\\temp\\sample.bmp", false)); // Create an instance of Image and initialize it with instance of BmpOptions by calling Create method com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpOptions, 500, 500); try { // Do some image processing // Save all changes image.save(); } finally { image.dispose(); }
public String getFilePath()
Gets the file path to create.
Value: The file path to create.public boolean isTemporal()
Gets a value indicating whether file will be temporal.
Value:true
if file will be temporal; otherwise, false
.isTemporal
in class FileSource
true
if file will be temporal; otherwise, false
.public StreamContainer getStreamContainer()
Gets the stream container.
getStreamContainer
in class Source
Use with caution. You will need to dispose the stream container after retrieval.