I have tested your code but not blend correctly,
public static void FillRectangleBlend2(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color colore)
{
var color = ConvertColor(colore);
using (var context = bmp.GetBitmapContext())
{
// Use refs for faster access (really important!) speeds up a lot!
var w = context.Width;
var h = context.Height;
var pixels = context.Pixels;
// Check boundaries
if ((x1 < 0 && x2 < 0) || (y1 < 0 && y2 < 0)
|| (x1 >= w && x2 >= w) || (y1 >= h && y2 >= h))
{
return;
}
// Clamp boundaries
if (x1 < 0) { x1 = 0; }
if (y1 < 0) { y1 = 0; }
if (x2 < 0) { x2 = 0; }
if (y2 < 0) { y2 = 0; }
if (x1 >= w) { x1 = w - 1; }
if (y1 >= h) { y1 = h - 1; }
if (x2 >= w) { x2 = w - 1; }
if (y2 >= h) { y2 = h - 1; }
int alpha = 1 + (int)((uint)color >> 24);
if (alpha == 1) return;
int alphac = 256 - alpha, p, pal, par, pag, pab;
if (alphac > 0)
{
color &= 0xffffff;
par = alpha * ((color >> 16) & 255);
pag = alpha * ((color >> 8) & 255);
pab = alpha * (color & 255);
color = ((par >> 8) << 16)
| ((pag >> 8) << 8)
| (pab >> 8);
}
unchecked
{
for (int y = y1; y <= y2; y++)
{
for (int i = y * w + x1; i < y * w + x2; i++)
{
p = pixels[i];
pal = 1 + (p >> 24);
par = alphac * pal * ((p >> 16) & 255);
pag = alphac * pal * ((p >> 8) & 255);
pab = alphac * pal * (p & 255);
pixels[i] = (Math.Min(255, alpha + pal - 1) << 24)
| (par & (255 * 256 * 256))
| (pag & (255 * 256 * 256)) >> 8
| (pab >> 16) + color;
}
}
}
}
}