如何在 C# 中将位图对象保存为 jpeg 文件
我有一个返回位图对象的函数。如何在 C# 中将这样的对象保存为 jpg 文件?
到目前为止,我有这个代码段
b = MakeGrayscale(b);
b.Save("C:\\test.jpg");
,我收到此错误消息
{“GDI+ 中发生一般错误。”}
StackTrace
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)
at Convert.Program.Plot(Byte[]& fileBufferArray, Int32 fileSize, Int32 offset) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Convert\Convert\Program.cs:line 151
at Convert.Program.Main(String[] args) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Convert\Convert\Program.cs:line 42
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
有人可以帮助我吗?
I have a function that returns a bitmap object. How do i save such a object as a jpg file in C# ?
So far i have this code segment
b = MakeGrayscale(b);
b.Save("C:\\test.jpg");
I get this error message
{"A generic error occurred in GDI+."}
StackTrace
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)
at Convert.Program.Plot(Byte[]& fileBufferArray, Int32 fileSize, Int32 offset) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Convert\Convert\Program.cs:line 151
at Convert.Program.Main(String[] args) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Convert\Convert\Program.cs:line 42
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Could someone please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论