|
I read it in from web and from disk with different apps with the same result. I think the easiest way to reproduce it is to modify the WriteableBitmapExBlitSample. What I changed is, in MainWindow.Xaml.cs load the osm image I pointed to above, and change
these lines:
particleBmp = LoadBitmap("/WriteableBitmapExBlitSample.Wpf;component/Data/osmSampleImage.png");
particleSourceRect = new Rect(0, 0, 256, 256);
In ParticleEmitter.cs I changed the source rect:
Rect sourceRect = new Rect(0, 0, 256, 256);
And changed the blit line:
var color = Color.FromArgb((byte)Convert.ToInt32(255 * 0.5), 255, 255, 255);
TargetBitmap.Blit(new Rect(0, 0, 256, 256), ParticleBitmap, sourceRect, color, WriteableBitmapExtensions.BlendMode.Alpha);
This shows an image on the top left. In case of a 32 bit image this is what I expect. In the case of 8 bit image like the above I get this:
http://yfrog.com/5rg2ip
I think the main code involved is in WriteableBitmapBlitExtensions.cs
if (BlendMode == BlendMode.Alpha)
{
destPixel = ((sa + (((da * (255 - sa)) * 0x8081) >> 23)) << 24) |
((sr + (((dr * (255 - sa)) * 0x8081) >> 23)) << 16) |
((sg + (((dg * (255 - sa)) * 0x8081) >> 23)) << 8) |
((sb + (((db * (255 - sa)) * 0x8081) >> 23)));
}
btw there seems to be a problem with codeplex' Insert code snippets.
|