예제 #1
0
        private byte[] getHuella(byte[] wsq)
        {
            byte[]       byteArray = new byte[0];
            MemoryStream ms        = new MemoryStream(wsq);

            byte[] data = new byte[ms.Length];
            ms.Read(data, 0, data.Length);
            WsqDecoder decoder = new WsqDecoder();
            Bitmap     bmp     = decoder.Decode(data);

            using (MemoryStream stream = new MemoryStream())
            {
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                stream.Close();
                byteArray = stream.ToArray();
            }
            return(byteArray);
        }
예제 #2
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            var path = Path.Combine(Helper.GetImagesPath(), "saved_fp.wsq");
            var enc  = new WsqEncoder();
            var dec  = new WsqDecoder();

            try
            {
                //var info = WsqCodec.GdiImageToImageInfo((Bitmap)inbox.Image);
                //var bytes = WsqCodec.Encode(info, 100, "This is David!");

                enc.Comment = "This is David!";
                var bytes = Encode(enc, (Bitmap)inbox.Image);

                File.WriteAllBytes(path, bytes);

                // Try to display the wsq image
                //var outinfo = WsqCodec.Decode(bytes);
                //if (outinfo != null && !outinfo.IsEmpty)
                //{
                //    var wsqbmp = WsqCodec.ImageInfoToGdiImage(outinfo);
                //    outbox.Image = wsqbmp;
                //}

                var outinfo = dec.Decode(bytes);
                var wsqbmp  = dec.DecodeGdi(bytes);
                outbox.Image = wsqbmp;

                var comments = WsqCodec.GetComments(bytes);

                outlogbox.AppendText(string.Format("Q            = {0}\r\n", nudQuality.Value));
                outlogbox.AppendText(string.Format("Cr           = {0}\r\n", nudCompressionRatio.Value));
                outlogbox.AppendText(string.Format("Br           = {0}\r\n", nudBitrate.Value));
                outlogbox.AppendText(string.Format("Size (bytes) = {0}\r\n", bytes.Length));
                LogInfo(outinfo, comments, outlogbox);
                outlogbox.AppendText("--------------------------------------------------------\r\n");
                outlogbox.Select(outlogbox.Text.Length, 0);
                outlogbox.ScrollToCaret();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, string.Format("Error: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        private void LoadWsq(string path)
        {
            var dec = new WsqDecoder();

            try
            {
                var bytes  = File.ReadAllBytes(path);
                var info   = dec.Decode(bytes);
                var bitmap = dec.DecodeGdi(bytes);
                pbox.Image = bitmap;

                var comments = WsqCodec.GetComments(bytes);

                LogInfo(info, comments);
                logbox.AppendText("--------------------------------------------------------\r\n");
                logbox.Select(logbox.Text.Length, 0);
                logbox.ScrollToCaret();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, string.Format("Error: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }