Effective way of making negative of image without external dlls

前端 未结 2 644
误落风尘
误落风尘 2021-01-03 05:38

That is the solution to make a negative from a image in C# Windows Forms without any dlls and in a effective, fast way?

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-03 06:00

    Go through all the pixels one by one (Bitmap.GetPixel() or something) and subtract the RGB values from 0xff to create a pixel of negative color. Save this pixel to a new image or onto the same image using (Bitmap.SetPixel()) at the same position.

        // Retrieve the image.
        var image1 = new Bitmap(@"C:\Documents and Settings\All Users\" 
            + @"Documents\My Music\music.bmp", true);
    
        int x, y;
    
        // Loop through the images pixels to reset color.
        for(x=0; x

提交回复
热议问题