- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
[C#] Hướng dẫn chỉnh sửa ánh sáng (Brightness) hình ảnh
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục chia sẽ đến các bạn đoạn source code dùng để chỉnh sửa ánh sáng của hình ảnh (Brightness Image c#).
Dưới đây là giao diện dùng để chỉnh ánh sáng cho hình ảnh trong Winform C#.
Source code adjust Brightness c#:
private Bitmap AdjustBrightness(Image image, float brightness)
{
// Make the ColorMatrix.
float b = brightness;
ColorMatrix cm = new ColorMatrix(new float[][]
{
new float[] {b, 0, 0, 0, 0},
new float[] {0, b, 0, 0, 0},
new float[] {0, 0, b, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1},
});
ImageAttributes attributes = new ImageAttributes();
attributes.SetColorMatrix(cm);
// Draw the image onto the new bitmap while applying
// the new ColorMatrix.
Point[] points =
{
new Point(0, 0),
new Point(image.Width, 0),
new Point(0, image.Height),
};
Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
// Make the result bitmap.
Bitmap bm = new Bitmap(image.Width, image.Height);
using (Graphics gr = Graphics.FromImage(bm))
{
gr.DrawImage(image, points, rect,
GraphicsUnit.Pixel, attributes);
}
// Return the result.
return bm;
}
HAVE FUN :)