Question: I have a 1 dimensional array of bytes, with separate values for A, R, G, and B, and I know the height and width of the expected image. How can I encode this data and save it as a PNG?

Answer: 
You can use a Bitmap and [Bitmap.SetPixel()](https://msdn.microsoft.com/en-us/library/system.drawing.bitmap.setpixel%28v=vs.110%29.aspx).

Then [save the Bitmap as png](https://msdn.microsoft.com/en-us/library/9t4syfhh%28v=vs.110%29.aspx) using `ImageFormat.Png` . Also, you might have to make sure that [the Bitmap format maintains transparency](https://stackoverflow.com/a/7666180/939213) .

(See the other answer here for a faster way than SetPixel.)

EDIT

Perhaps [WPF](https://msdn.microsoft.com/en-us/library/aa346816%28v=vs.110%29.aspx) can use the array directly. (I don't have much experience with it.)
I suggest it is better to look for a platform-independent solution that doesn't depend on building a desktop image or a Bitmap (neither GDI+ Bitmap nor WPF WriteableBitmap). BigGustave (available on NuGet) did the trick for me. <https://github.com/EliotJones/BigGustave> It creates the PNGs directly.