开发者

Delete pixel in a bitmap

Is there a way for me to delete a single pixel in a bitmap in C#? I already tried开发者_开发技巧 to look for a solution on the internet but I cant find one.


What exactly do you mean with "delete a pixel"? Bitmaps are (usually) rectangular grids of pixels with all of them having a defined value.

You can set the color of a single pixel by using SetPixel on a Bitmap object. This can be fully-transparent, too.


I don't think that is possible to "delete" a pixel, but you can set it to a specified color.

// Open your image
string path = "./path/to/your_image.bmp";
Bitmap img = (Bitmap)Bitmap.FromFile(path);

// Supporting variables
int x = 5;
int y = 5;
Color color = Color.Black;

// Actual operation
img.SetPixel(x, y, color);
img.Save(path);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