This project is read-only.

Issue with Blit()

Nov 29, 2010 at 11:32 AM
Edited Nov 29, 2010 at 11:33 AM

I am trying to Blit a rectangle from one bitmap to another.  However the horizontal amount of the image that is copy is the full width of the image not the 124 pixels requested. The vertical height of the Blit is correct.

wbField.Blit(new Point(0,0), wbTest, new Rect(0, 0, 124,124),Colors.White,WriteableBitmapExtensions.BlendMode.None);



Nov 29, 2010 at 12:46 PM

That's strange. Can you try a different overload?

If it doesn't work, please attach a repro VS2010 project so I can have a look at it.

- Rene Schulte

Nov 29, 2010 at 2:24 PM

I tracked the issue to the blend mode.

.None gives me the width issue, any other mode appears to work correctly.

I am switching to Alpha to solve my issue.



Nov 29, 2010 at 2:35 PM

Can you provide a sample so we can try and fix the issue with .None ?

Nov 29, 2010 at 3:02 PM

None is way faster and the problem should be fixed. I guess it has something todo with the BlockCopy fast path internally.

Can you provide a sample project / repro I can use as a starter.



Nov 29, 2010 at 3:57 PM

Not sure on how to attach a project, but here it is zipped.

Blit test 1,2 have the clipping issue.

Blit test 3 has a scaling issue.

Blit test 4 works correctly

Use the Clear field button between each test to reset the image.


Nov 29, 2010 at 6:28 PM

Scratch the "scaling" issue.  that was a programmer issue

Feb 1, 2011 at 8:49 PM

It took a bit, but I finally found some time to look into it. It's fixed in r67686



- Rene Schulte

Feb 2, 2011 at 10:37 AM

Awesome!  Can't wait to see performance jump =)

Jul 19, 2011 at 2:36 AM
Edited Jul 19, 2011 at 3:22 AM

It does not appear to be fixed.  I'm using the code from r67686 and I am experiencing the same problem with blend set to none.  The height blits correctly but the width stays at the source width.

Here is a sample piece of code:

Rect sourceRect = new Rect(0.0f, 0.0f, bitmap2.PixelWidth, bitmap2.PixelHeight);
Rect destRect = new Rect(0.0f, 0.0f, bitmap1.PixelWidth * .9f, bitmap1.PixelHeight * .9f);
bitmap1.Blit(destRect, bitmap2, sourceRect,WriteableBitmapExtensions.BlendMode.None);


Bitmap1 is a 300x300 pixel image and bitmap2 is a 100x100 pixel image.

I also tried with bitmap2 as a 600x600 pixel image.  This time the blit width and height were correct but the blit image was cropped.  It appears that the blend.none code only works if the source bitmap is the same size as the destination rectangle.

Oct 27, 2011 at 11:17 PM

I can't reproduce it rdagger. Can you provide a complete VS solution for a reproduction and some details what you'd expect. Thanks. 

Please make also sure you try the latest source code,


- Rene Schulte

Nov 21, 2011 at 8:25 PM

Using, I am seeing strange behavior with Blit as well.  The behavior shows when I attempt to Blit an image into a Rect larger than the dimensions of the destination WriteableBitmap.  Blending mode None results in a vertically stretched single-row of the source image.  Blending mode alpha results in an all-white image.

I am using the same WriteableBitmap as the source and destination.  This all works fine as long as the destination rect is the same size, or smaller than the destination image.

Expected behavior would be that the image would be drawn into visible area, while pixels "scaled" off the destination WriteableBitmap would simply not be drawn..




int w = wbmp.PixelWidth;
int h = wbmp.PixelHeight;

//Source rect of entire image
Rect sourceRect = new Rect(0,0,w,h);

//Create Rect larger than desitnation WriteableBitmap
Rect destRect = new Rect(0,0,w*1.75,h*1.75);
//Results in an incorrect image:
myWriteableBitmap.Blit(destRect, myWriteableBitmap, sourceRect, WriteableBitmapExtensions.BlendMode.None);

Nov 21, 2011 at 10:47 PM

Update to last post:


This issue only appears when using the same image for source and destination.  When cloning the source image to another WriteableBitmap everything looks as expected.

Nov 22, 2011 at 10:51 PM
Enclosed is a VS solution that demonstrates the issue.
The problem is with BlendMode.None and the destination rectangle scale. If the destination rect scale is less than 100% then the source width and height will be clipped. If greater than 100% then just the width will be clipped.
Sorry, for the delay in getting back to you.

From: [email removed]
To: [email removed]
Date: Thu, 27 Oct 2011 15:17:47 -0700
Subject: Re: Issue with Blit() [WriteableBitmapEx:236356]

From: teichgraf
I can't reproduce it rdagger. Can you provide a complete VS solution for a reproduction and some details what you'd expect. Thanks.
Please make also sure you try the latest source code,

- Rene Schulte
Read the full discussion online.
To add a post to this discussion, reply to this email (
To start a new discussion for this project, email
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at
Apr 23, 2012 at 8:42 PM

This behavior is normal when using the same bitmap and BlendMode.None. It uses a fast memory copying and the areas might overlap. Some people would call this behavior by design. ;)

Sorry for the late reply.


- Rene Schulte