public GroupPoint(List <cncPoint> _points, bool _select = false, DirrectionGroupPoint _dir = DirrectionGroupPoint.Left, bool _individ = false) { Points = _points; Selected = _select; //TempTraectory = _tempTraectory; Dirrect = _dir; IndividualPoints = _individ; }
private void GenVar1And2() { double sizeOnePoint = (double)numSizePoint.Value; //GlobalFunctions.LaserTimeOut = (int)LaserTimeOut.Value; pageVectorNOW = new List <GroupPoint>(); Bitmap bb = pageImageNOW; BitmapData data = bb.LockBits(new Rectangle(0, 0, bb.Width, bb.Height), ImageLockMode.ReadOnly, bb.PixelFormat); // make sure you check the pixel format as you will be looking directly at memory //направление движения DirrectionGroupPoint dir = DirrectionGroupPoint.Right; unsafe { byte *ptrSrc = (byte *)data.Scan0; int diff = data.Stride - data.Width; // example assumes 24bpp image. You need to verify your pixel depth for (int y = 0; y < data.Height; ++y) { List <cncPoint> tmp = new List <cncPoint>(); //во временный массив поместим линию с точками for (int x = 0; x < data.Width; ++x) { // windows stores images in BGR pixel order byte r = ptrSrc[0]; //тут получили нужный цвет if (r == 0) { tmp.Add(new cncPoint((x * sizeOnePoint) + (double)deltaX.Value, (y * sizeOnePoint) + (double)deltaY.Value, 0, 0, (int)LaserTimeOut.Value)); } ptrSrc += 1; } // а теперь временный массив скопируем в основной, но с определенным направлением if (dir == DirrectionGroupPoint.Right) { dir = DirrectionGroupPoint.Left; } else { tmp.Reverse(); dir = DirrectionGroupPoint.Right; } if (tmp.Count != 0) { pageVectorNOW.Add(new GroupPoint(tmp, false, dir, true)); } // ReSharper disable once RedundantAssignment tmp = new List <cncPoint>(); ptrSrc += diff; } } bb.UnlockBits(data); // тут нужно сделать преворот согластно текущй ориентации осей pageVectorNOW = VectorProcessing.Rotate(pageVectorNOW); }