Travel through pixels in BMP

后端 未结 7 1083
梦谈多话
梦谈多话 2020-11-30 02:32

\"enter

Hi i have a bmp loaded to a BMP object and im requir

7条回答
  •  眼角桃花
    2020-11-30 03:09

    You cold use a Linq selection to obtain a IEnumerable object:

    var pixelColors =
        from x in Enumerable.Range(0, bmp.Width - 1)
        from y in Enumerable.Range(0, bmp.Height - 1)
        select bmp.GetPixel(x, y);
    

    ...then iterate on the IEnumerable (using implicit typing):

    foreach(var color in pixelColors)
    {
        //do stuff on RGB values, etc...
    }
    

提交回复
热议问题