This project is read-only.

Applying pixel shader in-memory (solved)

Sep 16, 2010 at 3:59 PM

Hi Walt,

I'm trying to render a shader in-memory on a Bitmap, which appears to work nicely with the built-in BlurEffect, but unfortunately fails as soon as I try it with a Shazzam-generated one. My code basically uses a RenderTargetBitmap to apply the effect to an image and then render it:

public static BitmapSource ApplyEffect(this BitmapSource source, Effect effect)
	//create ad-hoc image
	var image = new Image { Source = source, Effect = effect, Width = source.Width, Height = source.Height};
	if (!image.IsMeasureValid)
		var size = new Size(image.Width, image.Height);
		image.Arrange(new Rect(size));

	//render the image into a bitmap, which is eventually returned
	var target = new RenderTargetBitmap((int)source.Width, (int) source.Height, source.DpiX, source.DpiY,
	return target;

If I submit one of Shazzam's effects to the above helper method, the image remains unchanged. BlurEffect on the other hand works as expected. It's probably not directly related to Shazzam (I barely know what I'm doing here ;), but maybe you can help me out on this one.

Thanks for your advice


Sep 16, 2010 at 5:33 PM

Think I got it - RenderTargetBitmap falls back to software rendering, which doesn't support PS3 yet. Just generated a PS2 effect and it worked. Shazzam is the s*** btw - love it!