使用下面的功能,我在尝试访问WriteableBitmap.PixelBuffer属性时遇到了问题。我得到的信息是:
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<title></title>
</head>
<body>
<p id="expand">Small or large business look no further for an office cleaning company in Raleigh. Feel confident that commercial cleaning services will get the job done right. Call or contact us today for a quote.</p>
<button id="toggle">Hide/Expand</button>
</body>
<script type="text/javascript">
$(document).ready(function () {
$("#expand").hide();
$("#toggle").on('click', function(){
$("#expand").toggle('slow');
})
});
</script>
</html>
我已阅读其他需要包含的地方
'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?)
但是当我使用这个包含时,我的代码没有任何变化。查看我的解决方案的参考资料,我没有看到像System.Runtime.InteropServices这样的内容。我很沮丧,因为这似乎是其他人试图访问WriteableBitmap的PixelBuffer的解决方案。
using System.Runtime.InteropServices.WindowsRuntime;
答案 0 :(得分:1)
确保引用该程序包所属的程序集:
System.Runtime.WindowsRuntime
汇编
答案 1 :(得分:0)
我最终通过其他方式解决了我原来的问题。为了调整图像的亮度,我最终使用了这个功能:
public ImageSource AdjustBrightness(BitmapImage Image, int Value, int mod)
{
Bitmap TempBitmap = BitmapImage2Bitmap(Image);
Bitmap NewBitmap = new Bitmap(TempBitmap.Width, TempBitmap.Height);
Graphics NewGraphics = Graphics.FromImage(NewBitmap);
float FinalValue = (float)Value / 255.0f;
float[][] FloatColorMatrix ={
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {mod * FinalValue, mod * FinalValue, mod * FinalValue, 1, 1}
};
ColorMatrix NewColorMatrix = new ColorMatrix(FloatColorMatrix);
ImageAttributes Attributes = new ImageAttributes();
Attributes.SetColorMatrix(NewColorMatrix);
NewGraphics.DrawImage(TempBitmap, new Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, GraphicsUnit.Pixel, Attributes);
Attributes.Dispose();
NewGraphics.Dispose();
return Bitmap2BitmapImage(NewBitmap);
}
答案 2 :(得分:-1)
您已将此方法声明为私有。您确定当您尝试访问该方法时,没有访问冲突。还可以通过右键单击包含此类的项目来检查解决方案资源管理器中的项目引用,并确保为System.Runtime.InteropServices.WindowsRuntime加载了正确的引用和程序集。以及任何其他必要的组件。