Exemple #1
0
        unsafe bool CheckBlock(int i, short *next_point, short *point)
        {
            Metablock block = blocks[i];
            int       endX  = block.x + block.width;
            int       endY  = block.y + block.height;
            int       dist  = 0;

            for (int x = block.x; x < endX; x += 2)
            {
                for (int y = block.y; y < endY; y += 2)
                {
                    dist += Math.Abs(point[y * width + x] - next_point[y * width + x]);
                }
            }

            return(dist == 0);
        }
Exemple #2
0
        void CreateMetaclocks()
        {
            for (int x = 0; x < width; x += rect_size)
            {
                for (int y = 0; y < height; y += rect_size)
                {
                    Metablock block = new Metablock
                    {
                        x      = x,
                        y      = y,
                        width  = Math.Min(x + rect_size, width) - x,
                        height = Math.Min(y + rect_size, height) - y
                    };

                    blocks.Add(block);
                }
            }
        }
Exemple #3
0
        public Bitmap LoadFromStr(Stream str)
        {
            Bitmap     next      = new Bitmap(width, height);
            BitmapData next_data = next.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format16bppRgb565);

            unsafe
            {
                //pos один расчет положения в циклах
                int pos;

                short *next_point = (short *)next_data.Scan0.ToPointer();
                short *point      = (short *)data.Scan0.ToPointer();
                byte * b_point    = (byte *)point;
                while (str.Position < str.Length)
                {
                    Message   m     = (Message)formatter.Deserialize(str);
                    Metablock block = blocks[m.blockIndex];

                    int endX = block.x + block.width;
                    int endY = block.y + block.height;
                    for (int y = block.y; y < endY; y++)
                    {
                        for (int x = block.x; x < endX; x++)
                        {
                            pos              = (y * width + x) * 2;
                            b_point[pos]     = (byte)str.ReadByte();
                            b_point[pos + 1] = (byte)str.ReadByte();
                        }
                    }
                }

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        next_point[y * width + x] = point[y * width + x];
                    }
                }
            }
            next.UnlockBits(next_data);
            return(next);
        }