Class ImageOptionsBase

Class ImageOptionsBase

ชื่อพื้นที่: Aspose.Imaging การประกอบ: Aspose.Imaging.dll (25.4.0)

ตัวเลือกฐานภาพ

[JsonObject(MemberSerialization.OptIn)]
public abstract class ImageOptionsBase : DisposableObject, IDisposable, IHasXmpData, IHasMetadata, ICloneable

Inheritance

object DisposableObject ImageOptionsBase

Derived

BmpOptions , DicomOptions , DxfOptions , EpsOptions , GifOptions , Html5CanvasOptions , IcoOptions , Jpeg2000Options , JpegOptions , MetafileOptions , PdfOptions , PngOptions , PsdOptions , SvgOptions , TgaOptions , TiffOptions , VectorRasterizationOptions , WebPOptions

Implements

IDisposable , IHasXmpData , IHasMetadata , ICloneable

อนุญาโตตุลาการ

DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

ImageOptionsBase()

เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Imaging.ImageOptionsBase

[JsonConstructor]
protected ImageOptionsBase()

ImageOptionsBase(ImageOptionsBase)

เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Imaging.ImageOptionsBase

protected ImageOptionsBase(ImageOptionsBase imageOptions)

Parameters

imageOptions ImageOptionsBase

ตัวเลือกภาพ

ImageOptionsBase(Image)

เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Imaging.ImageOptionsBase

protected ImageOptionsBase(Image image)

Parameters

image Image

รูปภาพ

Properties

BufferSizeHint

รับหรือตั้งค่าตัวอักษรขนาดกระเป๋าที่กําหนดขนาดที่อนุญาตสูงสุดสําหรับกระเป๋าภายในทั้งหมด

public int BufferSizeHint { get; set; }

คุณสมบัติมูลค่า

int

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการตั้งค่าข้อ จํากัด ของหน่วยความจําเมื่อสร้างภาพ JPEG ใหม่ ข้อ จํากัด ของหน่วยความจําคือขนาดที่อนุญาตสูงสุด (ใน megabytes) สําหรับ buffers ภายในทั้งหมด

string dir = "c:\\aspose.imaging\\issues\\net\\3404\\";

                                                                                                                                                                                      // Setting a memory limit of 50 megabytes for target created image
                                                                                                                                                                                      Aspose.Imaging.ImageOptionsBase createOptions = new Aspose.Imaging.ImageOptions.JpegOptions
                                                                                                                                                                                      {
                                                                                                                                                                                          CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive,
                                                                                                                                                                                          BufferSizeHint = 50,
                                                                                                                                                                                          Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "createdFile.jpg", false),
                                                                                                                                                                                      };

                                                                                                                                                                                      using (var image = Aspose.Imaging.Image.Create(createOptions, 1000, 1000))
                                                                                                                                                                                      {
                                                                                                                                                                                          image.Save(); // save to same location
                                                                                                                                                                                      }

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการตั้งค่าข้อ จํากัด ของหน่วยความจําเมื่อสร้างภาพ PNG และวาดกราฟิกที่ซับซ้อนบนมัน ข้อ จํากัด ของหน่วยความจําคือขนาดที่อนุญาตสูงสุด (ใน megabytes) สําหรับ buffers ภายในทั้งหมด

