public static void PointScale(object obj) { TextureScale.ThreadData threadData = (TextureScale.ThreadData)obj; for (int start = threadData.start; start < threadData.end; ++start) { int num1 = (int)((double)TextureScale.ratioY * (double)start) * TextureScale.w; int num2 = start * TextureScale.w2; for (int index = 0; index < TextureScale.w2; ++index) { TextureScale.newColors[num2 + index] = TextureScale.texColors[(int)((double)num1 + (double)TextureScale.ratioX * (double)index)]; } } TextureScale.mutex.WaitOne(); ++TextureScale.finishCount; TextureScale.mutex.ReleaseMutex(); }
// Token: 0x06000612 RID: 1554 RVA: 0x00024A2C File Offset: 0x00022E2C public static void PointScale(object obj) { TextureScale.ThreadData threadData = (TextureScale.ThreadData)obj; for (int i = threadData.start; i < threadData.end; i++) { int num = (int)(TextureScale.ratioY * (float)i) * TextureScale.w; int num2 = i * TextureScale.w2; for (int j = 0; j < TextureScale.w2; j++) { TextureScale.newColors[num2 + j] = TextureScale.texColors[(int)((float)num + TextureScale.ratioX * (float)j)]; } } TextureScale.mutex.WaitOne(); TextureScale.finishCount++; TextureScale.mutex.ReleaseMutex(); }
public static void BilinearScale(object obj) { TextureScale.ThreadData threadData = (TextureScale.ThreadData)obj; for (int start = threadData.start; start < threadData.end; ++start) { int num1 = (int)Mathf.Floor((float)start * TextureScale.ratioY); int num2 = num1 * TextureScale.w; int num3 = (num1 + 1) * TextureScale.w; int num4 = start * TextureScale.w2; for (int index = 0; index < TextureScale.w2; ++index) { int num5 = (int)Mathf.Floor((float)index * TextureScale.ratioX); float num6 = (float)index * TextureScale.ratioX - (float)num5; TextureScale.newColors[num4 + index] = TextureScale.ColorLerpUnclamped(TextureScale.ColorLerpUnclamped(TextureScale.texColors[num2 + num5], TextureScale.texColors[num2 + num5 + 1], num6), TextureScale.ColorLerpUnclamped(TextureScale.texColors[num3 + num5], TextureScale.texColors[num3 + num5 + 1], num6), (float)start * TextureScale.ratioY - (float)num1); } } TextureScale.mutex.WaitOne(); ++TextureScale.finishCount; TextureScale.mutex.ReleaseMutex(); }
// Token: 0x06000611 RID: 1553 RVA: 0x000248F0 File Offset: 0x00022CF0 public static void BilinearScale(object obj) { TextureScale.ThreadData threadData = (TextureScale.ThreadData)obj; for (int i = threadData.start; i < threadData.end; i++) { int num = (int)Mathf.Floor((float)i * TextureScale.ratioY); int num2 = num * TextureScale.w; int num3 = (num + 1) * TextureScale.w; int num4 = i * TextureScale.w2; for (int j = 0; j < TextureScale.w2; j++) { int num5 = (int)Mathf.Floor((float)j * TextureScale.ratioX); float value = (float)j * TextureScale.ratioX - (float)num5; TextureScale.newColors[num4 + j] = TextureScale.ColorLerpUnclamped(TextureScale.ColorLerpUnclamped(TextureScale.texColors[num2 + num5], TextureScale.texColors[num2 + num5 + 1], value), TextureScale.ColorLerpUnclamped(TextureScale.texColors[num3 + num5], TextureScale.texColors[num3 + num5 + 1], value), (float)i * TextureScale.ratioY - (float)num); } } TextureScale.mutex.WaitOne(); TextureScale.finishCount++; TextureScale.mutex.ReleaseMutex(); }
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; }