【发布时间】:2012-04-19 07:41:09
【问题描述】:
所有,我有一个基本的 Windows 7 Phone 应用程序,我刚刚完成了一个裁剪页面,用户可以在其中裁剪使用手机相机拍摄的图像。在cameraCapTask_Completed 事件中,我设置了应用程序的全局WritableBitmap
public static WriteableBitmap capturedImage;
如下
void cameraCapTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null)
{
// Take JPEG stream and decode into a WriteableBitmap object.
App.capturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
当我拍照时,我将其传递给 CropProcessPage 构造函数中的裁剪页面,我通过以下方式在页面中设置图像
public CropProcessPage()
{
InitializeComponent();
// Set the text and display captured image.
imageMain.Source = App.capturedImage;
这行得通。但是,当我返回主页并重新拍摄/拍摄另一张图像时,当我尝试使用新图像时,会显示旧图像(第一个拍摄的图像)。构造函数被调用,相机捕获的事件也被调用(设置新图像)。我在这里做错了什么?
【问题讨论】:
-
当我尝试使用新图像时,会显示旧图像(第一个拍摄的图像)。所以把它处理掉;)
-
我已经尝试过这样做,但当然没有
Dispose()方法;那我该怎么办?如果是,使用Invalidate(),如何使用? -
null 怎么样?在全局阶段将其定义为 null
-
不起作用。在重新分配之前,我已将其设置为 null。就好像App对象(WritableBitmap)一旦设置就无法更改!?
-
是的,我认为这是错误.. 所以删除 App.capturedImage 仅使用 imageMain.Source
标签: c# image windows-phone-7 image-capture