예제 #1
0
    private IEnumerator LateSaveCapturedPhoto(string photoPath)
    {
        yield return(null);

        Debug.Log("CaptureDeviceCamHandle on path: " + photoPath);
        byte[] bytes = File.ReadAllBytes(photoPath);
        File.Delete(photoPath);

        Sprite photoSprite = SpriteLoader.GetSpriteFromBytes(bytes);

        if (photoSprite == null)
        {
            Debug.LogError("CaptureDeviceCam complete, but sprite is null in path:\n" +
                           photoPath);
            yield break;
        }

        Sprite rotatedSprite = TextureRotator.RotateSprite(photoSprite);

        bytes = rotatedSprite.texture.EncodeToJPG();
        string photoName = "Vsm-Appraiser-devicePhoto-" + DateStringConverter.GetMDHMSMDate() + ".jpg";

        photoPath = Path.Combine(GlobalSettings.cloudStorageUploadPath, photoName);
        File.WriteAllBytes(photoPath, bytes);
        Debug.Log("CaptureDeviceCamHandle replaced by new path " + photoPath);

        //CardAdditionalScreen.DeviceCameraCaptureHandle(photoPath, rotatedSprite);
    }
예제 #2
0
    private void OnPostRender()
    {
        if (takeScreenshotOnNextFrame)
        {
            takeScreenshotOnNextFrame = false;

            Texture2D captureTex = new Texture2D(webCamTexture.width, webCamTexture.height);
            captureTex.SetPixels(webCamTexture.GetPixels());
            captureTex.Apply();
            captureTex = TextureRotator.RotateTexture(captureTex, true);

            byte[] encodedBytes = captureTex.EncodeToJPG();
            SaveScreenshot(encodedBytes);
        }
    }