Beispiel #1
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            byte  picNum = byte.Parse(picNumberBox.SelectedItem.ToString().Remove(0, 3));           //picNumberBox.SelectedItem.ToString().Replace;
            Pic8x v      = new Pic8x((byte)(picNum - 1));

            byte[] data  = new byte[768];
            byte   b     = 0;
            int    index = 0;
            int    bit   = 7;

            for (int j = 0; j < 64; j++)
            {
                for (int i = 0; i < 96; i++)
                {
                    int val = p.GetPixel(i, j).ToArgb().Equals(Color.Black.ToArgb()) ? 1 : 0;
                    b |= (byte)(val << bit--);
                    if (bit == -1)
                    {
                        bit           = 7;
                        data[index++] = b;
                        b             = 0;
                    }
                }
            }
            v.SetData(new object[] { "768", data });
            StreamWriter s = new StreamWriter(picNumberBox.SelectedItem.ToString() + ".8xi");

            v.Save(new BinaryWriter(s.BaseStream));
            s.Close();
        }
Beispiel #2
0
 private void Open(string fileName)
 {
     if (File.Exists(fileName))
     {
         FileInfo fi = new FileInfo(fileName);
         if (fi.Extension.ToLower() == ".8xi")
         {
             using (FileStream fs = new FileStream(fileName, FileMode.Open)) {
                 using (BinaryReader b = new BinaryReader(fs)) {
                     //Pic8x pic = (Pic8x)Var8x.FromBinaryReader(b);
                     Pic8x pic = new Pic8x(b);
                     p = pic.GetBitmap() ?? p;
                 }
             }
         }
         else if (fi.Extension.ToLower() == ".bmp" || fi.Extension.ToLower() == ".png" ||
                  fi.Extension.ToLower() == ".jpg" || fi.Extension.ToLower() == ".jpeg" ||
                  fi.Extension.ToLower() == ".gif")
         {
             using (Bitmap a = new Bitmap(fileName)) {
                 CropImageDialog cid = new CropImageDialog(a);
                 cid.ShowDialog();
                 p = cid.outMap ?? p;
                 canvas.Invalidate();
             }
         }
     }
     canvas.Invalidate();
 }