Class SolidBrush

Class SolidBrush

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

แปรงแบบเต็มมีวัตถุประสงค์เพื่อการวาดอย่างต่อเนื่องด้วยสีเฉพาะ คลาสนี้ไม่สามารถสืบทอดได้

public sealed class SolidBrush : Brush, IDisposable

การสืบทอด

objectDisposableObjectBrushSolidBrush

การนำไปใช้

IDisposable

สมาชิกที่สืบทอด

Brush.DeepClone(), Brush.Equals(object), Brush.GetHashCode(), Brush.Opacity, DisposableObject.Dispose(), DisposableObject.Disposed, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

ตัวอย่าง

ตัวอย่างนี้ใช้คลาส Graphics เพื่อสร้างรูปทรงพื้นฐานบนพื้นผิวของภาพ เพื่อแสดงการทำงาน ตัวอย่างนี้สร้างภาพใหม่ในรูปแบบ PNG และวาดรูปทรงพื้นฐานบนพื้นผิวของภาพโดยใช้วิธีการ Draw ที่เปิดเผยโดยคลาส Graphics```csharp [C#]

                                                                                                                                                                                                                                                            //สร้างอินสแตนซ์ของ FileStream
                                                                                                                                                                                                                                                            using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.png", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                //สร้างอินสแตนซ์ของ PngOptions และตั้งค่าคุณสมบัติต่างๆ
                                                                                                                                                                                                                                                                Aspose.Imaging.ImageOptions.PngOptions pngOptions = new Aspose.Imaging.ImageOptions.PngOptions();

                                                                                                                                                                                                                                                                //ตั้งค่าแหล่งที่มาสำหรับ PngOptions
                                                                                                                                                                                                                                                                pngOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                                //สร้างอินสแตนซ์ของภาพ 
                                                                                                                                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(pngOptions, 500, 500))
                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                    //สร้างและเริ่มต้นอินสแตนซ์ของคลาส Graphics
                                                                                                                                                                                                                                                                    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                                                                                                                                                                                    //ล้างพื้นผิว Graphics
                                                                                                                                                                                                                                                                    graphics.Clear(Aspose.Imaging.Color.Wheat);

                                                                                                                                                                                                                                                                    //วาด Arc โดยระบุวัตถุ Pen ที่มีสีดำ, 
                                                                                                                                                                                                                                                                    //รูปสี่เหลี่ยมผืนผ้ารอบ Arc, มุมเริ่มต้นและมุม Sweep
                                                                                                                                                                                                                                                                    graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), new Aspose.Imaging.Rectangle(200, 200, 100, 200), 0, 300);

                                                                                                                                                                                                                                                                    //วาด Bezier โดยระบุวัตถุ Pen ที่มีสีน้ำเงินและจุดพิกัด
                                                                                                                                                                                                                                                                    graphics.DrawBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Point(250, 100), new Aspose.Imaging.Point(300, 30), new Aspose.Imaging.Point(450, 100), new Aspose.Imaging.Point(235, 25));

                                                                                                                                                                                                                                                                    //วาด Curve โดยระบุวัตถุ Pen ที่มีสีเขียวและอาร์เรย์ของจุด
                                                                                                                                                                                                                                                                    graphics.DrawCurve(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new[] { new Aspose.Imaging.Point(100, 200), new Aspose.Imaging.Point(100, 350), new Aspose.Imaging.Point(200, 450) });

                                                                                                                                                                                                                                                                    //วาด Ellipse โดยใช้วัตถุ Pen และรูปสี่เหลี่ยมผืนผ้ารอบ
                                                                                                                                                                                                                                                                    graphics.DrawEllipse(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Yellow, 2), new Aspose.Imaging.Rectangle(300, 300, 100, 100));

                                                                                                                                                                                                                                                                    //วาดเส้น 
                                                                                                                                                                                                                                                                    graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Violet, 2), new Aspose.Imaging.Point(100, 100), new Aspose.Imaging.Point(200, 200));

                                                                                                                                                                                                                                                                    //วาด Pie segment
                                                                                                                                                                                                                                                                    graphics.DrawPie(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Silver, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(200, 20), new Aspose.Imaging.Size(200, 200)), 0, 45);

                                                                                                                                                                                                                                                                    //วาด Polygon โดยระบุวัตถุ Pen ที่มีสีแดงและอาร์เรย์ของจุด
                                                                                                                                                                                                                                                                    graphics.DrawPolygon(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2), new[] { new Aspose.Imaging.Point(20, 100), new Aspose.Imaging.Point(20, 200), new Aspose.Imaging.Point(220, 20) });

                                                                                                                                                                                                                                                                    //วาดรูปสี่เหลี่ยม
                                                                                                                                                                                                                                                                    graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(250, 250), new Aspose.Imaging.Size(100, 100)));

                                                                                                                                                                                                                                                                    //สร้างวัตถุ SolidBrush และตั้งค่าคุณสมบัติต่างๆ
                                                                                                                                                                                                                                                                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
                                                                                                                                                                                                                                                                    brush.Color = Color.Purple;
                                                                                                                                                                                                                                                                    brush.Opacity = 100;

                                                                                                                                                                                                                                                                    //วาดข้อความโดยใช้วัตถุ SolidBrush และฟอนต์ ที่จุดเฉพาะ
                                                                                                                                                                                                                                                                    graphics.DrawString("ภาพนี้ถูกสร้างโดย Aspose.Imaging API", new Aspose.Imaging.Font("Times New Roman", 16), brush, new Aspose.Imaging.PointF(50, 400));

                                                                                                                                                                                                                                                                    //บันทึกการเปลี่ยนแปลงทั้งหมด
                                                                                                                                                                                                                                                                    image.Save();
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }

## ตัวสร้าง

### <a id="Aspose_Imaging_Brushes_SolidBrush__ctor"></a> SolidBrush\(\)

เริ่มต้นอินสแตนซ์ใหม่ของคลาส Aspose.Imaging.Brushes.SolidBrush

```csharp
public SolidBrush()

