当前位置: 首页>>代码示例>>C#>>正文


C# Photo.save方法代码示例

本文整理汇总了C#中Photo.save方法的典型用法代码示例。如果您正苦于以下问题:C# Photo.save方法的具体用法?C# Photo.save怎么用?C# Photo.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Photo的用法示例。


在下文中一共展示了Photo.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

		void Update () {
			//Debug.Log (PlayerProfile.profile.lenses.Count);
			if(Input.GetButtonDown("Photo Review")){
				photoReview = !photoReview;
			}
			if (!photoReview) {
				if (Input.GetButtonDown ("Camera Switch")) {
					parent.transform.localPosition = cameraHeldUp;
				} 
				if (Input.GetButtonUp ("Camera Switch")) {
					parent.transform.localPosition = cameraHeldDown;
				}

				// When player presses down, a beep is heard
				if (!uimanager.isPaused) {
					if (Input.GetButtonDown ("Take Photo")) {
						cameraAudio.PlayOneShot (cam_click, 0.7f);  //  beep beep
						buttonDownWhilePaused = false;
						//  Then upon release the photo is taken
					} else if (Input.GetButtonUp ("Take Photo") && !buttonDownWhilePaused) {
						if (PlayerProfile.profile.memoryCardCapacity > memCardReader.getPhotoCount ()) {
							cameraAudio.PlayOneShot (cam_shutter, 0.7f);  //  snap
							//GameObject.Find ("Camera Prefab").GetComponent<PhotoEval> ().PhotoValues ();
							RenderTexture renderTexture = new RenderTexture (width, height, 24);	// Creates a render texture to pull the pixels from
							Camera parentCamera = parent.GetComponent<Camera> ();	// Gets the camera to output to the render tuexture
							parentCamera.targetTexture = renderTexture;
							Texture2D photoTexture = new Texture2D (width, height, TextureFormat.RGB24, false); // Texture2D that wil be stored in the Photo object
							parentCamera.Render (); // Forces the camera to render
							RenderTexture.active = renderTexture;
							photoTexture.ReadPixels (new Rect (0, 0, width, height), 0, 0); // Reads the pixels
							Photo photoMetaData = new Photo (); // Creates a new Photo object and then stores t2d and list of visible objects
							photoMetaData.photo = photoTexture;

							PhotoEval photoEvaluator = GameObject.Find ("Camera Prefab").GetComponent<PhotoEval> ();
							photoEvaluator.evaluatePhoto ();
							photoMetaData.balanceValue = photoEvaluator.balance;
							photoMetaData.spacingValue = photoEvaluator.spacing;
							photoMetaData.interestingnessValue = photoEvaluator.interest;
							photoMetaData.containsDeer = photoEvaluator.containsDeer;
							photoMetaData.containsFox = photoEvaluator.containsFox;
							photoMetaData.takenWithTelephoto = photoEvaluator.takenWithTelephoto;
							photoMetaData.takenWithWide = photoEvaluator.takenWithWideAngle;
							photoMetaData.takenWithFilter = photoEvaluator.takenWithFilter;

							parentCamera.targetTexture = null;
							RenderTexture.active = null;
							Destroy (renderTexture); 
							byte[] bytes = photoTexture.EncodeToPNG ();

                            // Note that pictures now get saved to the UploadQueue directory
                            string partialPath = Application.dataPath + "/Resources/UploadQueue/screen"
                                                 + System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");

                            photoMetaData.pathname = partialPath + ".metaphoto";
							//  Save image
							string filename = partialPath + ".png"; 
							System.IO.File.WriteAllBytes (filename, bytes);
							Debug.Log (string.Format ("Took screenshot to: {0}", filename));
							//  Save meta
							photoMetaData.save ();
							Camera mainCameraCam = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera> ();
							parentCamera.targetTexture = camView;	// Sets the render texture
							mainCameraCam.Render ();	// Renders the Player view
							mainCameraCam.targetTexture = null;
							buttonDownWhilePaused = true;

							// Finally, tell the Camera Menu Manager to update its own info
							camMenuManager.updatePhotoCounter ();
							camMenuManager.updatePhotoReviewUI ();
						} else {
							camMenuManager.warnAboutFullCard ();
						}
					}
				}
				// Aperture Size
				// Increases Aperture Size
				if (Input.GetButtonDown ("Aperture Up") && apertureInt < 5) {
					// Access components Depth of Field and Tone Mapping
					DepthOfField dof = GameObject.Find ("PlayerCam").GetComponent<DepthOfField> ();
					Tonemapping tm = GameObject.Find ("PlayerCam").GetComponent<Tonemapping> ();
					apertureInt += 1;
					// Set Aperture Size and Light levels based on presets
					tm.exposureAdjustment = apertureLight [apertureInt];
					dof.aperture = apertureSize [apertureInt];

				}
				// Decreasses Aperture Size
				if (Input.GetButtonDown ("Aperture Down") && apertureInt > 0) {
					// Access components Depth of Field and Tone Mapping
					DepthOfField dof = GameObject.Find ("PlayerCam").GetComponent<DepthOfField> ();
					Tonemapping tm = GameObject.Find ("PlayerCam").GetComponent<Tonemapping> ();
					apertureInt -= 1;
					// Set Aperture Size and Light levels based on presets
					dof.aperture = apertureSize [apertureInt];
					tm.exposureAdjustment = apertureLight [apertureInt];
				}
				// White Balance
				// Currently only effects r value of the base white texture
				// Plan to implement color wheel selector for more control/options
				// Decrease Red
//.........这里部分代码省略.........
开发者ID:SamReha,项目名称:SnapshotGame,代码行数:101,代码来源:SnapshotCam.cs

示例2: getMetaData

	public void getMetaData() {
		#if UNITY_EDITOR
		//  Make sure pictures are loaded into resources
		AssetDatabase.Refresh();
		#endif

		DirectoryInfo dir = new DirectoryInfo(pathToPostedPhotos);
		FileInfo[] info = dir.GetFiles("*.metaphoto");
		foreach (FileInfo file in info) {
			Photo photo = new Photo ();
			string filename = file.Name;
			photo.pathname = pathToPostedPhotos +  filename;
			photo.load ();

			Transform child = transform.Find (filename.Replace (".metaphoto", ""));
			GameObject metaData = new GameObject ();
			metaData.transform.position.Set(20f, 0f, 0f);
			Text textData = metaData.AddComponent<Text> ();

			// Configure comments for photo
			if (photo.comments.Count == 0) {
				Debug.Log ("It looks like there are no comments!");
				string markup = "";
				float score = Math.Max(photo.balanceValue, Math.Max(photo.spacingValue, photo.interestingnessValue));
				//Debug.Log (score);
				if (score <= 20f) {
					markup = "bad";
				} else if (score <= 70f) {
					markup = "good";
				} else {
					markup = "perfect";
				}
				photo.comments.Add(gameObject.GetComponent<CommentGenerator>().GenerateComment (markup));
				photo.save ();
			}

			//Debug.Log (filename + " - " + photo.comments [0]);
			BlogUIManager.photoPanel.GetComponentInChildren<Text> ().text = getPhotoComment(photo); //spacing the comments

			textData.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
			metaData.GetComponent<RectTransform> ().position = new Vector3 (0f, -90f, 0f);
			metaData.transform.SetParent (child, false);
		}
	}
开发者ID:SamReha,项目名称:SnapshotGame,代码行数:44,代码来源:PostedPhotosManager.cs


注:本文中的Photo.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。