Единство перевернуть текстуру с использованием c#C#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Единство перевернуть текстуру с использованием c#

Сообщение Anonymous »

Как мне позвонить в метод Fliptexturetrically в MakePhoto? < /p>

Моя фотография, сделанная в настоящее время, с ног на голову в Unity, и я наткнулся на этот код переворачивания текстуры, но я не знаю, как его применить. < /p>

Очень признателен, если бы кто -то мог мне помочь! < /p>

public static Texture2D FlipTextureVertically(Texture2D original)
{
Texture2D flipped = new Texture2D(original.width, original.height, TextureFormat.ARGB32, false);

int xN = original.width;
int yN = original.height;

for (int i = 0; i < xN; i++)
{
for (int j = 0; j < yN; j++)
{
flipped.SetPixel(i, yN - j - 1, original.GetPixel(i, j));
}
}

flipped.Apply();

return flipped;
}

public string MakePhoto(bool openIt)
{
int resWidth = Screen.width;
int resHeight = Screen.height;

Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false); //Create new texture
RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);

// hide the info-text, if any
if (infoText)
{
infoText.text = string.Empty;
}
// render background and foreground cameras
if (backroundCamera && backroundCamera.enabled)
{
backroundCamera.targetTexture = rt;
backroundCamera.Render();
backroundCamera.targetTexture = null;
}

if (backroundCamera2 && backroundCamera2.enabled)
{
backroundCamera2.targetTexture = rt;
backroundCamera2.Render();
backroundCamera2.targetTexture = null;
}

if (foreroundCamera && foreroundCamera.enabled)
{
foreroundCamera.targetTexture = rt;
foreroundCamera.Render();
foreroundCamera.targetTexture = null;
}

// get the screenshot
RenderTexture prevActiveTex = RenderTexture.active;
RenderTexture.active = rt;

screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);

// clean-up
RenderTexture.active = prevActiveTex;
Destroy(rt);

byte[] btScreenShot = screenShot.EncodeToJPG();
Destroy(screenShot);

// save the screenshot as jpeg file
string sDirName = Application.persistentDataPath + "/Screenshots";
if (!Directory.Exists(sDirName))
Directory.CreateDirectory (sDirName);

string sFileName = sDirName + "/" + string.Format ("{0:F0}", Time.realtimeSinceStartup * 10f) + ".jpg";
File.WriteAllBytes(sFileName, btScreenShot);

Debug.Log("Photo saved to: " + sFileName);
if (infoText)
{
infoText.text = "Saved to: " + sFileName;
}

// open file
if(openIt)
{
System.Diagnostics.Process.Start(sFileName);
}

return sFileName;
}


Подробнее здесь: https://stackoverflow.com/questions/546 ... ng-c-sharp
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»