ตัวอย่าง

ตัวอย่างนี้ใช้คลาส Graphics เพื่อสร้างรูปทรงพื้นฐานบนพื้นผิวของภาพ เพื่อแสดงการทำงาน ตัวอย่างนี้สร้างภาพใหม่ในรูปแบบ PNG และวาดรูปทรงพื้นฐานบนพื้นผิวของภาพโดยใช้วิธีการ Draw ที่เปิดเผยโดยคลาส Graphics```csharp [C#]

                                                                                                                                                                                                                                                            //สร้างอินสแตนซ์ของ FileStream
                                                                                                                                                                                                                                                            using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.png", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                //สร้างอินสแตนซ์ของ PngOptions และตั้งค่าคุณสมบัติต่างๆ
                                                                                                                                                                                                                                                                Aspose.Imaging.ImageOptions.PngOptions pngOptions = new Aspose.Imaging.ImageOptions.PngOptions();

                                                                                                                                                                                                                                                                //ตั้งค่าแหล่งที่มาสำหรับ PngOptions
                                                                                                                                                                                                                                                                pngOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                                //สร้างอินสแตนซ์ของภาพ 
                                                                                                                                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(pngOptions, 500, 500))
                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                    //สร้างและเริ่มต้นอินสแตนซ์ของคลาส Graphics
                                                                                                                                                                                                                                                                    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                                                                                                                                                                                    //ล้างพื้นผิว Graphics
                                                                                                                                                                                                                                                                    graphics.Clear(Aspose.Imaging.Color.Wheat);

                                                                                                                                                                                                                                                                    //วาด Arc โดยระบุวัตถุ Pen ที่มีสีดำ, 
                                                                                                                                                                                                                                                                    //รูปสี่เหลี่ยมผืนผ้ารอบ Arc, มุมเริ่มต้นและมุม Sweep
                                                                                                                                                                                                                                                                    graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), new Aspose.Imaging.Rectangle(200, 200, 100, 200), 0, 300);

                                                                                                                                                                                                                                                                    //วาด Bezier โดยระบุวัตถุ Pen ที่มีสีน้ำเงินและจุดพิกัด
                                                                                                                                                                                                                                                                    graphics.DrawBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Point(250, 100), new Aspose.Imaging.Point(300, 30), new Aspose.Imaging.Point(450, 100), new Aspose.Imaging.Point(235, 25));

                                                                                                                                                                                                                                                                    //วาด Curve โดยระบุวัตถุ Pen ที่มีสีเขียวและอาร์เรย์ของจุด
                                                                                                                                                                                                                                                                    graphics.DrawCurve(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new[] { new Aspose.Imaging.Point(100, 200), new Aspose.Imaging.Point(100, 350), new Aspose.Imaging.Point(200, 450) });

                                                                                                                                                                                                                                                                    //วาด Ellipse โดยใช้วัตถุ Pen และรูปสี่เหลี่ยมผืนผ้ารอบ
                                                                                                                                                                                                                                                                    graphics.DrawEllipse(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Yellow, 2), new Aspose.Imaging.Rectangle(300, 300, 100, 100));

                                                                                                                                                                                                                                                                    //วาดเส้น 
                                                                                                                                                                                                                                                                    graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Violet, 2), new Aspose.Imaging.Point(100, 100), new Aspose.Imaging.Point(200, 200));

                                                                                                                                                                                                                                                                    //วาด Pie segment
                                                                                                                                                                                                                                                                    graphics.DrawPie(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Silver, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(200, 20), new Aspose.Imaging.Size(200, 200)), 0, 45);

                                                                                                                                                                                                                                                                    //วาด Polygon โดยระบุวัตถุ Pen ที่มีสีแดงและอาร์เรย์ของจุด
                                                                                                                                                                                                                                                                    graphics.DrawPolygon(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2), new[] { new Aspose.Imaging.Point(20, 100), new Aspose.Imaging.Point(20, 200), new Aspose.Imaging.Point(220, 20) });

                                                                                                                                                                                                                                                                    //วาดรูปสี่เหลี่ยม
                                                                                                                                                                                                                                                                    graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(250, 250), new Aspose.Imaging.Size(100, 100)));

                                                                                                                                                                                                                                                                    //สร้างวัตถุ SolidBrush และตั้งค่าคุณสมบัติต่างๆ
                                                                                                                                                                                                                                                                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
                                                                                                                                                                                                                                                                    brush.Color = Color.Purple;
                                                                                                                                                                                                                                                                    brush.Opacity = 100;

                                                                                                                                                                                                                                                                    //วาดข้อความโดยใช้วัตถุ SolidBrush และฟอนต์ ที่จุดเฉพาะ
                                                                                                                                                                                                                                                                    graphics.DrawString("ภาพนี้ถูกสร้างโดย Aspose.Imaging API", new Aspose.Imaging.Font("Times New Roman", 16), brush, new Aspose.Imaging.PointF(50, 400));

                                                                                                                                                                                                                                                                    //บันทึกการเปลี่ยนแปลงทั้งหมด
                                                                                                                                                                                                                                                                    image.Save();
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }

### <a id="Aspose_Imaging_Brushes_SolidBrush__ctor_Aspose_Imaging_Color_"></a> SolidBrush\(Color\)

เริ่มต้นอินสแตนซ์ใหม่ของคลาส Aspose.Imaging.Brushes.SolidBrush

```csharp
public SolidBrush(Color color)

