草庐IT

image_name

全部标签

c# - validateImageData 参数和 Image.FromStream()

我担心这个重载中的第三个参数,validateImageData。文档对此没有太多解释,只说它会导致图像数据被验证但没有详细说明,到底做了什么来验证图像数据?publicstaticImageFromStream(Streamstream,booluseEmbeddedColorManagement,boolvalidateImageData)我想在网络应用程序中使用它,所以,我想知道如果我将validateImageData设置为true会发生什么,我想确保用户上传的是有效图像,是否建议设置将validateImageData设置为true或者是否足以在抛出异常时捕获异常?另外,将v

c# - Thread.CurrentPrincipal.Identity.Name 在 WPF 中为空

编辑简单的问题是,我怎样才能让Thread.CurrentPrincipal.Identity.Name让当前用户在WPF中登录?结束编辑我正在尝试调用一个现有方法(不在任何类型的服务中;只是POCO中的一个方法)来检索当前用户:Thread.CurrentPrincipal.Identity.Name这段代码是由其他人编写的,并且(大概)与他的ASP.NETMVC项目一起工作。我正在尝试从WPF中调用相同的方法,但名称现在为空。我能做些什么吗? 最佳答案 将Thread.CurrentPrincipal设置为newWindowsP

c# - 将 Resources.resx 中的 BitmapImage 分配给 Image.Source?

我想将我的Resources.resx中的BitmapImage分配给Image。事先我将.png图像保存到Resources.resx。此图像现在位于“/Resources/logo.png”中。在阅读了几篇SO帖子和其他文章后,我现在有了这个:logoImage.Source=newBitmapImage(newUri(@"pack://application:,,,/Resources/logo.png"));不幸的是,它不起作用。我不知道如何解决这个问题。我尝试用完整路径替换Pack-URI并且它有效,但我想使用相对路径以便在绝对路径不正确的不同机器上使用相同的源.谁能帮我解决

c# - 委托(delegate) : Method name expected error

我正在尝试让以下简单的委托(delegate)示例正常工作。根据我从中获取的一本书应该没问题,但我得到了一个Methodnameexpected错误。namespaceTestConsoleApp{classProgram{privatedelegatestringD();staticvoidMain(string[]args){intx=1;Dcode=newD(x.ToString());}}}有什么帮助吗? 最佳答案 删除():Dcode=newD(x.ToString);您想指定方法,而不是执行。

c# - .NET Image.Save 偶尔会生成带有错误 IDAT block 的 PNG

我有一个我编写的C#/.NET实用程序,可以从磁盘加载PNG图像Bitmapb=Bitmap.FromStream(newMemoryStream(File.ReadAllBytes(filename)))asBitmap;对它们执行多种转换(旋转、缩放、alpha),然后根据应用的转换以不同的文件名将生成的PNG图像保存回磁盘b.Save(outputName,ImageFormat.Png);我已经使用该实用程序成功编写了数千个PNG。但是,有时其中一个PNG无法加载到使用libpng的单独程序中。在该程序中,libpng给出错误“找到太多IDAT”查看PNG文件会发现在文件末尾I

c# - 获取屏幕空间中的 UnityEngine.UI.Images 位置并计算归一化偏移量(在覆盖 Canvas 内)

手头的问题:简化GivenanUnityEngine.Ui.ImageHowdoesonefindtheX,Ypositionofanormalisedoffset(like0.4,0.3fromthetopleft)insidethatimageinScreenSpaceunitslike400,300我想我需要找到左上角的ScreenSpace值然后通过以像素表示的实际大小比率来了解图像的渲染总大小缩放归一化偏移量。图1:图2显示了要使用的normalisedOffsets图2:So,inprecis,IneedtofindtheoffsetinScreenSpacepixelso

c# - "An assembly with the same simple name has already been imported"没有重复引用的错误

我收到以下错误:errorCS1704:Anassemblywiththesamesimplename'Interop.xxx.dll,Version=1.0.0.0,Culture=neutral,PublicKeyToken=nullhasalreadybeenimported.Tryremovingoneofthereferencesorsignthemtoenableside-by-side.我所看到的一切都表明我引用了两个同名的程序集,我需要删除其中一个。但是,我已经检查过并且只引用了一次。这也仅在我使用msbuild从我的开发箱上的命令行构建时发生。如果我通过VisualS

c# - Image.Save 崩溃 : {"Value cannot be null.\r\nParameter name: encoder"}

我正在尝试将图像保存到MemoryStream中,但在某些情况下会失败。代码如下:以下代码成功:Imageimg=Bitmap.FromStream(fileStream);MemoryStreamms=newMemoryStream();img.Save(ms,img.RawFormat);//Thissucceeds.以下代码失败:Imageimg=Bitmap.FromStream(fileStream);Imagethumb=img.GetThumbnailImage(thumbWidth,thumbHeight,null,System.IntPtr.Zero);MemoryS

c# - 具有路由属性的模糊 Controller 名称 : controllers with same name and different namespace for versioning

我正在尝试添加API版本控制,我的计划是为不同命名空间中的每个版本创建一个Controller。我的项目结构是这样的(注意:每个版本没有单独的区域)Controllers||---Version0||||-----ProjectController.cs||-----HomeController.cs||---Version1||-----ProjectController.cs|-----HomeController.cs我正在为路由使用RoutingAttribute。因此,Version0中的ProjectController具有路由功能namespaceMyProject.Co

c# - 在 WPF 中获取 "<Property Name> was already registered by "<控件名称>"错误

我在WPF中有一个用户控件,它绑定(bind)到一个依赖属性。当我尝试编译应用程序时,出现“属性名称”已由“控件名称”注册的错误,设计器显示“无法创建“用户控件”的实例”错误。这是我的简单控件的样子:ExampleUserControl.xaml:ExampleUserControl.xaml.cs:publicpartialclassExampleUserControl:UserControl{publicDependencyPropertySomeStringValueProperty=DependencyProperty.Register("SomeStringValue",ty