- Home /
capturing screen shot, and showing the captured image on screen
Hiii everyone, I have the requirement of capturing screen shot, saving it and accessing to show it on screen. How can I do this? please help out this new bee.... Thanks in advance
Answer by Unity_gamer · Feb 04, 2013 at 01:04 PM
Hi,
You can use "Application.CaptureScreenshot" to capture Image in Unity. you can refer the below link for reference. http://docs.unity3d.com/Documentation/ScriptReference/Application.CaptureScreenshot.html
public static string screenshotFilename = "screenshotName.png";
void Start() {
Application.CaptureScreenshot( screenshotName );
}
//use this to find the Path of the Image
var pathToImage = Application.persistentDataPath + "/" + screenshotName;
Try this out and post the result here.
Thanks
Hi, Here you go with my problem exactly 1. I am capturing screen shot by Application.CaptureScreenshot("path"+screenshot1.png); 2. Now need to fetch captured screen shot instantly & i am doing this by curSnap = Resources.Load("screenshot1"); I am getting null in curSnap if I access that screenshot instant but I am able to fetch once I close the engine & restart it.
$$anonymous$$y requirement is to get that captured snap as soon as I save in hard disk.
I am just bit to acheive that. Pls help me out Thanks
u tried using "Application.persistentDataPath" ? use this link for reference. http://docs.unity3d.com/Documentation/ScriptReference/Application-persistentDataPath.html
To load an image back in use the WWW class. If you are trying to speed up that process, just don't yield. It's a bit ugly but:
Application.CaptureScreenshot ("e:/foo.png");
WWW www = new WWW("file://e:/foo.png");
while (!www.isDone)
;
www.LoadImageIntoTexture((Texture2D)renderer.material.mainTexture);
You can save the image anywhere you have permission. If your target platform is controlled in some way, do as @Unity_gamer suggests and use persistentDataPath.
@robertbu Thanks for correcting me ..:) I used this in ios implementation , and it worked fine for me.
Thanks developers. I found the alternate solution using "WWWForm". Thanks for your care and help
Answer by Aqibsadiq · Apr 12, 2016 at 04:35 AM
@tenthplanet0 Here is simple Code for capturing screen shot, and showing the captured image on screen
This Code is For Andriod and IPhone.For PC Just Give the Image Path
public RawImage image;
void Start()
{
Photo();
Invoke("GetPhoto",1f);
}
public void Photo()
{
Application.CaptureScreenshot(Variables.ImageName);
}
public void GetPhoto()
{
#if !UNITY_EDITOR
string url = Application.persistentDataPath +"/"+Variables.ImageName;
var bytes = File.ReadAllBytes( url );
Texture2D texture = new Texture2D( 73, 73 );
texture.LoadImage( bytes );
image.texture= texture ;
#endif
}
Your answer
Follow this Question
Related Questions
How to save a screenshot to the camera roll (picture gallery)? 3 Answers
Taking Screenshot on Android.. 1 Answer
Screenshot is not saving to Gallery and folder 2 Answers
Allow user to download images from game assets 2 Answers
Save and Display Best Score 2 Answers