以下の関数では、WriteableBitmap.PixelBufferプロパティにアクセスしようとして問題が発生しています。私は取得していますメッセージは次のとおりです。'using'ステートメントが無視されています
'WriteableBitmap' does not contain a definition for 'PixelBuffer' and no extension method 'PixelBuffer' accepting a first argument of type 'WriteableBitmap' could be found (are you missing a using directive or an assembly reference?)
私は
using System.Runtime.InteropServices.WindowsRuntime;
を含める必要がある他の場所を読みました。しかし、私はこれが含ま使用した場合、何も私のコードでは変化しません。私の解決策の参考資料を見ると、System.Runtime.InteropServicesのようなものは見当たりません。これはWriteableBitmapのPixelBufferにアクセスしようとしている他の人たちの解決策であるように思えます。
private WriteableBitmap ChangeBrightness(WriteableBitmap source, byte change_value)
{
WriteableBitmap dest = new WriteableBitmap(source);
byte[] color = new byte[4];
using (Stream s = source.PixelBuffer.AsStream())
{
using (Stream d = dest.PixelBuffer.AsStream())
{
// read the pixel color
while (s.Read(color, 0, 4) > 0)
{
// color[0] = b
// color[1] = g
// color[2] = r
// color[3] = a
// do the adding algo per byte (skip the alpha)
for (int i = 0; i < 4; i++)
{
if ((int)color[i] + change_value > 255) color[i] = 255; else color[i] = (byte)(color[i] + change_value);
}
// write the new pixel color
d.Write(color, 0, 4);
}
}
}
// return the new bitmap
return dest;
}
コードのどの部分が機能しませんか。 'WriteableBitmap'が認識されないか、何ですか? – MrZander
'PixelBuffer'は[' Windows.UI.Xaml.Media.Imaging.WriteableBitmap'](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml)のメンバーであるようです。 media.imaging.writeablebitmap#Windows_UI_Xaml_Media_Imaging_WriteableBitmap_PixelBuffer)、間違ったものを使用しましたか? – DavidG
http://stackoverflow.com/questions/20478467/stream-stream-writeablebitmap-pixelbuffer-asstream-missingこれは関連性が高いようですが、特にアセンブリ/名前空間に関する質問のコメント – MrZander