Beispiel #1
0
        public static ProjImage FromStream(Stream stream)
        {
            BinaryReader br = new BinaryReader(stream);

            if (br.ReadUInt16() != FileHead)
            {
                throw new Exception("错误的文件格式");
            }
            if (br.ReadUInt32() != FileVersion)
            {
                throw new Exception("不支持的(老)文件版本");
            }
            string    des   = br.ReadString();
            int       count = br.ReadInt32();
            ProjImage img   = new ProjImage();

            img.Description = des;
            for (int i = 0; i < count; i++)
            {
                Proj p = new Proj();
                p.ProjType = br.ReadInt32();
                float a = br.ReadSingle();
                float b = br.ReadSingle();
                p.Location = new MPointF(a, b);
                float c = br.ReadSingle();
                float d = br.ReadSingle();
                p.Speed = new MPointF(c, d);
                img.Projs.Add(p);
            }
            return(img);
        }
Beispiel #2
0
 public void DrawImage(ProjImage image, MPointF location)
 {
     foreach (var proj in image.Projs)
     {
         var newImg = proj;
         newImg.Location += location;
         Projs.Add(newImg);
     }
 }
Beispiel #3
0
        public static ProjImage FromImage(string file, int projType, int resolution)
        {
            Bitmap    img  = (Bitmap)Image.FromFile(file);
            ProjImage proj = new ProjImage();

            proj.Resolution = resolution;
            for (int i = 0; i < img.Width; i++)
            {
                for (int j = 0; j < img.Height; j++)
                {
                    if (img.GetPixel(i, j).A != 0)
                    {
                        Proj p = new Proj();
                        p.ProjType = projType;
                        p.Location = new MPointF(i * resolution, j * resolution);
                        proj.Projs.Add(p);
                    }
                }
            }
            return(proj);
        }