string dir = "c:\\aspose.imaging\\issues\\net\\3383\\";

                                                                                                                                                                                                                    const int ImageSize = 2000;
                                                                                                                                                                                                                    Aspose.Imaging.ImageOptionsBase createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                                                                                    createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "graphics_simple.png", false);
                                                                                                                                                                                                                    createOptions.BufferSizeHint = 30; // Memory limit is 30 Mb

                                                                                                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(createOptions, ImageSize, ImageSize))
                                                                                                                                                                                                                    {
                                                                                                                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
                                                                                                                                                                                                                        // You can use any graphic operations here, all of them will be performed within the established memory limit
                                                                                                                                                                                                                        // For example:
                                                                                                                                                                                                                        graphics.Clear(Aspose.Imaging.Color.LightSkyBlue);
                                                                                                                                                                                                                        graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 3f), 0, 0, image.Width, image.Height);

                                                                                                                                                                                                                        image.Save();
                                                                                                                                                                                                                    }

                                                                                                                                                                                                                    // A large number of graphic operations are also supported:
                                                                                                                                                                                                                    const int OperationAreaSize = 10;
                                                                                                                                                                                                                    createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                                                                                    createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "graphics_complex.png", false);
                                                                                                                                                                                                                    createOptions.BufferSizeHint = 30; // Memory limit is 30 Mb

                                                                                                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(createOptions, ImageSize, ImageSize))
                                                                                                                                                                                                                    {
                                                                                                                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
                                                                                                                                                                                                                        graphics.BeginUpdate();
                                                                                                                                                                                                                        graphics.Clear(Aspose.Imaging.Color.LightSkyBlue);

                                                                                                                                                                                                                        int x, y;
                                                                                                                                                                                                                        int numberOfOperations = 0;
                                                                                                                                                                                                                        for (int column = 0; column * OperationAreaSize < ImageSize; column++)
                                                                                                                                                                                                                        {
                                                                                                                                                                                                                            for (int row = 0; row * OperationAreaSize < ImageSize; row++)
                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                x = column * OperationAreaSize;
                                                                                                                                                                                                                                y = row * OperationAreaSize;

                                                                                                                                                                                                                                bool reversed = (column + row) % 2 != 0;
                                                                                                                                                                                                                                if (reversed)
                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                    graphics.DrawLine(
                                                                                                                                                                                                                                        new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red),
                                                                                                                                                                                                                                        x + OperationAreaSize - 2,
                                                                                                                                                                                                                                        y,
                                                                                                                                                                                                                                        x,
                                                                                                                                                                                                                                        y + OperationAreaSize);
                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                else
                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                    graphics.DrawLine(
                                                                                                                                                                                                                                        new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red),
                                                                                                                                                                                                                                        x,
                                                                                                                                                                                                                                        y,
                                                                                                                                                                                                                                        x + OperationAreaSize - 2,
                                                                                                                                                                                                                                        y + OperationAreaSize);
                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                numberOfOperations++;
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        }

                                                                                                                                                                                                                        // About 40k operations will be applied here, while they do not take up too much memory 
                                                                                                                                                                                                                        // since they are already unloaded into the external file, and will be loaded from there one at a time
                                                                                                                                                                                                                        graphics.EndUpdate();

                                                                                                                                                                                                                        image.Save();
                                                                                                                                                                                                                    }

FullFrame

ได้รับหรือตั้งค่าค่าแสดงให้เห็นว่า [กรอบเต็ม]

[JsonProperty]
public bool FullFrame { get; set; }

คุณสมบัติมูลค่า

bool

KeepMetadata

ได้รับค่าใช้จ่ายในการเก็บข้อมูลรูปภาพต้นฉบับบนส่งออก

public bool KeepMetadata { get; set; }

คุณสมบัติมูลค่า

bool

MultiPageOptions

ตัวเลือกหลายหน้า

public MultiPageOptions MultiPageOptions { get; set; }

คุณสมบัติมูลค่า

MultiPageOptions

Palette

รับหรือตั้งค่าสีแพลตฟอร์ม

public virtual IColorPalette Palette { get; set; }

คุณสมบัติมูลค่า

IColorPalette

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการบีบอัดภาพ PNG โดยใช้สีที่ระบุด้วยแพลตฟอร์มที่ดีที่สุด

// Loads png image        
                                                                                                                 string  sourceFilePath="OriginalRings.png";
                                                                                                                 string  outputFilePath="OriginalRingsOutput.png";
                                                                                                                 using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(sourceFilePath))
                                                                                                             {
                                                                                                                 image.Save(outputFilePath, new Aspose.Imaging.ImageOptions.PngOptions()
                                                                                                                 {
                                                                                                                      Progressive = true,
                                                                                                                          // Use indexed color type
                                                                                                                      ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.IndexedColor,
                                                                                                                          // Use maximal compression
                                                                                                                      CompressionLevel = 9,
                                                                                                                   // Get the closest 8-bit color palette which covers as many pixels as possible, so that a palettized image
                                                                                                                      // is almost visually indistinguishable from a non-palletized one.
                                                                                                                      Palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette((Aspose.Imaging.RasterImage)image, 256, Aspose.Imaging.PaletteMiningMethod.Histogram)
                                                                                                                 });
                                                                                                             }
                                                                                                                 // The output file size should be significantly reduced

ตัวอย่างต่อไปนี้โหลดภาพ BMP และบันทึกมันกลับไปยัง BMP โดยใช้ตัวเลือกการบันทึกต่างๆ