พารามิเตอร์

color Color

สีของแปรงแบบเต็ม

คุณสมบัติ

Color

รับหรือกำหนดสีของแปรง

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

ค่าโปรperty

Color

ตัวอย่าง

ตัวอย่างนี้ใช้คลาส Graphics เพื่อสร้างรูปทรงพื้นฐานบนพื้นผิวของภาพ เพื่อแสดงการทำงาน ตัวอย่างนี้สร้างภาพใหม่ในรูปแบบ PNG และวาดรูปทรงพื้นฐานบนพื้นผิวของภาพโดยใช้วิธีการ Draw ที่เปิดเผยโดยคลาส Graphics```csharp [C#]

                                                                                                                                                                                                                                                            //สร้างอินสแตนซ์ของ FileStream
                                                                                                                                                                                                                                                            using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.png", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                //สร้างอินสแตนซ์ของ PngOptions และตั้งค่าคุณสมบัติต่างๆ
                                                                                                                                                                                                                                                                Aspose.Imaging.ImageOptions.PngOptions pngOptions = new Aspose.Imaging.ImageOptions.PngOptions();

                                                                                                                                                                                                                                                                //ตั้งค่าแหล่งที่มาสำหรับ PngOptions
                                                                                                                                                                                                                                                                pngOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                                //สร้างอินสแตนซ์ของภาพ 
                                                                                                                                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(pngOptions, 500, 500))
                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                    //สร้างและเริ่มต้นอินสแตนซ์ของคลาส Graphics
                                                                                                                                                                                                                                                                    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                                                                                                                                                                                    //ล้างพื้นผิว Graphics
                                                                                                                                                                                                                                                                    graphics.Clear(Aspose.Imaging.Color.Wheat);

                                                                                                                                                                                                                                                                    //วาด Arc โดยระบุวัตถุ Pen ที่มีสีดำ, 
                                                                                                                                                                                                                                                                    //รูปสี่เหลี่ยมผืนผ้ารอบ Arc, มุมเริ่มต้นและมุม Sweep
                                                                                                                                                                                                                                                                    graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), new Aspose.Imaging.Rectangle(200, 200, 100, 200), 0, 300);

                                                                                                                                                                                                                                                                    //วาด Bezier โดยระบุวัตถุ Pen ที่มีสีน้ำเงินและจุดพิกัด
                                                                                                                                                                                                                                                                    graphics.DrawBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Point(250, 100), new Aspose.Imaging.Point(300, 30), new Aspose.Imaging.Point(450, 100), new Aspose.Imaging.Point(235, 25));

                                                                                                                                                                                                                                                                    //วาด Curve โดยระบุวัตถุ Pen ที่มีสีเขียวและอาร์เรย์ของจุด
                                                                                                                                                                                                                                                                    graphics.DrawCurve(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new[] { new Aspose.Imaging.Point(100, 200), new Aspose.Imaging.Point(100, 350), new Aspose.Imaging.Point(200, 450) });

                                                                                                                                                                                                                                                                    //วาด Ellipse โดยใช้วัตถุ Pen และรูปสี่เหลี่ยมผืนผ้ารอบ
                                                                                                                                                                                                                                                                    graphics.DrawEllipse(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Yellow, 2), new Aspose.Imaging.Rectangle(300, 300, 100, 100));

                                                                                                                                                                                                                                                                    //วาดเส้น 
                                                                                                                                                                                                                                                                    graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Violet, 2), new Aspose.Imaging.Point(100, 100), new Aspose.Imaging.Point(200, 200));

                                                                                                                                                                                                                                                                    //วาด Pie segment
                                                                                                                                                                                                                                                                    graphics.DrawPie(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Silver, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(200, 20), new Aspose.Imaging.Size(200, 200)), 0, 45);

                                                                                                                                                                                                                                                                    //วาด Polygon โดยระบุวัตถุ Pen ที่มีสีแดงและอาร์เรย์ของจุด
                                                                                                                                                                                                                                                                    graphics.DrawPolygon(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2), new[] { new Aspose.Imaging.Point(20, 100), new Aspose.Imaging.Point(20, 200), new Aspose.Imaging.Point(220, 20) });

                                                                                                                                                                                                                                                                    //วาดรูปสี่เหลี่ยม
                                                                                                                                                                                                                                                                    graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(250, 250), new Aspose.Imaging.Size(100, 100)));

                                                                                                                                                                                                                                                                    //สร้างวัตถุ SolidBrush และตั้งค่าคุณสมบัติต่างๆ
                                                                                                                                                                                                                                                                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
                                                                                                                                                                                                                                                                    brush.Color = Color.Purple;
                                                                                                                                                                                                                                                                    brush.Opacity = 100;

                                                                                                                                                                                                                                                                    //วาดข้อความโดยใช้วัตถุ SolidBrush และฟอนต์ ที่จุดเฉพาะ
                                                                                                                                                                                                                                                                    graphics.DrawString("ภาพนี้ถูกสร้างโดย Aspose.Imaging API", new Aspose.Imaging.Font("Times New Roman", 16), brush, new Aspose.Imaging.PointF(50, 400));

                                                                                                                                                                                                                                                                    //บันทึกการเปลี่ยนแปลงทั้งหมด
                                                                                                                                                                                                                                                                    image.Save();
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }
 แบบไทย