@Override public int FromByteArrayV1(byte[] BA, int Idx) throws IOException { Idx = super.FromByteArrayV1(BA, Idx); // . Idx = N0.FromByteArray(BA, Idx); Idx = N1.FromByteArray(BA, Idx); Idx = N2.FromByteArray(BA, Idx); Idx = N3.FromByteArray(BA, Idx); // . Width = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx); Idx += 4; Height = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx); Idx += 4; // . int DataSize = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx); Idx += 4; int LC = DataSize / TLevelParams.Size; Levels = new TLevelParams[LC]; for (int I = 0; I < LC; I++) { Levels[I] = new TLevelParams(); Idx = Levels[I].FromByteArray(BA, Idx); } // . return Idx; }
public byte[] ToByteArrayV1() throws IOException { ByteArrayOutputStream BOS = new ByteArrayOutputStream(1024); try { BOS.write(super.ToByteArrayV1()); // . BOS.write(N0.ToByteArray()); BOS.write(N1.ToByteArray()); BOS.write(N2.ToByteArray()); BOS.write(N3.ToByteArray()); // . byte[] BA = TDataConverter.ConvertInt32ToLEByteArray(Width); BOS.write(BA); BA = TDataConverter.ConvertInt32ToLEByteArray(Height); BOS.write(BA); // . int DataSize = 0; if (Levels != null) DataSize = Levels.length * TLevelParams.Size; BA = TDataConverter.ConvertInt32ToLEByteArray(DataSize); BOS.write(BA); if (DataSize > 0) for (int I = 0; I < Levels.length; I++) BOS.write(Levels[I].ToByteArray()); // . return BOS.toByteArray(); // . -> } finally { BOS.close(); } }