string dir = "c:\\temp\\";

                                                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                       {
                                                                                                           Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                           // Create BmpOptions
                                                                                                           Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                           // Use 8 bits per pixel to reduce the size of the output image.
                                                                                                           saveOptions.BitsPerPixel = 8;

                                                                                                           // Set the closest 8-bit color palette which covers the maximal number of image pixels, so that a palettized image
                                                                                                           // is almost visually indistinguishable from a non-palletized one.
                                                                                                           saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette(rasterImage, 256);

                                                                                                           // Save without compression.
                                                                                                           // You can also use RLE-8 compression to reduce the size of the output image.
                                                                                                           saveOptions.Compression = Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb;

                                                                                                           // Set the horizontal and vertical resolution to 96 dpi.
                                                                                                           saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);

                                                                                                           image.Save(dir + "sample.bmpoptions.bmp", saveOptions);
                                                                                                       }

ตัวอย่างต่อไปนี้โหลดภาพ BMP และบันทึกเป็น JPEG โดยใช้ตัวเลือกการบันทึกต่างๆ

string dir = "c:\\temp\\";

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

ตัวอย่างต่อไปนี้จะสร้างภาพ BMP Grayscale แบบพลาสติกแล้วบันทึกไว้ในไฟล์

string dir = "c:\\temp\\";

                                                                                                      Aspose.Imaging.ImageOptions.BmpOptions createOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                      // Save to a file
                                                                                                      createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "output.palette8bit.bmp", false);

                                                                                                      // Use 8 bits per pixel to reduce the size of the output image.
                                                                                                      createOptions.BitsPerPixel = 8;

                                                                                                      // Set the standard 8-bit grayscale color palette which covers all grayscale colors.
                                                                                                      // If the processed image contains only grayscale colors, then its palettized version
                                                                                                      // is visually indistinguishable from a non-palletized one.
                                                                                                      createOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                      // Save without compression.
                                                                                                      // You can also use RLE-8 compression to reduce the size of the output image.
                                                                                                      createOptions.Compression = Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb;

                                                                                                      // Set the horizontal and vertical resolution to 96 dpi.
                                                                                                      createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);

                                                                                                      // Create a BMP image of 100 x 100 px and save it to a file.
                                                                                                      using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(createOptions, 100, 100))
                                                                                                      {
                                                                                                          Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                          Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                              new Aspose.Imaging.Point(0, 0),
                                                                                                              new Aspose.Imaging.Point(image.Width, image.Height),
                                                                                                              Aspose.Imaging.Color.Black,
                                                                                                              Aspose.Imaging.Color.White);

                                                                                                          // Fill the image with a grayscale gradient
                                                                                                          graphics.FillRectangle(gradientBrush, image.Bounds);

                                                                                                          image.Save();
                                                                                                      }

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการ palletize ภาพ BMP เพื่อลดขนาดการผลิต

// Create a BMP image 100 x 100 px.
                                                                                              using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
                                                                                              {
                                                                                                  // The linear gradient from the left-top to the right-bottom corner of the image.
                                                                                                  Aspose.Imaging.Brushes.LinearGradientBrush brush =
                                                                                                      new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                          new Aspose.Imaging.Point(0, 0),
                                                                                                          new Aspose.Imaging.Point(bmpImage.Width, bmpImage.Height),
                                                                                                          Aspose.Imaging.Color.Red,
                                                                                                          Aspose.Imaging.Color.Green);

                                                                                                  // Fill the entire image with the linear gradient brush.
                                                                                                  Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
                                                                                                  gr.FillRectangle(brush, bmpImage.Bounds);

                                                                                                  // Get the closest 8-bit color palette which covers as many pixels as possible, so that a palettized image
                                                                                                  // is almost visually indistinguishable from a non-palletized one.
                                                                                                  Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette(bmpImage, 256);

                                                                                                  // 8-bit palette contains at most 256 colors.
                                                                                                  Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                  saveOptions.Palette = palette;
                                                                                                  saveOptions.BitsPerPixel = 8;

                                                                                                  using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                  {
                                                                                                      bmpImage.Save(stream, saveOptions);
                                                                                                      System.Console.WriteLine("The palettized image size is {0} bytes.", stream.Length);
                                                                                                  }

                                                                                                  using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                  {
                                                                                                      bmpImage.Save(stream);
                                                                                                      System.Console.WriteLine("The non-palettized image size is {0} bytes.", stream.Length);
                                                                                                  }
                                                                                              }

                                                                                              // The output looks like this:
                                                                                              // The palettized image size is 11078 bytes.
                                                                                              // The non-palettized image size is 40054 bytes.

ProgressEventHandler

ได้รับหรือตั้งค่ากระบวนการกระบวนการ

[JsonProperty]
public ProgressEventHandler ProgressEventHandler { get; set; }

คุณสมบัติมูลค่า

ProgressEventHandler

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการพิมพ์ข้อมูลเกี่ยวกับเหตุการณ์การพัฒนาสําหรับการดําเนินงานโหลด / การส่งออก

