473,848 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image resources file *.res extension

Hi,

I am looking for an example of how to extract bitmap images from an embedded
resource file (a file with *.res extension, which can be viewed inside of
the ide and can hold bitmaps, icons, string tables, etc.) and place them
into a imagelist.

I have found examples using the resource manager to create a "resource file"
like so:
ResourceWriter rw = new ResourceWriter (
@"D:\Projects\R OG.resources" ) ;
Image img0 = Image.FromFile ( @"D:\Projects\C hecked.bmp" ) ;
Image img1 = Image.FromFile ( @"D:\Projects\C heckedDisabled. bmp" )
;
Image img2 = Image.FromFile ( @"D:\Projects\U nChecked.bmp" ) ;
Image img3 = Image.FromFile (
@"D:\Projects\U nCheckedDisable d.bmp" ) ;
rw.AddResource ( "Checked", img0 ) ;
rw.AddResource ( "CheckedDisable d", img1 ) ;
rw.AddResource ( "UnChecked" , img2 ) ;
rw.AddResource ( "UnCheckedDisab led", img3 ) ;
rw.Close( ) ;

and then extract the data like so:
Assembly asm = Assembly.GetExe cutingAssembly ( ) ;
// Namespace = TestLoadingReso urceFile
ResourceManager rm = new ResourceManager (
"TestLoadingRes ourceFile.ROG", asm ) ;
imageList1.Imag es.Add( ( Image ) rm.GetObject ( "Checked" ) );
imageList1.Imag es.Add( ( Image ) rm.GetObject (
"CheckedDisable d" ) );
imageList1.Imag es.Add( ( Image ) rm.GetObject ( "UnChecked" ) );
imageList1.Imag es.Add( ( Image ) rm.GetObject (
"UnCheckedDisab led" ) );

// Afterwards add the file in the IDE and change build action to "Embedded
Resource"

This "resource file" cannot be viewed in the IDE as anything other than
binary data unless you change the extension of the file to res. However,
you cannot load the file using the resource manager after viewing the res
file in the IDE because header information is removed from the file when it
is viewed (change extension back to resources and you can see that
information was removed).

Any help will be appreciated.

Thanks,
Dave

Nov 16 '05 #1
1 3854
Still no luck finding out how to load data from *.res files, but I did run
across this in MSDN:

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpguide/html/cpconcreatingre s
ourcefiles2.htm

Only .resources files should be embedded in common language runtime
assemblies and satellite assemblies. The Resource File Generator
(Resgen.exe) converts text (.txt) files and XML-based resource (.resx) files
into .resources files by wrapping methods implemented by the ResourceReader,
ResourceWriter, ResXResourceRea der, and ResXResourceWri ter classes. You can
also use Resgen.exe to convert .resources files back into .resx and .txt
files.

However, they are referring to embedding resources inside of "runtime"
assemblies and I am embedding my resources at design time.

In case someone runs across the code below via google this comment is
incorrect:
// Namespace = TestLoadingReso urceFile
ResourceManager rm = new ResourceManager ("TestLoadingRe sourceFile.ROG" ,
asm ) ;

TestLoadingReso urceFile is the name of the namespace, but in the call to
ResourceManager it is the name of the assembly. They just happen to be the
same name.

If you know anything and can give me a hand, I would appreciate it.

Thanks,
Dave
"D. Yates" <fo****@hotmail .com> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I am looking for an example of how to extract bitmap images from an embedded resource file (a file with *.res extension, which can be viewed inside of
the ide and can hold bitmaps, icons, string tables, etc.) and place them
into a imagelist.

I have found examples using the resource manager to create a "resource file" like so:
ResourceWriter rw = new ResourceWriter (
@"D:\Projects\R OG.resources" ) ;
Image img0 = Image.FromFile ( @"D:\Projects\C hecked.bmp" ) ;
Image img1 = Image.FromFile ( @"D:\Projects\C heckedDisabled. bmp" ) ;
Image img2 = Image.FromFile ( @"D:\Projects\U nChecked.bmp" ) ;
Image img3 = Image.FromFile (
@"D:\Projects\U nCheckedDisable d.bmp" ) ;
rw.AddResource ( "Checked", img0 ) ;
rw.AddResource ( "CheckedDisable d", img1 ) ;
rw.AddResource ( "UnChecked" , img2 ) ;
rw.AddResource ( "UnCheckedDisab led", img3 ) ;
rw.Close( ) ;

