Class Cache
nazivni prostor: Aspose.Imaging Sastav: Aspose.Imaging.dll (25.4.0)
Sadrži cache postavke.
public static class Cache
Inheritance
naslijeđeni članovi
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Ovaj primjer pokazuje korištenje 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
Prihvatite broj dodijeljenih bajtova diska.
public static long AllocatedDiskBytesCount { get; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje korištenje 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
Dobiva broj dodijeljenih in-memory bajtova.
public static long AllocatedMemoryBytesCount { get; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje korištenje 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
Pronađite ili postavite cache folder.
public static string CacheFolder { get; set; }
Vrijednost nekretnina
CacheType
Pronađite ili postavite upotrijebljenu cache shemu.
public static CacheType CacheType { get; set; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje korištenje 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
Dobiva ili postavlja vrijednost koja ukazuje na to treba li ponovna raspodjela biti točna ili ne. Ako ponovna raspodjela nije točna, performansa bi trebala biti veća.
public static bool ExactReallocateOnly { get; set; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje korištenje 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
Točna ponovna raspodjela obavlja ponovnu raspodjelu dodatne memorije samo do gore navedene granice.Prolazeći gornji ograničenje za memoriju tijekom ponovnog dodjele, prikupljeni podaci će se kopirati na disk ako je to moguće.Prolazeći gornji ograničenje za memoriju diska tijekom ponovnog dodjele, ispušta se odgovarajuća iznimka.Učinkovitost bi trebala biti veća ako se ova opcija isključi jer ako je moguće, neće biti izvršena dodatna kopija.Međutim, to također može dovesti do prekoračenja gornjih granica određenih za memoriju ili disk.
MaxDiskSpaceForCache
Pronađite ili postavite maksimalni raspoloživ prostor na disku za cache.Vrijednost određena je brojanje megabita.
public static int MaxDiskSpaceForCache { get; set; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje korištenje 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
Vrijednost 0 će potrošiti svu dostupnu memoriju i služi kao bez gornjeg ograničenja.
MaxMemoryForCache
Dobiva ili postavlja maksimalnu raspoloživu memoriju za cache u memoriji.
public static int MaxMemoryForCache { get; set; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje korištenje 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
Vrijednost 0 će potrošiti svu dostupnu memoriju i služi kao bez gornjeg ograničenja.
Methods
SetDefaults()
Sastavite Aspose.Imaging.Cache postavke na podrazumevane.
public static void SetDefaults()