private void CreateImage() { _Image = new Bitmap(32, 32); Color[] cols = null; if (_Pattern == null && _PreviewSprite != null) { cols = ((Texture2D)_PreviewSprite.texture).GetPixels(); } for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { if (_Pattern != null) { int index = _Pattern.GetPixel(x, y); System.Drawing.Color col = System.Drawing.Color.FromArgb(0, 0, 0, 0); if (index < 15) { col = System.Drawing.Color.FromArgb(_Pattern.Palette[index].R, _Pattern.Palette[index].G, _Pattern.Palette[index].B); } _Image.SetPixel(x, y, col); } else if (cols != null) { _Image.SetPixel(x, 32 - y, System.Drawing.Color.FromArgb((byte)(cols[x + y * 32].a * 255f), (byte)(cols[x + y * 32].r * 255f), (byte)(cols[x + y * 32].g * 255f), (byte)(cols[x + y * 32].b * 255f))); } } } }
private static Color ToUnityColor(System.Drawing.Color netColor) { return(new Color(netColor.R / 255f, netColor.G / 255f, netColor.B / 255f, netColor.A / 255f)); }