public void Test3460()
                                                                                                                 {
                                                                                                                     string dir = "c:\\aspose.imaging\\net\\issues\\3460";
                                                                                                                     string fileName = System.IO.Path.Combine(dir, "big.png");

                                                                                                                     // Example of use of separate operation progress event handlers for load/export operations
                                                                                                                     using (var image = Aspose.Imaging.Image.Load(fileName, new Aspose.Imaging.LoadOptions { ProgressEventHandler = ProgressCallback }))
                                                                                                                     {
                                                                                                                         image.Save(fileName + ".psd",
                                                                                                                                    new Aspose.Imaging.ImageOptions.PsdOptions() { ProgressEventHandler = ExportProgressCallback });
                                                                                                                     }
                                                                                                                 }

                                                                                                                 private void ProgressCallback(Aspose.Imaging.ProgressManagement.ProgressEventHandlerInfo info)
                                                                                                                 {
                                                                                                                     System.Console.WriteLine("{0} : {1}/{2}", info.EventType, info.Value, info.MaxValue);
                                                                                                                 }

                                                                                                                 private void ExportProgressCallback(Aspose.Imaging.ProgressManagement.ProgressEventHandlerInfo info)
                                                                                                                 {
                                                                                                                     System.Console.WriteLine("Export event {0} : {1}/{2}", info.EventType, info.Value, info.MaxValue);
                                                                                                                 }

                                                                                                                 // The STDOUT log may look like this:
                                                                                                                 //Initialization : 1/4
                                                                                                                 //PreProcessing : 2/4
                                                                                                                 //Processing : 3/4
                                                                                                                 //Finalization : 4/4
                                                                                                                 //Export event Initialization : 1/4
                                                                                                                 //Export event PreProcessing : 2/4
                                                                                                                 //Export event Processing : 3/4
                                                                                                                 //Export event RelativeProgress : 1/1
                                                                                                                 //RelativeProgress : 1/1
                                                                                                                 //Export event Finalization : 4/4

ResolutionSettings

รับหรือตั้งค่าการแก้ปัญหา

public virtual ResolutionSetting ResolutionSettings { get; set; }

คุณสมบัติมูลค่า

ResolutionSetting

Examples

ตัวอย่างต่อไปนี้โหลดภาพ BMP และบันทึกมันกลับไปยัง BMP โดยใช้ตัวเลือกการบันทึกต่างๆ

string dir = "c:\\temp\\";

                                                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                       {
                                                                                                           Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                           // Create BmpOptions
                                                                                                           Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                           // Use 8 bits per pixel to reduce the size of the output image.
                                                                                                           saveOptions.BitsPerPixel = 8;

                                                                                                           // Set the closest 8-bit color palette which covers the maximal number of image pixels, so that a palettized image
                                                                                                           // is almost visually indistinguishable from a non-palletized one.
                                                                                                           saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette(rasterImage, 256);

                                                                                                           // Save without compression.
                                                                                                           // You can also use RLE-8 compression to reduce the size of the output image.
                                                                                                           saveOptions.Compression = Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb;

                                                                                                           // Set the horizontal and vertical resolution to 96 dpi.
                                                                                                           saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);

                                                                                                           image.Save(dir + "sample.bmpoptions.bmp", saveOptions);
                                                                                                       }

ตัวอย่างต่อไปนี้โหลดภาพ BMP และบันทึกเป็น JPEG โดยใช้ตัวเลือกการบันทึกต่างๆ

string dir = "c:\\temp\\";

                                                                                                   // Load a BMP image from a file.
                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Do some image processing.

                                                                                                       // Use additional options to specify the desired image parameters.
                                                                                                       Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                       // The number of bits per channel is 8.
                                                                                                       // When a palette is used, the color index is stored in the image data instead of the color itself.
                                                                                                       saveOptions.BitsPerChannel = 8;

                                                                                                       // Set the progressive type of compression.
                                                                                                       saveOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                       // Set the image quality. It is a value between 1 and 100.
                                                                                                       saveOptions.Quality = 100;

                                                                                                       // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                       saveOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                       saveOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                       // If the source image is colored, it will be converted to grayscaled.
                                                                                                       saveOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.Grayscale;

                                                                                                       // Use a palette to reduce the output size.
                                                                                                       saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                       image.Save(dir + "sample.palettized.jpg", saveOptions);
                                                                                                   }

ตัวอย่างต่อไปนี้จะสร้างภาพ BMP Grayscale แบบพลาสติกแล้วบันทึกไว้ในไฟล์

