當前位置: 首頁>>代碼示例>>C#>>正文


C# Image.SavePNG方法代碼示例

本文整理匯總了C#中System.Image.SavePNG方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.SavePNG方法的具體用法?C# Image.SavePNG怎麽用?C# Image.SavePNG使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Image的用法示例。


在下文中一共展示了Image.SavePNG方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: HandleKeyDown

        void HandleKeyDown(KeyDownEvent e)
        {
            var renderer = GetSubsystem<Renderer>();

            switch (e.Key)
            {
                case Constants.KEY_ESCAPE:
                    BackToSelector();
                    return;
                case Constants.KEY_F1:
                    GetSubsystem<UI>().ToggleConsole();
                    return;
                case Constants.KEY_F2:
                    GetSubsystem<UI>().ToggleDebugHud();
                    return;
            }

            switch (e.Key)
            {
                case Constants.KEY_1:
                    var quality = renderer.TextureQuality;
                    ++quality;
                    if (quality > 2)
                        quality = 0;
                    renderer.TextureQuality = quality;
                    break;

                case Constants.KEY_2:
                    var mquality = renderer.MaterialQuality;
                    ++mquality;
                    if (mquality > 2)
                        mquality = 0;
                    renderer.MaterialQuality = mquality;
                    break;

                case Constants.KEY_3:
                    renderer.SpecularLighting = !renderer.SpecularLighting;
                    break;

                case Constants.KEY_4:
                    renderer.DrawShadows = !renderer.DrawShadows;
                    break;

                case Constants.KEY_5:
                    var shadowMapSize = renderer.ShadowMapSize;
                    shadowMapSize *= 2;
                    if (shadowMapSize > 2048)
                        shadowMapSize = 512;
                    renderer.ShadowMapSize = shadowMapSize;
                    break;

                // shadow depth and filtering quality
                case Constants.KEY_6:
                    var q = (int)renderer.ShadowQuality++;
                    if (q > 3)
                        q = 0;
                    renderer.ShadowQuality = (ShadowQuality)q;
                    break;

                // occlusion culling
                case Constants.KEY_7:
                    var o = !(renderer.MaxOccluderTriangles > 0);
                    renderer.MaxOccluderTriangles = o ? 5000 : 0;
                    break;

                // instancing
                case Constants.KEY_8:
                    renderer.DynamicInstancing = !renderer.DynamicInstancing;
                    break;

                case Constants.KEY_9:
                    Image screenshot = new Image();
                    GetSubsystem<Graphics>().TakeScreenShot(screenshot);
                    screenshot.SavePNG(GetSubsystem<FileSystem>().ProgramDir + $"Data/Screenshot_{GetType().Name}_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)}.png");
                    break;
            }
        }
開發者ID:Type1J,項目名稱:AtomicExamples,代碼行數:77,代碼來源:Sample.cs

示例2: HandleKeyDown

		void HandleKeyDown(KeyDownEventArgs e)
		{
			switch (e.Key)
			{
				case Key.Esc:
					Exit();
					return;
				case Key.F1:
					console.Toggle();
					return;
				case Key.F2:
					debugHud.ToggleAll();
					return;
			}

			var renderer = Renderer;
			switch (e.Key)
			{
				case Key.N1:
					var quality = renderer.TextureQuality;
					++quality;
					if (quality > 2)
						quality = 0;
					renderer.TextureQuality = quality;
					break;

				case Key.N2:
					var mquality = renderer.MaterialQuality;
					++mquality;
					if (mquality > 2)
						mquality = 0;
					renderer.MaterialQuality = mquality;
					break;

				case Key.N3:
					renderer.SpecularLighting = !renderer.SpecularLighting;
					break;

				case Key.N4:
					renderer.DrawShadows = !renderer.DrawShadows;
					break;

				case Key.N5:
					var shadowMapSize = renderer.ShadowMapSize;
					shadowMapSize *= 2;
					if (shadowMapSize > 2048)
						shadowMapSize = 512;
					renderer.ShadowMapSize = shadowMapSize;
					break;

				// shadow depth and filtering quality
				case Key.N6:
					var q = (int)renderer.ShadowQuality++;
					if (q > 3)
						q = 0;
					renderer.ShadowQuality = (ShadowQuality)q;
					break;

				// occlusion culling
				case Key.N7:
					var o = !(renderer.MaxOccluderTriangles > 0);
					renderer.MaxOccluderTriangles = o ? 5000 : 0;
					break;

				// instancing
				case Key.N8:
					renderer.DynamicInstancing = !renderer.DynamicInstancing;
					break;

				case Key.N9:
					Image screenshot = new Image();
					Graphics.TakeScreenShot(screenshot);
					screenshot.SavePNG(FileSystem.ProgramDir + $"Data/Screenshot_{GetType().Name}_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)}.png");
					break;
			}
		}
開發者ID:xamarin,項目名稱:urho-samples,代碼行數:76,代碼來源:Sample.cs


注:本文中的System.Image.SavePNG方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。