public void SizeUp(int addSize)
 {
     for (int i = 0; i < addSize; i++)
     {
         var obj = Transform.Instantiate(Target);
         Clones.Add(obj);
         obj.gameObject.SetActive(false);
         obj.name += Size - 1;
         obj.transform.SetParent(parentObject);
     }
     Enumerator = Clones.GetEnumerator();
 }
Пример #2
0
        private void Comapre(MyImageInfo other)
        {
            var thisfn  = FileName;
            var otherfn = other.FileName;

            bool      equals = true;
            Rectangle rect1  = new Rectangle(0, 0, iBitmap.Width, iBitmap.Height);
            Rectangle rect2  = new Rectangle(0, 0, other.iBitmap.Width, other.iBitmap.Height);

            if (rect1.Width == rect2.Width && rect1.Height == rect2.Height)
            {
                BitmapData bmpData1 = iBitmap.LockBits(rect1, ImageLockMode.ReadOnly, iBitmap.PixelFormat);
                BitmapData bmpData2 = other.iBitmap.LockBits(rect1, ImageLockMode.ReadOnly, other.iBitmap.PixelFormat);
                unsafe
                {
                    byte *ptr1  = (byte *)bmpData1.Scan0.ToPointer();
                    byte *ptr2  = (byte *)bmpData2.Scan0.ToPointer();
                    int   width = rect1.Width * 3; // for 24bpp pixel data
                    for (int y = 0; equals && y < rect1.Height; y++)
                    {
                        for (int x = 0; x < width; x++)
                        {
                            if (*ptr1 != *ptr2)
                            {
                                equals = false;
                                break;
                            }
                            ptr1++;
                            ptr2++;
                        }
                        ptr1 += bmpData1.Stride - width;
                        ptr2 += bmpData2.Stride - width;
                    }
                }
                iBitmap.UnlockBits(bmpData1);
                other.iBitmap.UnlockBits(bmpData2);

                if (equals)
                {
                    Clones.Add(other);
                    other.Clones.Add(this);
                }
            }
        }