C
C#2y ago
LukeZurg22

Drawing Borders Between Provinces

I am working with maps; WriteableBitmap images that i'm shifting around, manipulating and etc. I am trying to implement a new version of a map but i don't necessarily know how. I have a map as such
2 Replies
LukeZurg22
LukeZurg222y ago
and I am trying to reach this state.
LukeZurg22
LukeZurg222y ago
This is the closest, simplest code that I have already existing to act as context for what I am trying to do:
public unsafe WriteableBitmap DrawSelectedProvince(WriteableBitmap image, uint color)
{
image.Lock();
var pixels = (uint*)image.BackBuffer;
var pixelCount = image.PixelWidth * image.PixelHeight;

Parallel.For(0, pixelCount, (index) =>
{
var rawPixel = pixels[index];

if (rawPixel == color)
pixels[index] = GetRawColor(Colors.WhiteSmoke);
else
pixels[index] = 0;
});

image.Unlock();
return image;
}
public unsafe WriteableBitmap DrawSelectedProvince(WriteableBitmap image, uint color)
{
image.Lock();
var pixels = (uint*)image.BackBuffer;
var pixelCount = image.PixelWidth * image.PixelHeight;

Parallel.For(0, pixelCount, (index) =>
{
var rawPixel = pixels[index];

if (rawPixel == color)
pixels[index] = GetRawColor(Colors.WhiteSmoke);
else
pixels[index] = 0;
});

image.Unlock();
return image;
}
My hopes are to get this black-border completely separate from the province colours; creating a new WriteableBitmap that is filled with these borders but devoid if the original image's colours.