Class Brush

Class Brush

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

Lớp chổi cơ bản.

[JsonObject(MemberSerialization.OptIn)]
public abstract class Brush : DisposableObject, IDisposable

Kế thừa

objectDisposableObjectBrush

Kế thừa từ

HatchBrush, SolidBrush, TransformBrush

Triển khai

IDisposable

Thành viên kế thừa

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()

Các khối khởi tạo

Brush()

protected Brush()

Thuộc tính

Độ mờ

Lấy hoặc thiết lập độ mờ của chổi. Giá trị nên nằm trong khoảng từ 0 đến 1. Giá trị 0 có nghĩa là chổi hoàn toàn hiển thị, giá trị 1 có nghĩa là chổi hoàn toàn không trong suốt.

public float Opacity { get; set; }

Giá trị thuộc tính

float

Ví dụ

Ví dụ này sử dụng lớp Graphics để tạo các hình dạng nguyên thủy trên bề mặt Hình ảnh. Để minh họa hoạt động, ví dụ tạo một Hình ảnh mới ở định dạng PNG và vẽ các hình dạng nguyên thủy trên bề mặt Hình ảnh bằng các phương thức Vẽ được lớp Graphics cung cấp.```csharp [C#]

                                                                                                                                                                                                                                                            //Tạo một thể hiện của FileStream
                                                                                                                                                                                                                                                            using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.png", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                //Tạo một thể hiện của PngOptions và thiết lập các thuộc tính khác nhau
                                                                                                                                                                                                                                                                Aspose.Imaging.ImageOptions.PngOptions pngOptions = new Aspose.Imaging.ImageOptions.PngOptions();

                                                                                                                                                                                                                                                                //Thiết lập nguồn cho PngOptions
                                                                                                                                                                                                                                                                pngOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                                //Tạo một thể hiện của Hình ảnh 
                                                                                                                                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(pngOptions, 500, 500))
                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                    //Tạo và khởi tạo một thể hiện của lớp Graphics
                                                                                                                                                                                                                                                                    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                                                                                                                                                                                    //Xóa bề mặt Graphics
                                                                                                                                                                                                                                                                    graphics.Clear(Aspose.Imaging.Color.Wheat);

                                                                                                                                                                                                                                                                    //Vẽ một cung bằng cách chỉ định đối tượng Pen có màu đen, 
                                                                                                                                                                                                                                                                    //một hình chữ nhật bao quanh cung, góc bắt đầu và góc quét
                                                                                                                                                                                                                                                                    graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), new Aspose.Imaging.Rectangle(200, 200, 100, 200), 0, 300);

                                                                                                                                                                                                                                                                    //Vẽ một đường Bezier bằng cách chỉ định đối tượng Pen có màu xanh và các điểm tọa độ.
                                                                                                                                                                                                                                                                    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));

                                                                                                                                                                                                                                                                    //Vẽ một đường cong bằng cách chỉ định đối tượng Pen có màu xanh lá cây và một mảng các điểm
                                                                                                                                                                                                                                                                    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) });

                                                                                                                                                                                                                                                                    //Vẽ một hình elip bằng cách sử dụng đối tượng Pen và một hình chữ nhật bao quanh
                                                                                                                                                                                                                                                                    graphics.DrawEllipse(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Yellow, 2), new Aspose.Imaging.Rectangle(300, 300, 100, 100));

                                                                                                                                                                                                                                                                    //Vẽ một đường thẳng 
                                                                                                                                                                                                                                                                    graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Violet, 2), new Aspose.Imaging.Point(100, 100), new Aspose.Imaging.Point(200, 200));

                                                                                                                                                                                                                                                                    //Vẽ một đoạn bánh
                                                                                                                                                                                                                                                                    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);

                                                                                                                                                                                                                                                                    //Vẽ một đa giác bằng cách chỉ định đối tượng Pen có màu đỏ và một mảng các điểm
                                                                                                                                                                                                                                                                    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) });

                                                                                                                                                                                                                                                                    //Vẽ một hình chữ nhật
                                                                                                                                                                                                                                                                    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)));

                                                                                                                                                                                                                                                                    //Tạo một đối tượng SolidBrush và thiết lập các thuộc tính khác nhau
                                                                                                                                                                                                                                                                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
                                                                                                                                                                                                                                                                    brush.Color = Color.Purple;
                                                                                                                                                                                                                                                                    brush.Opacity = 100;

                                                                                                                                                                                                                                                                    //Vẽ một chuỗi sử dụng đối tượng SolidBrush và Font, tại một điểm cụ thể
                                                                                                                                                                                                                                                                    graphics.DrawString("Hình ảnh này được tạo bởi API Aspose.Imaging", new Aspose.Imaging.Font("Times New Roman", 16), brush, new Aspose.Imaging.PointF(50, 400));

                                                                                                                                                                                                                                                                    // lưu tất cả các thay đổi.
                                                                                                                                                                                                                                                                    image.Save();
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }

## Phương thức

### <a id="Aspose_Imaging_Brush_DeepClone"></a> DeepClone\(\)

Tạo một bản sao sâu mới của Aspose.Imaging.Brush hiện tại.

```csharp
public virtual Brush DeepClone()

Trả về

Brush

Một Aspose.Imaging.Brush mới là bản sao sâu của thể hiện Aspose.Imaging.Brush này.

Equals(object)

Kiểm tra xem các đối tượng có bằng nhau không.

public override bool Equals(object obj)

Tham số

obj object

Đối tượng khác.

Trả về

bool

Kết quả so sánh sự bằng nhau.

Equals(Brush)

Kiểm tra xem các đối tượng có bằng nhau không.

protected bool Equals(Brush other)

Tham số

other Brush

Đối tượng khác.

Trả về

bool

Kết quả so sánh sự bằng nhau.

GetHashCode()

Lấy mã băm của đối tượng hiện tại.

public override int GetHashCode()

Trả về

int

Mã băm.

 Tiếng Việt