Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用图像和纹理遮罩平铺形状?_C#_Winforms_Drawing - Fatal编程技术网

C# 如何使用图像和纹理遮罩平铺形状?

C# 如何使用图像和纹理遮罩平铺形状?,c#,winforms,drawing,C#,Winforms,Drawing,如何使用纹理遮罩将带有纹理笔刷的圆角矩形应用于源图像 像这样的事。。。但是如何使用纹理遮罩呢 Bitmap textile = new Bitmap("textile.png"); TextureBrush textileBrush = new TextureBrush(textile); Bitmap outfit = new Bitmap("outfit.png"); Bitmap masksource = new Bitmap("mask.png");

如何使用纹理遮罩将带有纹理笔刷的圆角矩形应用于源图像

像这样的事。。。但是如何使用纹理遮罩呢

    Bitmap textile = new Bitmap("textile.png");
    TextureBrush textileBrush = new TextureBrush(textile);
    Bitmap outfit = new Bitmap("outfit.png");
    Bitmap masksource = new Bitmap("mask.png");

    Color bodyColorKey = Color.FromArgb(0, 255, 0);

    //what i should to do next and how to apply FillRectangle?
    using (Graphics g = Graphics.FromImage(outfit))
    {
        g.FillRectangle(textileBrush, new Rectangle(0, 0, ???, ???));
    }
装备: 还有他的面具: 纺织品质地: 以及在输出时应如何处理:


有没有关于系统绘图的想法?

使用遮罩图像,使给定颜色透明,并按如下方式组合图像

Bitmap textile = new Bitmap("textile.png");
        TextureBrush textileBrush = new TextureBrush(textile);
        Bitmap outfit = new Bitmap("outfit.png");
        Bitmap masksource = new Bitmap("mask.png");

        Bitmap transparentImage = new Bitmap(outfit.Width, outfit.Height);

        masksource.MakeTransparent(Color.FromArgb(255, 0, 255, 0));
        using (Graphics g = Graphics.FromImage(transparentImage))
        {
            g.DrawImage(outfit, new Point(0, 0));
            //g.DrawImage(textile, new Point(0, 0)); // use texture image
            g.FillRectangle(textileBrush, g.ClipBounds); // use texture image as Tile mode
            g.DrawImage(masksource, new Point(0, 0));
            transparentImage.MakeTransparent(Color.FromArgb(255, 255, 0, 0));
            transparentImage.MakeTransparent(Color.FromArgb(255, 0, 0, 255));
        }
        Bitmap outputImage = new Bitmap(outfit.Width, outfit.Height);
        using (Graphics g = Graphics.FromImage(outputImage))
        {
            g.DrawImage(outfit, new Point(0, 0));
            g.DrawImage(transparentImage, new Point(0, 0));
        }
只需要用纹理图像填充矩形

//what i should to do next and how to apply FillRectangle?
using (Graphics g = Graphics.FromImage(outfit))
{
    g.FillRectangle(textileBrush,g.ClipBounds);
}

你在找衣服吗?宽,宽,高?不。我正在寻找FillRectangle与纹理,基于纹理遮罩。在我的例子中,int y=0的每像素;y.身高;y++。。。。install.SetPixelx,y,textile.GetPixelx,y;将不起作用。输出将看起来很糟糕。我需要一个类似的东西,但用于FillRectangle,带有TextureBrush,用于瓷砖纺织纹理。在我的装备上使用面具形状纹理。几乎可以工作,需要一些改进,但现在我了解如何使用它们。