Hello,
I might not see the trees for the wood here. I have several smaller WriteableBitmaps and want to blit them into a larger one in a Windows Store 8.1 app.
When I copy pixel by pixel, I get the result on the right in the following image. When using Blit, I get the left one. Both sections are not the same but there is an obvious quality difference :-/. What am I doing wrong?
Any help appreciated.
Andreas
Source code:
Blit:
I might not see the trees for the wood here. I have several smaller WriteableBitmaps and want to blit them into a larger one in a Windows Store 8.1 app.
When I copy pixel by pixel, I get the result on the right in the following image. When using Blit, I get the left one. Both sections are not the same but there is an obvious quality difference :-/. What am I doing wrong?
Any help appreciated.
Andreas
Source code:
Blit:
dest.DrawInto(backgroundImage, xDestOffset, yDestOffset, 0, 0, backgroundImage.PixelWidth, backgroundImage.PixelHeight);
public static void DrawInto(this WriteableBitmap dest, WriteableBitmap backgroundImage, int xDestOffset, int yDestOffset, int xstart, int ystart, int xend, int yend)
{
Rect destRect = new Windows.Foundation.Rect(xDestOffset, yDestOffset, xDestOffset + xend-xstart, yDestOffset + yend-ystart);
Rect srcRect = new Windows.Foundation.Rect(xstart, ystart, xend-xstart, yend-ystart);
dest.Blit(destRect, backgroundImage, srcRect, WriteableBitmapExtensions.BlendMode.None);
}
Get/SetPixel: for (int x = 0; x < backgroundImage.PixelWidth; x++)
{
if (x +xDestOffset >= dest.PixelWidth) {
break;
}
for (int y = 0; y < backgroundImage.PixelHeight; y++)
{
if (y + yDestOffset >= dest.PixelHeight)
{
break;
}
var color = backgroundImage.GetPixel(x, y);
dest.SetPixel(x+xDestOffset, y+yDestOffset, color);
}
}