Class Cache
De naam: Aspose.Imaging Verzameling: Aspose.Imaging.dll (25.5.0)
Inhoudt cache instellingen.
public static class CacheInheritance
Geëerbiede leden
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;Properties
AllocatedDiskBytesCount
Geeft de toegewezen schijf byten tellen.
public static long AllocatedDiskBytesCount { get; }Eigendomswaarde
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;AllocatedMemoryBytesCount
Geeft de toegewezen in-memory bytes te tellen.
public static long AllocatedMemoryBytesCount { get; }Eigendomswaarde
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;CacheFolder
Krijg of zet de cache map.
public static string CacheFolder { get; set; }Eigendomswaarde
CacheType
Geeft of zet het gebruikte cache-schema.
public static CacheType CacheType { get; set; }Eigendomswaarde
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;ExactReallocateOnly
Geeft of stelt een waarde die aangeeft of de herverdeling nauwkeurig moet zijn of niet. Als de herverdeling nauwkeurig is, moet de prestatie hoger zijn.
public static bool ExactReallocateOnly { get; set; }Eigendomswaarde
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;Remarks
De exacte herverdeling zal de herverdeling van extra geheugen alleen uitvoeren tot de bovengenoemde limiet.Bij het overschrijden van de bovenste limiet voor in-memory tijdens de herverdeling worden de cached-gegevens indien mogelijk gecopieerd naar de schijf.Bij het overschrijden van de bovenste limiet voor het schijfgeheugen tijdens de herverdeling wordt de juiste uitzondering gegooid.De prestaties moeten hoger zijn als deze optie wordt uitgeschakeld omdat geen extra kopiëring mogelijk zal worden uitgevoerd,Dit kan echter ook leiden tot het overschrijden van de bovengrenzen die voor het geheugen of de schijf zijn aangegeven.
MaxDiskSpaceForCache
Geeft of stelt de maximale beschikbare schijfruimte voor cache.De gedefinieerde waarde is het tellen van megabyte.
public static int MaxDiskSpaceForCache { get; set; }Eigendomswaarde
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;Remarks
De waarde van 0 verbruikt alle beschikbare geheugen en dient als geen bovengrens.
MaxMemoryForCache
Geeft of stelt het maximale beschikbare geheugen voor cache in het geheugen.
public static int MaxMemoryForCache { get; set; }Eigendomswaarde
Examples
Dit voorbeeld toont het gebruik van Aspose.Imaging.Cache
// By default the cache folder is set to user's local temp directory.
// You can also specify another cache folder than default like the following:
// Cache.CacheFolder = @"D:\\MyTemp";
// Auto mode is flexible and efficient
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// Default value is 0, which means there is no upper limit
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte
// It is not recommended to change the following property as it may greatly affect the performance
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// At any time you may check how many bytes currently allocated for memory or disk
// cache by examining the following properties
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// Do some image processing as below
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// after executing the code above there will be allocated 40000 bytes in-memory.
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// The allocation properties may be used to check whether all Aspose.Imaging objects were properly disposed.
// In case you've forgot to call dispose on some object the cache values will be different than 0.
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;Remarks
De waarde van 0 verbruikt alle beschikbare geheugen en dient als geen bovengrens.
Methods
SetDefaults()
Stel de Aspose.Imaging.Cache-instellingen op standaard.
public static void SetDefaults()