c# – 截图捕获和显示
发布时间:2020-12-15 22:09:33 所属栏目:百科 来源:网络整理
导读:我正在创建一个应用程序,我希望能够存储屏幕截图,然后显示它.我的代码运行正常,屏幕截图被存储,并且程序似乎也没有问题地收到.但是,它没有显示屏幕截图,这非常令人沮丧.这是我的代码: void OnGUI(){ if (GUI.Button (new Rect(940,y+25,Screen.width/30,Scr
我正在创建一个应用程序,我希望能够存储屏幕截图,然后显示它.我的代码运行正常,屏幕截图被存储,并且程序似乎也没有问题地收到.但是,它没有显示屏幕截图,这非常令人沮丧.这是我的代码:
void OnGUI(){ if (GUI.Button (new Rect(940,y+25,Screen.width/30,Screen.height/14),Tex7)){ Debug.Log ("Selfie-maker"); folderPath = Application.persistentDataPath + "/screenshot.png"; Application.CaptureScreenshot(folderPath); Debug.Log ("Screenshot number " + screenshotCount +" taken!"); screenshotCount ++; } if(GUI.Button (new Rect(940,y+65,Tex)){ Debug.Log ("Anders"); fileName = Path.Combine(Application.persistentDataPath,"screenshot.png"); bytes = File.ReadAllBytes(fileName); screenshot = new Texture2D(0,TextureFormat.ATF_RGB_DXT1,false); screenshot.LoadImage(bytes); } } 我希望我提供的信息就足够了.如果没有,请不要犹豫. 解决方法
尝试加载这样的图像:
string fullFilename = Path.Combine(Application.persistentDataPath,"screenshot.png"); 然后,加载图像: WWW www = new WWW(fullFilename); Texture2D texTmp = new Texture2D(0,false); www.LoadImageIntoTexture(texTmp); 这应该工作,我无法测试代码,因为我没有在这台PC上安装Unity. 代码取自这里,请不要犹豫! http://answers.unity3d.com/questions/25271/how-to-load-images-from-given-folder.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |