草庐IT

drawing_functions

全部标签

c# - 如何检查 Azure 函数是否在本地环境中运行? `RoleEnvironment` 在 Azure Functions 中不起作用

我在代码中有一个条件,我需要检查当前环境是否不是本地的。我使用了!RoleEnvironment.IsEmulated,现在这在Azure函数中不起作用,但在云服务中起作用。相同的代码也在云服务中共享,因此解决方案应与云服务和Azure功能一起使用。我如何检查当前环境是本地的而不是托管/部署的? 最佳答案 根据FabioCavalcante的回答,这是一个有效的Azure函数,用于检查当前运行环境(本地或托管):usingSystem.Net;usingSystem.Net.Http;usingSystem.Threading.Ta

c# - 创建随机颜色 (System.Drawing.Color)

我正在尝试创建随机绘图颜色。有一个错误。你能帮我看看这段代码吗?privateRandomrandom;privatevoidMainForm_Load(objectsender,EventArgse){random=newRandom();}privateColorGetRandomColor(){returnColor.FromArgb(random.Next(0,255),random.Next(0,255),random.Next(0,255));//Theerrorishere}publicSolidBrushbrushGet(){SolidBrushoBrush=newSo

c# - 将 System.Windows.Media.ImageSource 转换为 System.Drawing.Bitmap

如何在C#中将System.Windows.Media.ImageSource转换为System.Drawing.Bitmap? 最佳答案 它是较旧的OP,但对于其他一些人来说仍然可以派上用场,因为在没有dll互操作或剪贴板hack的情况下找到更干净的解决方案需要一些时间。这对我有用,您可以在保存到文件或rtf流之前使用pngencoder来削减图像大小privateSystem.Drawing.ImageImageWpfToGDI(System.Windows.Media.ImageSourceimage){MemoryStrea

c# - 使用 Bearer token 时,具有 AD 身份验证的 Azure Function 导致 401 Unauthorized

我在C#中有一个非常简单的Azure函数,我已经为其设置了AzureAD身份验证。我刚刚使用Express设置在功能配置中创建了应用程序注册。publicstaticclassIsAuthenticated{[FunctionName("IsAuthenticated")]publicstaticasyncTaskRun([HttpTrigger(AuthorizationLevel.Anonymous,"get","options",Route=null)]HttpRequestreq,ILoggerlog){returnnewOkObjectResult("Youare"+req.

c# - 如何创建从 System.Drawing.Bitmap 对象开始的 iTextSharp.text.Image 对象?

我是iTextSharp(iText的C#版本)的新手:我有这样的东西:System.Drawing.Bitmapbitmap=(System.Drawing.Bitmap)ChartHelper.GetPdfChart((int)currentVuln.UrgencyRating*10);iTextSharp.text.Imageimg=iTextSharp.text.Image.GetInstance(bitmap);vulnerabilityDetailsTable.AddCell(newPdfPCell(img){Border=PdfPCell.RIGHT_BORDER,Bor

c# - PInvoke C# : Function takes pointer to function as argument

我想在我的C#代码中访问这个函数,这可能吗?所以最后C++代码会调用我的函数并应用名为“sFrameofData”的结构。C++代码://Theusersuppliedfunctionwillbecalledwheneveraframeofdataarrives.DLLintCortex_SetDataHandlerFunc(void(*MyFunction)(sFrameOfData*pFrameOfData));这也许行得通吗?C#代码:[DllImport("Cortex_SDK.dll")]publicexternstaticintCortex_SetDataHandlerFu

c# - 从 System.Drawing.Image.RawFormat 获取 ImageFormat

此代码在尝试调用Image.Save(MemoryStream,ImageFormat)时失败。我得到异常:aValuecannotbenull.Parametername:encoder"ImageFormatformat=generatedImage.RawFormatasImageFormat;image.ImageData=generatedImage.Save(format);如果我直接传入ImageFormat对象,它会起作用,例如ImageFormat.Jpeg.将rawformat转换为ImageFormat的最佳方法是什么(最好不要使用switch语句或大量if语句)

c# - 在 AWS Lambda 上使用 System.Drawing.Common NuGet 包时无法加载 DLL 'libdl'

我们有一个缩略图生成器lambda函数,我正在尝试将其更新到.NETCore2.0,但在使用Microsoft的System.Drawing.CommonNuGet包时遇到以下错误:TypeInitializationExceptionThetypeinitializerfor'Gdip'threwanexception.atSystem.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32width,Int32height,Int32stride,Int32format,HandleRefscan0,IntPtr

c# - 如何将 System.Drawing.font 转换为 System.Windows.Media.Fonts 或 TypeFace?

如何将System.Drawing.Font转换为System.Windows.Media.Fonts或TypeFace?或者如何从System.Drawing.Font的实例生成System.Windows.Media.Fonts或TypeFace的实例? 最佳答案 你不能实例化Media.Fonts,但我认为你可以得到一个Media.FontFamily这就是我实现它的方法。usingSystem.Drawing;usingMedia=System.Windows.Media;Fontfont=newFont(newSystem

c# - 质量和压缩与 system.drawing.imaging 之间的区别?

我对ASP.NET中的图像处理完全陌生。我非常熟悉Photoshop,并且在某种程度上了解图像魔术。我试图找出质量和压缩之间的区别,因为其他应用倾向于将它们视为相同。对于system.drawing.imaging,有质量和压缩设置。http://msdn.microsoft.com/en-us/library/system.drawing.imaging.encoder.quality.aspx读取:“质量类别指定图像的压缩级别。”http://msdn.microsoft.com/en-us/library/bb882583.aspx阅读:“质量级别0对应最大压缩,质量级别100对