如何将颜色更改为黑白到屏幕的左上角三角形? [英] How to change colors to black-white into the top left triangle of the screen?

查看:54
本文介绍了如何将颜色更改为黑白到屏幕的左上角三角形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

  public 位图MakeScreenshot()
{
Bitmap Bitmap = new 位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
Graphics Graphics = Graphics.FromImage(Bitmap);
Graphics.CopyFromScreen( 0 0 0 0 ,Screen.PrimaryScreen.Bounds.Size,CopyPixelOperation.SourceCopy);

return 位图;
}

// Reduce Screenshot Method
public static void ReduceScreenshot( string fileName)
{
var bmpSS = 新的位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
var gfxSS = Graphics.FromImage(bmpSS);
gfxSS.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,Screen.PrimaryScreen.Bounds.Y, 0 0 ,Screen.PrimaryScreen.Bounds.Size,CopyPixelOperation.SourceCopy);

ColorMatrix colorMatrix = new ColorMatrix(
new float [] []
{
new float [] { 1 .5f, 1 .5f, 1 .5f, 0 0 },
< span class =code-keyword> new float [] { 1 .5f, 1 .5f, 1 .5f, 0 0 },
new float [] { 1 .5f, 1 .5f, 1 .5f, 0 0 },
new float [] { 0 0 0 1 0 } ,
new float [] {-1,-1,-1, 0 1 }
});

ImageAttributes attributes = new ImageAttributes();
attributes.SetColorMatrix(colorMatrix);
Rectangle abc = new 矩形(-783,-383,bmpSS.Width,bmpSS.Height);
gfxSS.DrawImage(bmpSS,abc,-783,-383,bmpSS.Width,bmpSS.Height,GraphicsUnit.Pixel,attributes);

bmpSS.Save( ScreenshotGray.png,ImageFormat.Png) ;
}

}





它是如何工作的http://take.ms/6tzvU [ ^ ]。我应该如何将区域从矩形更改为三角形?

解决方案

请参阅 http://www.flipcode.com/archives/Win32_Window_Skinning.shtml [ ^ ]。

Here is my code:

    public Bitmap MakeScreenshot()
    {
        Bitmap Bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        Graphics Graphics = Graphics.FromImage(Bitmap);
        Graphics.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

        return Bitmap;
    }

    //Reduce Screenshot Method
    public static void ReduceScreenshot(string fileName)
    {
        var bmpSS = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        var gfxSS = Graphics.FromImage(bmpSS);
        gfxSS.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

        ColorMatrix colorMatrix = new ColorMatrix(
           new float[][]
           {
               new float[] { 1.5f, 1.5f, 1.5f, 0, 0},
               new float[] { 1.5f,1.5f, 1.5f, 0, 0},
               new float[] {1.5f, 1.5f, 1.5f, 0, 0},
               new float[] {0, 0, 0, 1, 0},
               new float[] {-1, -1, -1, 0, 1}
           });

        ImageAttributes attributes = new ImageAttributes();
        attributes.SetColorMatrix(colorMatrix);
        Rectangle abc= new Rectangle(-783, -383, bmpSS.Width, bmpSS.Height);
        gfxSS.DrawImage(bmpSS, abc, -783, -383, bmpSS.Width, bmpSS.Height, GraphicsUnit.Pixel, attributes);

        bmpSS.Save("ScreenshotGray.png", ImageFormat.Png);
    }

}



It's how it work http://take.ms/6tzvU[^]. How should i change area from rectangle to triangle?

解决方案

See http://www.flipcode.com/archives/Win32_Window_Skinning.shtml[^].


这篇关于如何将颜色更改为黑白到屏幕的左上角三角形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