public static void ReadByte(string scode, com_pixelEdit edit) { try { var src = edit.edit; var p = edit.palette; string strbase64 = System.Uri.UnescapeDataString(scode); byte[] bb = System.Convert.FromBase64String(strbase64); var s = LZMAHelper.DeCompress(new System.IO.MemoryStream(bb), (uint)bb.Length); bb = new byte[s.Length]; s.Read(bb, 0, bb.Length); int seek = 0; int width = bb[seek]; seek++; if (width == 0) { width = 256; } int height = bb[seek]; seek++; if (height == 0) { height = 256; } Debug.Log("w=" + width + ",h=" + height); edit.Resize(width, height); Color32[] pp = src.GetPixels32(0); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { byte ind = bb[seek]; seek++; pp[y * width + x].a = ind; } } src.SetPixels32(pp, 0); src.Apply(); Color32[] ppp = p.GetPixels32(0); int c = bb[seek]; seek++; for (int i = 0; i < c; i++) { byte inde = bb[seek]; seek++; byte r = bb[seek]; seek++; byte g = bb[seek]; seek++; byte b = bb[seek]; seek++; ppp[inde].r = r; ppp[inde].g = g; ppp[inde].b = b; } p.SetPixels32(ppp); p.Apply(); } catch { } }
public static void ReadByte(string scode, com_pixelEdit edit) { try { var src = edit.edit; var p = edit.palette; string strbase64 = System.Uri.UnescapeDataString(scode); byte[] bb = System.Convert.FromBase64String(strbase64); var s = LZMAHelper.DeCompress(new System.IO.MemoryStream(bb), (uint)bb.Length); bb = new byte[s.Length]; s.Read(bb, 0, bb.Length); int seek = 0; int width = bb[seek]; seek++; if (width == 0) width = 256; int height = bb[seek]; seek++; if (height == 0) height = 256; Debug.Log("w=" + width + ",h=" + height); edit.Resize(width, height); Color32[] pp = src.GetPixels32(0); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { byte ind = bb[seek]; seek++; pp[y * width + x].a = ind; } } src.SetPixels32(pp, 0); src.Apply(); Color32[] ppp = p.GetPixels32(0); int c = bb[seek]; seek++; for (int i = 0; i < c; i++) { byte inde = bb[seek]; seek++; byte r = bb[seek]; seek++; byte g = bb[seek]; seek++; byte b = bb[seek]; seek++; ppp[inde].r = r; ppp[inde].g = g; ppp[inde].b = b; } p.SetPixels32(ppp); p.Apply(); } catch { } }