and then extract the data like so:
Assembly asm = Assembly.GetExe cutingAssembly ( ) ;
// Namespace = TestLoadingReso urceFile
ResourceManager rm = new ResourceManager (
"TestLoadingRes ourceFile.ROG", asm ) ;
imageList1.Imag es.Add( ( Image ) rm.GetObject ( "Checked" ) );
imageList1.Imag es.Add( ( Image ) rm.GetObject (
"CheckedDisable d" ) );
imageList1.Imag es.Add( ( Image ) rm.GetObject ( "UnChecked" ) );
imageList1.Imag es.Add( ( Image ) rm.GetObject (
"UnCheckedDisab led" ) );

// Afterwards add the file in the IDE and change build action to "Embedded
Resource"

This "resource file" cannot be viewed in the IDE as anything other than
binary data unless you change the extension of the file to res. However,
you cannot load the file using the resource manager after viewing the res
file in the IDE because header information is removed from the file when it is viewed (change extension back to resources and you can see that
information was removed).

Any help will be appreciated.

Thanks,
Dave


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11776
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
0
1652
by: Duncan Welch | last post by:
I've got users uploading a file, which I then want resize, make a thumbnail out of, then delete. The image and thumbnail are working fine, but when I try to delete the image, I get an error: "The process cannot access the file "c:\inetpub\wwwroot\pictures\1\21_orig.jpg" because it is being used by another process. " I'm using the Image.Dispose() method before trying to delete it; how do I free up this image? Thanks in advance,
2
3520
by: Don Tucker | last post by:
Hello, I have a Windows Application that needs to load multiple image files in response to users clicking buttons. Currently, I just have these images as .jpg files on disk, but I don't want to have to migrate the files everywhere that the executable is installed. Is there a way to add them to a Visual Studio solution/project so that they are embedded in the application somehow? If so, how do I access the images when needed? Thanks,...
62
17888
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image(); img.src = ; Then I use the image a few more times by adding it into an Array object:
6
1997
by: nichughes | last post by:
Hello all, A question relating to http://www.entrust-systems.net/ Just for a change I have run into a problem that seems to be OS specific rather than browser specific - the box image that is acting as a faux border for the main text block shows nasty image effects on the outside when using either Firefox or Konqueror on Suse Linux. This image is set to resize with the browser window (and hence the text) and this seems to be what...
6
7615
by: Frank Rizzo | last post by:
I have an interesting problem. I have a directory of image files. However, none of the files have an extension. I need to figure out what type if image it is and attach an extension to the file. Is there a way to determine image type in the .net framework? Thanks.
12
3368
by: Shawn Northrop | last post by:
Ive been searching for an image resize tutorial for a while now and found this code which worked nicely. I was unable to find the full source code but i think i pieced together the code from the tutorials correctly. My problem is when i upload an image it does not fit any case in the open_image function switch statement. when i echo $file i get 0808...tmp on my localhost server and 0808.... on my webhosting server. There is no .jpg even if...
4
1806
by: Muddasir | last post by:
Hi.. i am having a strange problem.......the problem is i am trying to upload a file and to store it in db....when the file got stored in db...it got converted into black and white image and the stored in db with the same name("b"appended in the begining of the filename). now the problem is that...the following script only converts three images which i was using through out the testing phase......now it uploads only those three images...
1
2152
by: Sinan Alkan | last post by:
Hi All, I have a method to resize any image file to the specific dimensions and save this new image to a path. I found it on a web page(By Joel Neubeck) and i changed it for my project. The code is as follows; --------------------------------- // usings part using System.Drawing; using System.Drawing.Imaging;
0
9893
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10722
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10348
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9500
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5919
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4137
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.