❔ Drawing a Border Around Certain Parts of a Bitmap

Howdy there, So I'm currently building an application in AvaloniaUI and I am trying to add a functionality where on a displayed bitmap, if you click on an area with a specific color it gets selected and a border get's drawn around all regions of any color selected, even if they aren't contiguous (Attached images show how this works). The issue that I am currently running into is that iterating through the entire image and using getPixel(x,y) and setPixel(x,y, color) is too slow and results in a significant delay. What I'm wondering is if I there are any alternate approaches I can use. I am already using the class provided by the top response here https://stackoverflow.com/questions/24701703/c-sharp-faster-alternatives-to-setpixel-and-getpixel-for-bitmaps-for-windows-f and although it is faster, it is still very noticeably slow. Here is my current code: https://pastebin.com/n1M0mRLQ If there are any bad practices that I am currently employing then I would also appreciate them being pointed out. Some of the stuff here is a rather tad strange since I didn't know if I was going to keep this or if I was going to rewrite this. I am also considering redoing it in C++ and/or instead keeping track of what parts of the image are what color in the initial loading stage in case that brings up any different/better methods of mdoing this. Thanks!
Stack Overflow
C# - Faster Alternatives to SetPixel and GetPixel for Bitmaps for W...
I am trying to teach myself C# and have heard from a variety of sources that the functions get and setpixel can be horribly slow. What are some of the alternatives and is the performance improvement
Pastebin
Current Border Script - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
1 Reply
Accord
Accord17mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server