Пример #1
0
        public override int DrawBatch(int maxBlocksToDraw)
        {
            int blocksDone = 0;

            //byte sid = 255;
            for (; imageX <= maxX; imageX++)
            {
                for (; imageY <= maxY; imageY++)
                {
                    // find matching palette entry
                    System.Drawing.Color color = ImageBitmap.GetPixel(imageX, imageY);
                    drawBlocks = Palette.FindBestMatch(color);
                    Coords.Z   = coordOffsets.Z - (imageY - minY);
                    // draw layers
                    for (; layer < Palette.Layers; layer++)
                    {
                        Coords.X = (imageX - minX) * coordMultiplierX + coordOffsets.X + layerVector.X * layer;
                        Coords.Y = (imageX - minX) * coordMultiplierY + coordOffsets.Y + layerVector.Y * layer;
                        if (DrawOneBlock())
                        {
                            blocksDone++;

                            /*BoundingBox placetobuild = new BoundingBox(Coords.X, Coords.Y, Coords.Z, Coords.X, Coords.Y, Coords.Z);
                             * string rtn = "" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
                             * Block newBlock = Player.WorldMap.GetBlock(placetobuild.XMin, placetobuild.YMin, placetobuild.ZMin);
                             * if (newBlock != Block.Air)
                             * {
                             *  Player.Send(Packet.MakeMakeSelection(sid, "DrawImage" + sid, placetobuild, rtn, 255));
                             *  if (sid == 0) {
                             *      sid = 255;
                             *  } else {
                             *      sid--;
                             *  }
                             * }*/
                            if (blocksDone >= maxBlocksToDraw)
                            {
                                layer++;
                                return(blocksDone);
                            }
                        }
                    }
                    layer = 0;
                }
                imageY = minY;
                if (TimeToEndBatch)
                {
                    imageX++;
                    return(blocksDone);
                }
            }
            IsDone = true;
            return(blocksDone);
        }
Пример #2
0
        public override int DrawBatch(int maxBlocksToDraw)
        {
            int blocksDone = 0;

            for ( ; imageX <= maxX; imageX++)
            {
                for ( ; imageY <= maxY; imageY++)
                {
                    // find matching palette entry
                    System.Drawing.Color color = ImageBitmap.GetPixel(imageX, imageY);
                    drawBlocks = Palette.FindBestMatch(color);
                    Coords.Z   = coordOffsets.Z - (imageY - minY);
                    // draw layers
                    for ( ; layer < Palette.Layers; layer++)
                    {
                        Coords.X = (imageX - minX) * coordMultiplierX + coordOffsets.X + layerVector.X * layer;
                        Coords.Y = (imageX - minX) * coordMultiplierY + coordOffsets.Y + layerVector.Y * layer;
                        if (DrawOneBlock())
                        {
                            blocksDone++;
                            if (blocksDone >= maxBlocksToDraw)
                            {
                                layer++;
                                return(blocksDone);
                            }
                        }
                    }
                    layer = 0;
                }
                imageY = minY;
                if (TimeToEndBatch)
                {
                    imageX++;
                    return(blocksDone);
                }
            }
            IsDone = true;
            return(blocksDone);
        }
Пример #3
0
        private void InitializeImage()
        {
            photo    = new Color[Image.Width, Image.Height];
            newPhoto = new Color[Image.Width, Image.Height];

            for (int i = 0; i < Image.Width; i++)
            {
                for (int j = 0; j < Image.Height; j++)
                {
                    if (i < ImageBitmap.Width && j < ImageBitmap.Height)
                    {
                        Color pixel = ImageBitmap.GetPixel(i, j);
                        photo[i, j]    = pixel;
                        newPhoto[i, j] = pixel;
                    }
                    else
                    {
                        photo[i, j]    = Color.White;
                        newPhoto[i, j] = Color.White;
                    }
                }
            }
        }