下面的代码创建了一个透明的图片
var bitmap = new SoftwareBitmap(BitmapPixelFormat.Rgba8, 192, 192); var writer = new DataWriter(); for (int i = 0; i < 192 * 192; i++) { writer.WriteUInt32(0); } bitmap.CopyFromBuffer(writer.DetachBuffer()); using var file = File.OpenWrite("icon_background.png"); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, file.AsRandomAccessStream()); encoder.SetSoftwareBitmap(bitmap); await encoder.FlushAsync();