WinRT Loading an Image into a Byte array

后端 未结 1 1041
梦毁少年i
梦毁少年i 2021-01-25 06:20

I\'m trying to learn how to interact with the some of the WinRT (Metro) objects for images. Basically, I\'m working towards creating a \"GetPixel\" and \"SetPixel\" method that

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-25 07:01

    I have a WinRT version of the WriteableBitmapEx project here that does what you are looking for. Basically you need to load the image into a WriteableBitmap, then access its pixel buffer by calling PixelBuffer.AsStream(). Then you need to seek the stream to the x,y position (y * bmp.PixelWidth + x) to be able to read the pixel value. Then also convert the 4 bytes you get to the pixel format that works for you.

    EDIT*

    WriteableBitmapEx does natively support WinRT now.

    0 讨论(0)
提交回复
热议问题