public static BilinearScale ( System obj ) : void | ||
obj | System | |
Résultat | void |
public static void Scale(Texture2D tex, int newWidth, int newHeight) { TextureScale.texColors = tex.GetPixels(); TextureScale.newColors = new Color[newWidth * newHeight]; TextureScale.ratioX = 1f / ((float)newWidth / (float)(tex.width - 1)); TextureScale.ratioY = 1f / ((float)newHeight / (float)(tex.height - 1)); TextureScale.w = tex.width; TextureScale.w2 = newWidth; TextureScale.BilinearScale(0, newHeight); tex.Resize(newWidth, newHeight); tex.SetPixels(TextureScale.newColors); tex.Apply(); }
private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear) { TextureScale.texColors = tex.GetPixels(); TextureScale.newColors = new Color[newWidth * newHeight]; if (useBilinear) { TextureScale.ratioX = (float)(1.0 / ((double)newWidth / (double)(((Texture)tex).get_width() - 1))); TextureScale.ratioY = (float)(1.0 / ((double)newHeight / (double)(((Texture)tex).get_height() - 1))); } else { TextureScale.ratioX = (float)((Texture)tex).get_width() / (float)newWidth; TextureScale.ratioY = (float)((Texture)tex).get_height() / (float)newHeight; } TextureScale.w = ((Texture)tex).get_width(); TextureScale.w2 = newWidth; int num1 = Mathf.Min(SystemInfo.get_processorCount(), newHeight); int num2 = newHeight / num1; TextureScale.finishCount = 0; if (TextureScale.mutex == null) { TextureScale.mutex = new Mutex(false); } if (num1 > 1) { int num3; for (num3 = 0; num3 < num1 - 1; ++num3) { TextureScale.ThreadData threadData = new TextureScale.ThreadData(num2 * num3, num2 * (num3 + 1)); new Thread(!useBilinear ? new ParameterizedThreadStart(TextureScale.PointScale) : new ParameterizedThreadStart(TextureScale.BilinearScale)).Start((object)threadData); } TextureScale.ThreadData threadData1 = new TextureScale.ThreadData(num2 * num3, newHeight); if (useBilinear) { TextureScale.BilinearScale((object)threadData1); } else { TextureScale.PointScale((object)threadData1); } while (TextureScale.finishCount < num1) { Thread.Sleep(1); } } else { TextureScale.ThreadData threadData = new TextureScale.ThreadData(0, newHeight); if (useBilinear) { TextureScale.BilinearScale((object)threadData); } else { TextureScale.PointScale((object)threadData); } } tex.Resize(newWidth, newHeight); tex.SetPixels(TextureScale.newColors); tex.Apply(); }
// Token: 0x06000610 RID: 1552 RVA: 0x00024750 File Offset: 0x00022B50 private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear) { TextureScale.texColors = tex.GetPixels(); TextureScale.newColors = new Color[newWidth * newHeight]; if (useBilinear) { TextureScale.ratioX = 1f / ((float)newWidth / (float)(tex.width - 1)); TextureScale.ratioY = 1f / ((float)newHeight / (float)(tex.height - 1)); } else { TextureScale.ratioX = (float)tex.width / (float)newWidth; TextureScale.ratioY = (float)tex.height / (float)newHeight; } TextureScale.w = tex.width; TextureScale.w2 = newWidth; int num = Mathf.Min(SystemInfo.processorCount, newHeight); int num2 = newHeight / num; TextureScale.finishCount = 0; if (TextureScale.mutex == null) { TextureScale.mutex = new Mutex(false); } if (num > 1) { int i; TextureScale.ThreadData threadData; for (i = 0; i < num - 1; i++) { threadData = new TextureScale.ThreadData(num2 * i, num2 * (i + 1)); ParameterizedThreadStart start = (!useBilinear) ? new ParameterizedThreadStart(TextureScale.PointScale) : new ParameterizedThreadStart(TextureScale.BilinearScale); Thread thread = new Thread(start); thread.Start(threadData); } threadData = new TextureScale.ThreadData(num2 * i, newHeight); if (useBilinear) { TextureScale.BilinearScale(threadData); } else { TextureScale.PointScale(threadData); } while (TextureScale.finishCount < num) { Thread.Sleep(1); } } else { TextureScale.ThreadData obj = new TextureScale.ThreadData(0, newHeight); if (useBilinear) { TextureScale.BilinearScale(obj); } else { TextureScale.PointScale(obj); } } tex.Resize(newWidth, newHeight); tex.SetPixels(TextureScale.newColors); tex.Apply(); TextureScale.texColors = null; TextureScale.newColors = null; }