保存图像(或视频)使用像素着色器处理 [英] Saving Image(Or a video) Processed using Pixel Shader

查看:134
本文介绍了保存图像(或视频)使用像素着色器处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

删除提醒|编辑|删除|更改类型





0

Hii,



我使用像素着色器创建了一个小效果并使用c#中的WPF将其应用于图像。一切正常但现在我仍然坚持这最后一步。 如何在应用像素着色器效果后实际保存图像?



例如,我已经对图像控件中的图像应用了灰度效果。现在我想以某种格式保存它,比如说jpeg。怎么做?进一步,我想对视频应用相同的效果。我可以设法应用它,但最后如何保存?请一些专家帮助我!!



我再次在c#中使用WPF ...提前谢谢!!

Remove Alert | Edit | Delete | Change Type


0
Hii,

I have created a small effect using pixel shader and applied it to a image using WPF in c#.Everything works fine but now i am stuck with this final step. How to actually save the image ,after pixel shader effect is applied??

For E.g., I have applied a grayscale effect to a image in image control.Now I want to save it in some format, say jpeg. How to do it? moving further, I want to apply the same effect to a video also. I can manage to apply it but finally how to save that? Please some experts out there help me!!

Again I used WPF in c#... Thank you in advance!!

推荐答案

您可以使用以下方法对图像渲染执行相同操作: -





public BitmapSource GetBitmapSourceFromVisual(FrameworkElement printCanvas)

{

RenderTargetBitmap renderBitmap = null;

try

{

System.Windows.Size size = new System.Windows.Size(printCanvas.Width,printCanvas.Height);



renderBitmap = new RenderTargetBitmap ((int)(size.Width),(int)(size.Height),96,96,PixelFormats.Default); // PixelFormats.Pbgra32);



renderBitmap.Render(printCanvas);

返回renderBitmap;

}

catch(exception ex)

{

return renderBitmap;

}

}
You can use following method to do the same for image rendering :-


public BitmapSource GetBitmapSourceFromVisual(FrameworkElement printCanvas)
{
RenderTargetBitmap renderBitmap = null;
try
{
System.Windows.Size size = new System.Windows.Size(printCanvas.Width, printCanvas.Height);

renderBitmap = new RenderTargetBitmap((int)(size.Width), (int)(size.Height), 96, 96, PixelFormats.Default);// PixelFormats.Pbgra32);

renderBitmap.Render(printCanvas);
return renderBitmap;
}
catch (Exception ex)
{
return renderBitmap;
}
}


非常感谢先生!但现在问题是Windows Store App中没有像素着色器(使用c#)
Thank you so much sir!! But now the problem is that pixel shaders are not availaible in Windows Store App(Using c#)


这篇关于保存图像(或视频)使用像素着色器处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