// Token: 0x06000A59 RID: 2649 RVA: 0x0002CC34 File Offset: 0x0002B034
    public static Texture2D CaptureCamera(string pictureName)
    {
        Camera    main      = Camera.main;
        float     y         = (float)(Screen.height - Screen.width) * 0.5f;
        Rect      source    = new Rect(0f, y, (float)Screen.width, (float)Screen.width);
        Texture2D texture2D = new Texture2D((int)source.width, (int)source.height, TextureFormat.RGB24, false);

        texture2D.ReadPixels(source, 0, 0, false);
        texture2D.Apply();
        TextureUtility.ScaleBilinear(texture2D, 256, 256);
        byte[] bytes     = texture2D.EncodeToPNG();
        string thumbPath = CaptureScreenHelper.GetThumbPath(pictureName);

        File.WriteAllBytes(thumbPath, bytes);
        return(texture2D);
    }
Exemplo n.º 2
0
    // Token: 0x06000A28 RID: 2600 RVA: 0x0002BF70 File Offset: 0x0002A370
    private void LoadTexure(out Texture2D texture)
    {
        int width  = Screen.width;
        int width2 = Screen.width;

        texture = new Texture2D(width, width2);
        string thumbPath = CaptureScreenHelper.GetThumbPath(this._TID);

        if (!File.Exists(thumbPath))
        {
            texture = null;
            return;
        }
        FileStream fileStream = new FileStream(thumbPath, FileMode.Open, FileAccess.Read);

        fileStream.Seek(0L, SeekOrigin.Begin);
        byte[] array = new byte[fileStream.Length];
        fileStream.Read(array, 0, (int)fileStream.Length);
        fileStream.Close();
        fileStream.Dispose();
        texture.LoadImage(array);
    }
Exemplo n.º 3
0
    // Token: 0x06000A9C RID: 2716 RVA: 0x0002D964 File Offset: 0x0002BD64
    public static Texture2D LoadTextureByIO(string TID)
    {
        Texture2D texture2D = new Texture2D(0, 0);
        string    thumbPath = CaptureScreenHelper.GetThumbPath(TID);

        if (!File.Exists(thumbPath))
        {
            return(null);
        }
        FileStream fileStream = new FileStream(thumbPath, FileMode.Open, FileAccess.Read);

        fileStream.Seek(0L, SeekOrigin.Begin);
        byte[] array = new byte[fileStream.Length];
        fileStream.Read(array, 0, (int)fileStream.Length);
        fileStream.Close();
        fileStream.Dispose();
        int width  = Screen.width;
        int width2 = Screen.width;

        texture2D = new Texture2D(width, width2);
        texture2D.LoadImage(array);
        return(texture2D);
    }
    // Token: 0x0600089F RID: 2207 RVA: 0x0002523C File Offset: 0x0002363C
    private Sprite CreateSprite(string TID)
    {
        string    thumbPath = CaptureScreenHelper.GetThumbPath(TID);
        Texture2D texture2D;

        if (!File.Exists(thumbPath))
        {
            texture2D = (Texture2D)Resources.Load("Thumbs/Thumb_" + TID);
        }
        else
        {
            int width  = Screen.width;
            int width2 = Screen.width;
            texture2D = new Texture2D(width, width2);
            FileStream fileStream = new FileStream(thumbPath, FileMode.Open, FileAccess.Read);
            fileStream.Seek(0L, SeekOrigin.Begin);
            byte[] array = new byte[fileStream.Length];
            fileStream.Read(array, 0, (int)fileStream.Length);
            fileStream.Close();
            fileStream.Dispose();
            texture2D.LoadImage(array);
        }
        return(Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), new Vector2(0.5f, 0.5f)));
    }