为什么在Xamarin Media插件中使用ImageSource.FromStream而不是FromFile?(Why use ImageSource.FromStream instead of FromFile in Xamarin Media plugin?)
我正在使用James Montemagno的Xamarin Media插件( https://github.com/jamesmontemagno/MediaPlugin ),他的使用示例显示了从捕获的照片以这种方式更新的图像:
targetImage.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); file.Dispose(); return stream; });
这似乎同样有效:
targetImage.Source = ImageSource.FromFile(file.Path);
但是我觉得詹姆斯的榜样必须展示出更好的方式,但我无法理解为什么 - 也许在一个平台或另一个平台上有些微妙的东西。 任何人都可以告诉我为什么Xamarin ImageSource应该单向设置?
I am using James Montemagno's Xamarin Media Plugin (https://github.com/jamesmontemagno/MediaPlugin) and his usage example shows an image being updated in this way from the captured photo:
targetImage.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); file.Dispose(); return stream; });
This seems to work just as well:
targetImage.Source = ImageSource.FromFile(file.Path);
However I feel that James' example must be showing a better way but I can't figure why -- maybe some subtle thing on one platform or another. Can anyone tell me why the Xamarin ImageSource should be set one way versus another?
原文:https://stackoverflow.com/questions/41663571
最满意答案
事实证明,由于我的nginx配置中的错误页面定义,我收到了这个奇怪的会话错误消息。
通过更正我的实体中的一些错误来解决未找到实体的问题。 Symfony开发人员栏为我提供了足够的信息来跟踪问题。
It turns out I was getting this strange session error message because of an error page definition in my nginx config.
The entity not found issue was resolved by correcting some errors in my entities. The Symfony developer bar provided me with enough information to track the issue down.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
正如Tomasz Turkowski所说,解决方案是使用$ file-> getClientOriginalName(在UploadFileMover类中)使用其真实名称更改文件的基本名称。 class UploadFileMover { public function moveUploadedFile(UploadedFile $file, $uploadBasePath, $relativePath) { // $originalName = $file->getFilename(); ...
-
最简单的方法是通过合理频繁运行的垃圾收集来实现这一点。 您在symfony文档中有关于空闲时间段的段落。 http://symfony.com/doc/current/components/http_foundation/session_configuration.html#session-idle-time-keep-alive Thank's for your help, I do not understand what I've done. I've tested your solution (so ...
-
事实证明,由于我的nginx配置中的错误页面定义,我收到了这个奇怪的会话错误消息。 通过更正我的实体中的一些错误来解决未找到实体的问题。 Symfony开发人员栏为我提供了足够的信息来跟踪问题。 It turns out I was getting this strange session error message because of an error page definition in my nginx config. The entity not found issue was resolved ...
-
upload()函数未执行的答案非常简单 - 表单被标记为无效。 现在我正在寻找帮助,为什么会发生这种情况( 使用LifecycleCallbacks时无法找到该文件 ) The answer why the upload() function was not executed was quite easy - the form is marked as invalid. Now I am looking for help why this happens (The file could not be fo ...
-
您必须取消上传行 namespace Upload\UploadBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Upload\UploadBundle\Entity\Document; class Defa ...
-
我找到了。 我犯了一个非常愚蠢的错误:我在更新数据之前没有加载我的实体,因此每次我尝试更新实体时都会创建一个新实体。 I've found it. I was making a very stupid mistake: I wasn't loading my entity before updating the data, so every time I tried to update the entity I created a new one.
-
嗨认为问题出在你的Controller(MyEntityController.php) 在表单验证之后,在updateTeamAction中使用这个: if($editForm->isValid()) { $em->persist($entity); $em->flush(); $this->get('session')->getFlashBag()->add( 'notice', 'Edit success.' ); ret ...
-
尝试在实体命名空间前面使用\ : 'class' => '\Evr\HomeBundle\Entity\Language', Try to use \ in front of entity namespace: 'class' => '\Evr\HomeBundle\Entity\Language',