// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; namespace E { public class Program { public static void Convert(string fnm) { Stream istm = new FileStream(fnm, FileMode.Open, FileAccess.Read); Stream ostm = new FileStream(fnm.Replace(".itc2", ".jpg"), FileMode.Create, FileAccess.Write); byte[] b = new byte[65536]; int n; bool first = true; while((n = istm.Read(b, 0, b.Length)) > 0) { int ix = 0; if(first) { while(b[ix] != 0xFF && b[ix+1] != 0xD8 && b[ix+2] != 0xFF && b[ix+3] != 0xE0) { ix++; if(ix > n - 4) throw new Exception(fnm + " does not conatin a JPG file"); } first = false; } ostm.Write(b, ix, n - ix); } ostm.Close(); istm.Close(); } public static void Main(string[] args) { Convert(@"C:\coverart.itc2"); } } }