问题:图像吨;数组跨类。 [英] Questions: Tons of Images; Arrays cross-class.

查看:41
本文介绍了问题:图像吨;数组跨类。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,图片......

我有一个项目,在这个时间和我正在合作的版本中,我有648个主要停留图像,所以说,加上另外100个左右侧面功能。


它们将存储在外部.dll中。虽然我不知道我是否想要将资源功能与C#一起使用,而不是直接。如果你愿意的话。我在过去的许多学习项目中都使用了直接调用C:\\Image.jpg。成功,甚至在我的电脑之外。所以我可以这样做,因为我已经在我的数组中有所有文件名等待代码使用它们。


问题:我应该使用资源功能吗?这是所有这些图像的最佳方式吗? = P


其次,我的程序有一个单独的.dll,其中包含程序的所有文本数据。 .cs文件原样超过120k,我还没有填写所有数据。请注意,这只是一个命名空间,而是单独的数据类,然后是数据。多数民众赞成。


我应该如何从不同的命名空间和类中调用数组?我无法理解。以下是我之前做过的一个例子,没有成功。

First, images...
I have a project that, at this time and version I am working with, I have 648 main stay images, so to say, plus another 100 or so in side features.

They are going to stored in a outside .dll. Though I can''t figure out if I want to use the Resources feature with C# rather then the "Direct" calling if you will. I have, in many Learning projects in the past have just used the direct call "C:\\Image.jpg" with success, even outside my PC. So I could do that, as I have already have all the file names in my arrays awaiting the code to make use of them.

Question: Should I go with the Resource feature? Is this the best way to go about this with all these images? =P

Second, my program has a separate .dll holding all the text data for the program. The .cs file is over 120k as it is and I''m still not done filling all the data. Mind you this is simply a namespace, and seperate data classes, then the data. Thats it.

How should I go about calling the arrays from separate namespaces and classes? I can''t figure it out. Heres an example of what I was doing earlier with no success.

展开 | 选择 | Wrap | 行号

推荐答案


"非静态字段,方法或属性需要对象引用
"An object reference is required for the non-static field, method, or property"



GetFrontIcon是一个静态方法,它试图返回Temp,一个非静态成员。我希望有所帮助!在其他主题上我真的没什么可提供的,除非您重新评估您的图像分配。你需要同时加载所有648个图像吗?


我对你的程序一无所知所以我很难推测,但它可能会值得只加载你将用于代码中任何给定状态的图像。当你从一个州搬到另一个州时,吃一点加载时间并缓存你需要的那个状态的图像。并不总是必要的,但无论如何都要考虑一下。

GetFrontIcon is a static method that tries to return Temp, a non-static member. I hope that helps! I don''t really have anything to offer on the other topic, except maybe you should reevaluate your image allocation. Do you need to have all 648 images loaded at the same time?

I don''t know anything about your program so it''s hard for me to speculate, but it might be worthwhile to only load those images you''ll be using for any given state in your code. When you go from one state to another, eat a bit of a loading time and cache the images you''ll need for that state. Not always necessary, but it''s something to think about at any rate.


好的,我会更具体一点......


我应该使用ImageList来缓存实例所需的图像吗?那是我最初的想法之一。但我再次陷入困境,大声笑......


我不知道哪种方式更有效率,或者可能性更高。我已经有一个数组,其中包含在其特定类别中命名的图像,并且我有一个带有目录字符串的变量...我已经在单独的计算机上完成了从.dll调用图像的方法,看它是否有效,并且没有错误...

我只是嵌入将所有文件放入.dll文件中,我只是称之为(例如)这个:
Ok, I''ll be a little more specific...

Should I use an ImageList to cache the images I need for the instance? That was one of my original thoughts. But Im cornered with this again, lol...

I don''t know which way would be more efficient, or probable. I already have a array with images named out in their specific category, and I have a variable with the directory string... I have done that method of calling an image from a .dll before on a seperate computer to see if it worked, and there wasn''t an error...
Do I just "Embed" all the files into the .dll file, and do I just call them like (for example) this:
展开 | 选择 | Wrap | 行号


否我的意思是把静态放在:)你有一个静态方法试图访问非静态成员。因此,当静态方法试图查看非静态成员的内容时,它为null,因为它尚未被实例化。一个简单的解决方法是使非静态成员成为静态成员。


我想如果你用DLL加载所有内容,它已经在内存中了。我讨论的另一种方法是在需要时直接从文件中加载它(因此缓存)。正如我所说的,无论哪种方式都适合你,我只是建议另一种选择:)


至于你的实际存储类型......这取决于你的看法我想。无论如何,如果你要浏览每个图像,你也可以只使用一个List,然后解析列表并将每个图像放在需要的位置。如果您在需要时按名称查找图像,可以使用带有图像名称的哈希表作为快速检索的关键。这部分实际上取决于您对程序进行编码的方式。
No I meant put static in :) You had a static method trying to access a non-static member. So when that static method tried to look at the contents of the non-static member, it''s null because it hasn''t been instantiated. An easy fix would be to make the non-static member a static member.

I guess if you''re loading everything with a DLL, it''s already in memory. The alternative I was talking about was to load it directly from a file when needed (hence the caching). As I said, either way would work for you, I was just suggesting an alternative :)

As for your actual storage type... it depends on how you''re looking it up I guess. If you''ll be going through every image anyway, you might as well just use a List, then parse the list and put each image where it needs to go. If you''ll be looking up an image by name as you need it, maybe use a hash table with the image name as the key for fast retrieval. This part really depends on how you code your program.


这篇关于问题:图像吨;数组跨类。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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