473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to put images into a seperate DLL file outside of .exe

Samishii23
246 100+
So Im going to have a 15mb .exe file if I can't manage to get all the images put into a seperate file. Whether its a .dat, .db, or .dll file. It don't matter.

I've googled for this question a few times. The only thing I've found is...
in order to put an image inside a dll you need todo the following
right click on the image-> Properties -> now insted of Content put the image as Embeded Resource and thats it :-)
That did not work for me, and I'm pretty new to the language and using Visual Studio '05.

So any ideas please?
Sep 13 '09 #1
12 4006
GaryTexmo
1,501 Expert 1GB
It worked fine for me... here's what I did.

1) Created a test project that was a windows form
2) Created a test project that was a class library
3) Right-clicked on the class library and selected Add->Existing Item
4) Selected the image I wanted to use
5) Clicked the image to bring up the properties for it
6) Under Build Action, I selected Embedded Resource
7) In my class library, I did the following...

Expand|Select|Wrap|Line Numbers
  1.     public static class Class1
  2.     {
  3.         public static Image GetBulletImage()
  4.         {
  5.             Image img = new Bitmap(@"F:\My Documents\Visual Studio 2008\Projects\TEST\ClassLibrary1\BULLET.JPG");
  6.  
  7.             return img;
  8.         }
  9.     }
(Node, to get the path I just dragged the image from my Solution Explorer to the code window)

8) In my test form, I added a reference to my class library
9) In the constructor of my main form, I did...

Expand|Select|Wrap|Line Numbers
  1. this.BackgroundImage = Class1.GetBulletImage();
10) Build and run... the background image is set to the image I loaded.

I hope that helps, good luck! :)
Sep 13 '09 #2
Samishii23
246 100+
Ty for the detailed outline of your process. Only 1 problem now, when I go to "Add Reference" I can't find the class library, and I can not build the thing because I can't put using System.Drawing; in, im assume because its a class library and not a Windows Application.

The error the compiler gives me is "The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?)"
Sep 16 '09 #3
GaryTexmo
1,501 Expert 1GB
Class library doesn't come from adding a reference, it comes from adding a new project. Right click your Solution and select Add->New Project. Unless you mean you can't add a reference to your class library from your main form, in which case see below...

Also, you need to add a reference to System.Drawing before you can put a using statement in. In the project that needs the reference added, right-click references and select Add Reference.

If you want to add a reference to a project in your solution, once you've done the above, click the Projects tab. It should be in there :)
Sep 16 '09 #4
Samishii23
246 100+
Well. After not understanding what the h3ll you were getting at. I stumbled upon my answers with your guidance.

Damn references from h3ll. Lol.
Reference this, reference that.. Lol. Wish Microsoft would make that a little easier. =)

Thanks again Gary
Sep 16 '09 #5
Samishii23
246 100+
Crap. Ok sorry. Not done. meh.
Having issues accessing the images from the Class Project.

Before I had them setup under properties, and I could simply access them by their name.
Expand|Select|Wrap|Line Numbers
  1. someimage.Image = @"C:\Image.jpg";
Fix something, and more things break because of the fix. lol
Sep 16 '09 #6
GaryTexmo
1,501 Expert 1GB
Re-check my code above again, you're missing something vital ;)

Hint: You're trying to assign a "string" type to what is an "image" type.
Sep 16 '09 #7
Samishii23
246 100+
Well from your code, i've gotten it down to:
Expand|Select|Wrap|Line Numbers
  1. Image[] NewImage = new Bitmap(@"C:\Image.jpg");
But like I was saying. When the images were directly imbedded into the Form resources, I could access the Images through their name. Not I'm not having such luck.

Also what I get from your code is that I have to use functions to pass things.
One thing I would like to pass from the Class Project to the main Form Project, but arrays are annoying..........
Sep 17 '09 #8
GaryTexmo
1,501 Expert 1GB
I'm not sure if you can still use that... you're assigning a single Bitmap to an array.

Anyway, as for just using the name... I don't know. I know how to do it with XNA and LoadContent<> but I don't know of a .NET equivalent. Do you need to access it like that?
Sep 17 '09 #9
Samishii23
246 100+
I don't need to access it exactly like that. If I could figure out how to return the array of Bitmap objects that would be fine, but the compiler has a fit, and won't let me return the array variable. It wants me to return a single item out of the array.

Although accessing it at out would be nice rather then having to call a function for every image call, know what I mean?
Sep 17 '09 #10
GaryTexmo
1,501 Expert 1GB
Errr no, it's because...
Expand|Select|Wrap|Line Numbers
  1. Image[] NewImage = new Bitmap(@"C:\Image.jpg");
... should be...

Expand|Select|Wrap|Line Numbers
  1. Image NewImage = new Bitmap(@"C:\Image.jpg");
If you want to put it into a list...

Expand|Select|Wrap|Line Numbers
  1. List<Image> imageList = new List<Image>();
  2. imageList.Add(NewImage);
If the list was previously empty, then that image would now be the first element...

Expand|Select|Wrap|Line Numbers
  1. Image firstImage = imageList[0];
Sep 17 '09 #11
Samishii23
246 100+
Is that List callable to the Windows Form project rather then just the Class Project or can I return the entire list variable via a function?

Sorry about all the dumb questions. Really I'm just looking for more clarification. Because Im new, and Im not good with C Sharp let alone cross-project referencing.
Sep 17 '09 #12
GaryTexmo
1,501 Expert 1GB
The list would be in your windows form... you load it from the dll that gets your image for you, which is where you said (per your title) you want to keep them.

Maybe step back a little here and go through the code I posted throughout this thread, then experiment around with it. It's easy to get overwhelmed with new information. Take the time to familiarize yourself with it, and try a few things. For more information on how projects work, dive right into google. There's tons of great information and tutorials out there :)

Also, sorry if I'm not explaining things very clearly. If anybody else around here can think of a better way of putting it, please feel free to correct me. I'm guilty of tunnel vision at times ;)
Sep 17 '09 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Norman Peelman | last post by:
I have a script that outputs images directly using the 'image' functions. I have googled quite a bit but cannot seem to find the correct method of sending headers to keep the images from being...
11
by: LarryM | last post by:
Hi, NB, not to stop capturing the single displayed Image, but to stop downloading the entire image directory. (In my Website you will do a search, and get some thumbnails, and these can be...
2
by: news | last post by:
We currently have our mySQL server on the same box as the Apache server. For security and load balancing, we're going to be moving the mySQL server to another box. We're already using a single...
2
by: Eric | last post by:
I have a header server(.ascx) control that I want to use with all my existing seperate web apps. These web apps are configured as seperate web apps in IIS but when I try to build my solutiuon...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: Sirplaya | last post by:
I am retrieving images that I stored in SQL Server on my web pages in C#. I have no problem with the images displaying, however, I am trying to wrap the image with an <A HREF ..." and each time I...
4
by: dgiglio | last post by:
Hi, For security purposes, I am trying to make an image appear on my page from outside of the web root. It works in two files, both of which I have taken from a book and modified. The first file...
15
Samishii23
by: Samishii23 | last post by:
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...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.