Exemplo n.º 1
0
        /// <summary>
        /// This method opens the ZIF-file.
        /// </summary>
        /// <returns>Returns a status boolean value of the file opening proces </returns>
        public bool OpenDocument()
        {
            OpenFileDialog dlg = new OpenFileDialog()
            {
                Filter = "ZuydImage Format | *.zif"
            };

            if (dlg.ShowDialog() == true)
            {
                if (Path.GetExtension(dlg.FileName) != ".zif")
                {
                    return(false);
                }

                CurrentFile = Path.GetFileName(dlg.FileName);

                using (Stream stream = dlg.OpenFile())
                {
                    // Read stream
                    BinaryReader br = new BinaryReader(stream);

                    // add to fileList
                    fileBinary = new FileBinary(br.ReadBytes((int)stream.Length));
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets DrawingBoard
        /// </summary>
        /// <param name="fileBinary"></param>
        /// <returns>Returns statusvalue of drawing process</returns>
        public bool SetDrawing(FileBinary fileBinary)
        {
            //
            resetDrawBoard();

            // variables
            byte[] bytesPixel = new byte[4];

            int count = 0;
            int red, green, blue, alpha;

            red = green = blue = alpha = 0;

            for (int i = 0; i < fileBinary.binary[0].Length; i++)
            {
                bytesPixel[count] = fileBinary.binary[0][i];

                if (count != 0 && count % 3 == 0)
                {
                    blue = BitConverter.ToInt32(bytesPixel, 0) != 0
                        ? 255 // zwarte pixel
                        : 0;  // witte pixel

                    pixels.Add((uint)((blue << 24) + (green << 16) + (red << 8) + alpha));
                    count = 0;
                }
                else
                {
                    count++;
                }
            }

            pixels.Add(pixels[0]);
            //
            DrawBoard();
            return(true); // testing
        }
Exemplo n.º 3
0
 public void ResetDocument()
 {
     // resets
     fileBinary  = null;
     CurrentFile = null;
 }