static bool Test() { try { DirectoryInfo info = new DirectoryInfo(@"C:\Users\Julio\Dropbox\CsJpgDec\Pics"); Stopwatch watch = new Stopwatch(); watch.Start(); foreach (var file in info.GetFiles()) { Console.WriteLine(file.FullName); Pixz.Decode(file.FullName); } watch.Stop(); Console.WriteLine("Test took: " + watch.ElapsedMilliseconds / 1000.0 + " s"); Console.ReadKey(); return(true); } catch (Exception ex) { Console.WriteLine("An error occured: :(" + ex.Message); Console.ReadKey(); return(false); } }
static void Main(string[] args) { //Environment.CurrentDirectory = @"D:\Documents\Tencent Files\1347360374\Image\Group\Image4\新建文件夹"; string path = args.Length > 2 ? args[1] : Environment.CurrentDirectory; var e = Directory.EnumerateFiles(path, "*.jpg").GetEnumerator(); while (e.MoveNext()) { var c = e.Current; var s = File.OpenRead(c); try { int count = Pixz.Decode(s)[0].Count; count = (int)Math.Log(count, 1.33); Directory.CreateDirectory(count.ToString()); s.Close(); s = null; File.Move(c, Path.Combine(count.ToString(), Path.GetFileName(c))); } catch (Exception ex) { Console.WriteLine(ex); } finally { s?.Close(); } } }
private void btnAbrir_Click(object sender, EventArgs e) { using (OpenFileDialog dialogo = new OpenFileDialog()) { dialogo.Filter = "JPEG Images (*.jpg; *.jpeg;)|*.jpg; *.jpeg; | All files (*.*)|*.*"; if (dialogo.ShowDialog() == DialogResult.OK) { Stopwatch watch = new Stopwatch(); watch.Start(); images = Pixz.Decode(dialogo.FileName); watch.Stop(); lblTiempo.Text = watch.ElapsedMilliseconds / 1000.0 + " s"; if (images.Count == 0) { MessageBox.Show("No se encontraron imágenes en el archivo"); return; } pbxOriginal.Image = images[0]; nudImagen.Value = 0; nudImagen.Minimum = 0; nudImagen.Maximum = images.Count - 1; } } }
public static void Read(BinaryReader reader, ImgInfo imgInfo, Pixz.Markers markerId) { Logger.Write("Unknown marker (" + markerId.ToString("X") + ")"); if (!imgInfo.startOfImageFound) { Logger.Write(" found outside of image"); } Logger.WriteLine(" at: " + (reader.BaseStream.Position - 2).ToString("X")); // Check if marker is not followed by a length argument if (markerId >= Pixz.Markers.Rs0 && markerId <= Pixz.Markers.Rs7) return; if (markerId == Pixz.Markers.LiteralFF) return; if (!imgInfo.startOfImageFound) return; ushort length = reader.ReadBEUInt16(); Logger.WriteLine("Length: " + length.ToString()); reader.BaseStream.Seek(length - 2, SeekOrigin.Current); }