要在移动设备中显示图像,图像是否必须驻留在智能设备应用程序中的设备上?
我正在用 C# 开发智能设备应用程序。在此应用程序中,我的应用程序中有一些图像,我用来从我的应用程序在模拟器上显示这些图像。要在模拟器上显示图像,我需要创建驻留在模拟器上的一个图像文件夹。只有在那之后我才能在模拟器中显示图像。我可以使用“文件”->“配置”->“常规”->“共享文件夹”在模拟器中创建文件夹。为了共享文件夹,我给出了包含图像的文件夹的路径。一旦我共享文件夹,驻留在我的应用程序中的图像文件夹将被复制到模拟器中,名称为“存储卡”。现在我需要使用路径 Bitmap bmp=new Bitmap(@"/Storage Card/ImageName.jpg");现在我可以在模拟器中显示图像了。我们是否可以在模拟器中显示图像而不需要驻留在模拟器上的任何图像文件夹(这样我们就不需要像上面的情况一样通过共享文件夹将图像文件夹放置在模拟器中)?如果答案是否定的,那么要在不同的移动设备上运行应用程序,我们需要将包含图像的文件夹放置在不同的移动设备上。不是吗?如果答案是肯定的,那么我们如何在应用程序的不同移动设备上显示图像,而不在移动设备上放置任何图像文件夹?
I am devloping smart device application in C#. In this application I have some images in my application which I used to dispay on emulator from my application. To display the images on emulator I need to create the one folder of images which resides on the emulator. Only after that I am able to display the images in emulator. I am able to create the folder in emulator by using File->Configure->General->Shared Folder. For sharing the folder I am giving the path of the folder which contains the images. Once I share the folder the folder of images which resides in my application will get copied in emulator with the name "Storage Card". Now I need to use the path as Bitmap bmp=new Bitmap(@"/Storage Card/ImageName.jpg"); Now I am able to display the images in emulator. Can we display the images in the emulator without any image folder which resides on emultor (so that we dont need to place the image folder in emulator as in the above case by sharing the folder) ? If the answere is no then to run the application on different mobile devices we need to place the folder which contains the images on different mobile devices. Isnt it? If the answere is yes then how we can display the images on different mobile device from our application without placing any folder of images on mobile devices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了显示图像,您需要在设备(或模拟器)上放置图像 - 否则它将没有数据来知道要显示什么。
您可以通过多种方式将图像传输到设备或模拟器。最简单的方法是,将图像添加到 Visual Studio 项目并将图像文件标记为应复制到目标文件夹的内容。然后,当您去调试它时,Visual Studio 将复制图像文件和应用程序文件,这可能就是您想要的。您需要更改应用程序在其中查找文件的路径(因为它们不再位于“/存储卡”中)。
要在目标(非模拟器)设备上获取图像,您可能需要创建一个 Visual Studio 安装项目,并让它包含您的 exe 和图像文件(并指定应用程序安装时将图像放入哪个文件夹)已安装)。
以上是我做过的,也是推荐的。但还有其他选择。一种可能是从网络下载图像,这可能适用于模拟器和设备(但需要您拥有网络上可用的图像,以及要连接的模拟器和设备)。
In order to display the images, you'll need to have the images on the device (or emulator) - otherwise it wouldn't have the data to know what to display.
There are a few ways you can get the images to the device or emulator. The easiest is if you add the images to your Visual Studio project and mark the image files as content that should be copied to the destination folder. Then Visual Studio will copy the image files along with the application file when you go to debug it, which is probably what you want. You'll need to change the path your application is looking for the files in (since they won't be in "/Storage Card" anymore).
To get the images on a target (non-emulator) device, you'll probably want to create a Visual Studio Install project, and have it include your exe and the image files (and specify which folder to put the images in when the app is installed).
The above is what I've done, and would recommend. But there are other options. One might be to download the images from the web, which might work for both an emulator and devices (but will require you to have the images available on the web, and the emulator and devices to be connected).