SFML.Graphics.Image.Copy C# (CSharp) Method

Copy() public method

Copy pixels from another image onto this one. This function does a slow pixel copy and should only be used at initialization time
public Copy ( Image source, uint destX, uint destY ) : void
source Image Source image to copy
destX uint X coordinate of the destination position
destY uint Y coordinate of the destination position
return void
        public void Copy(Image source, uint destX, uint destY)
        {
            Copy(source, destX, destY, new IntRect(0, 0, 0, 0));
        }

Same methods

Image::Copy ( Image source, uint destX, uint destY, IntRect sourceRect ) : void
Image::Copy ( Image source, uint destX, uint destY, IntRect sourceRect, bool applyAlpha ) : void

Usage Example

示例#1
0
        private void btnSplit_Click(object sender, EventArgs e)
        {
            if (Resource != null)
            {
                btnSplit.Visible = false;

                if (!Directory.Exists(txtOutputPath.Text))
                {
                    Directory.CreateDirectory(txtOutputPath.Text);
                }

                var srcExt = txtFile.Text.Substring(
                    txtFile.Text.LastIndexOf(".") + 1);
                var srcName = txtFile.Text.Substring(
                    txtFile.Text.LastIndexOf(Path.DirectorySeparatorChar) + 1).Replace("." + srcExt, string.Empty);

                var cols   = ((int)numericX.Value >= 1) ? (int)numericX.Value : 1;
                var rows   = ((int)numericY.Value >= 1) ? (int)numericY.Value : 1;
                var width  = (int)Resource.Image.Size.X / cols;
                var height = (int)Resource.Image.Size.Y / rows;

                for (int r = 0; r < rows; r++)
                {
                    for (int c = 0; c < cols; c++)
                    {
                        var destName = txtOutputFormat.Text.Replace(
                            "%f", srcName).Replace(
                            "%ext", srcExt).Replace(
                            "%r", r.ToString()).Replace(
                            "%c", c.ToString()).Replace(
                            "%t", ((r * cols) + c).ToString());

                        Image image = new Image((uint)width, (uint)height);
                        image.Copy(Resource.Image, 0, 0, new IntRect(c * width, r * height, width, height));

                        image.SaveToFile(txtOutputPath.Text + destName);
                        image?.Dispose();
                        image = null;

                        Application.DoEvents();
                    }
                }

                btnSplit.Visible = true;
            }

            txtFile.Focus();
        }
All Usage Examples Of SFML.Graphics.Image::Copy