string dir = "c:\\temp\\";

                                                                                                      Aspose.Imaging.ImageOptions.BmpOptions createOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                      // Save to a file
                                                                                                      createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "output.palette8bit.bmp", false);

                                                                                                      // Use 8 bits per pixel to reduce the size of the output image.
                                                                                                      createOptions.BitsPerPixel = 8;

                                                                                                      // Set the standard 8-bit grayscale color palette which covers all grayscale colors.
                                                                                                      // If the processed image contains only grayscale colors, then its palettized version
                                                                                                      // is visually indistinguishable from a non-palletized one.
                                                                                                      createOptions.Palette = Aspose.Imaging.ColorPaletteHelper.Create8BitGrayscale(false);

                                                                                                      // Save without compression.
                                                                                                      // You can also use RLE-8 compression to reduce the size of the output image.
                                                                                                      createOptions.Compression = Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb;

                                                                                                      // Set the horizontal and vertical resolution to 96 dpi.
                                                                                                      createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);

                                                                                                      // Create a BMP image of 100 x 100 px and save it to a file.
                                                                                                      using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(createOptions, 100, 100))
                                                                                                      {
                                                                                                          Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                          Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                              new Aspose.Imaging.Point(0, 0),
                                                                                                              new Aspose.Imaging.Point(image.Width, image.Height),
                                                                                                              Aspose.Imaging.Color.Black,
                                                                                                              Aspose.Imaging.Color.White);

                                                                                                          // Fill the image with a grayscale gradient
                                                                                                          graphics.FillRectangle(gradientBrush, image.Bounds);

                                                                                                          image.Save();
                                                                                                      }

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการสร้างภาพ JPEG ของขนาดที่ระบุด้วยพารามิเตอร์ที่ระบุ

string dir = "c:\\temp\\";

                                                                                                                    // Create a JPEG image of 100x100 px.
                                                                                                                    // Use additional options to specify the desired image parameters.
                                                                                                                    Aspose.Imaging.ImageOptions.JpegOptions createOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

                                                                                                                    // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly.
                                                                                                                    createOptions.BitsPerChannel = 8;

                                                                                                                    // Set the progressive type of compression.
                                                                                                                    createOptions.CompressionType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionMode.Progressive;

                                                                                                                    // Set the image quality. It is a value between 1 and 100.
                                                                                                                    createOptions.Quality = 100;

                                                                                                                    // Set the horizontal/vertical resolution to 96 dots per inch.
                                                                                                                    createOptions.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(96.0, 96.0);
                                                                                                                    createOptions.ResolutionUnit = Aspose.Imaging.ResolutionUnit.Inch;

                                                                                                                    // This is a standard option for JPEG images.
                                                                                                                    // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed.
                                                                                                                    createOptions.ColorType = Aspose.Imaging.FileFormats.Jpeg.JpegCompressionColorMode.YCbCr;

                                                                                                                    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(createOptions, 100, 100))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(jpegImage);

                                                                                                                        Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                            new Aspose.Imaging.Point(jpegImage.Width, jpegImage.Height),
                                                                                                                            Aspose.Imaging.Color.Yellow,
                                                                                                                            Aspose.Imaging.Color.Blue);

                                                                                                                        // Fill the image with a grayscale gradient
                                                                                                                        graphics.FillRectangle(gradientBrush, jpegImage.Bounds);

                                                                                                                        // Save to a file.
                                                                                                                        jpegImage.Save(dir + "output.explicitoptions.jpg");
                                                                                                                    }

Source

รับหรือตั้งค่าแหล่งเพื่อสร้างภาพ

public Source Source { get; set; }

คุณสมบัติมูลค่า

Source

VectorRasterizationOptions

รับหรือตั้งค่าตัวเลือกการเรสเตอร์ vector

public VectorRasterizationOptions VectorRasterizationOptions { get; set; }

คุณสมบัติมูลค่า

VectorRasterizationOptions

XmpData

รับหรือตั้งค่าคอนเทนเนอร์ metadata XMP

[JsonProperty]
public virtual XmpPacketWrapper XmpData { get; set; }

คุณสมบัติมูลค่า

XmpPacketWrapper

Methods

Clone()

สร้างคลอนของตัวอย่างนี้

public virtual ImageOptionsBase Clone()

Returns

ImageOptionsBase

คลอนสมาชิกของสถานการณ์นี้

ReleaseManagedResources()

เปิดตัวทรัพยากรที่จัดการ ตรวจสอบให้แน่ใจว่าไม่มีทรัพยากรที่ไม่ได้จัดการจะเปิดตัวที่นี่เนื่องจากอาจมีการเปิดตัวแล้ว

protected override void ReleaseManagedResources()
 แบบไทย