如何在 Windows Phone 中的 ScheduledTaskAgent 上裁剪图像 [英] How to crop image on ScheduledTaskAgent in Windows Phone

查看:18
本文介绍了如何在 Windows Phone 中的 ScheduledTaskAgent 上裁剪图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 ScheduledTaskAgent 裁剪图像.由于它在后台运行,因此在尝试实例化 WriteableBitmap 时出现跨线程异常(因为它需要在 UI 线程中创建).我有一个图像流,如何在不使用 WriteableBitmap 的情况下裁剪它?

I need to crop an image using a ScheduledTaskAgent. Since it runs in the background I get a cross-thread exception when trying to instantiate a WriteableBitmap (as it needs to be created in the UI thread). I have a stream of the image, how would I go about cropping it without using a WriteableBitmap?

谢谢

推荐答案

您甚至可以在后台代理中使用调度程序(以及 UI 线程):

You can use the dispatcher (and therefore the UI thread) even in a background agent:

protected override void OnInvoke(ScheduledTask task)
{
    Deployment.Current.Dispatcher.BeginInvoke(() =>
    {
        // Use the WriteableBitmap here

        this.NotifyComplete();
    });
}

这篇关于如何在 Windows Phone 中的 ScheduledTaskAgent 上裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