icon from a .RC file

Post Reply
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

icon from a .RC file

Post by Natter »

Is it possible to save an icon from a .RC file to a file ?
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: icon from a .RC file

Post by Antonio Linares »

You can save it from a RES file but you can't save it from a RC file as you only have the icon name there.

The RES file does include the icon contents.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: icon from a .RC file

Post by Natter »

Sorry, Antonio, I wrote it wrong. Of course I meant the RES file :(
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: icon from a .RC file

Post by Antonio Linares »

Simply open the RES file with a resources editor and save the icon file
regards, saludos

Antonio Linares
www.fivetechsoft.com
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: icon from a .RC file

Post by Natter »

I guess I didn't ask the question well. :( I compiled .prg and .rc into a single .exe In some situation I need to save one of the resources (icon) to a bitmap file from the program.
User avatar
Antonio Linares
Site Admin
Posts: 42259
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: icon from a .RC file

Post by Antonio Linares »

Open the EXE with the resources editor and save the icon
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: icon from a .RC file

Post by nageswaragunupudi »

If you want to save an Icon resource to an icon file "filename.ico"

Code: Select all | Expand

hIcon := LoadIcon( GetResources(), cResIcoName )
FW_SaveHIconToIco( hIcon, "name.ico" )
If you want to save any image resource to a file of the same type or different type:
Ex. Save bmp resource as bmp file.

Code: Select all | Expand

FW_SaveImage( BmpResourceName, "name.bmp" )
Ex. Save bmp resource as PNG file.

Code: Select all | Expand

FW_SaveImage( BmpResourceName, "name.png" )
This reads bitmap image from the resource, converts to png image and saves as png image.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: icon from a .RC file

Post by nageswaragunupudi »

Sample:

Using this rc file:
"saveres.rc"

Code: Select all | Expand

BOOKSICO ICON "..\icons\books.ico"
CHARTICO ICON "..\icons\chart.ico"
USERSICO ICON "..\icons\users.ico"
SEA   BITMAP "..\bitmaps\sea.bmp"
OLGA  10  "..\bitmaps\olga1.jpg"
build and run this sample program in the fwh\samples folder:

"saveres.prg"

Code: Select all | Expand

#include "fivewin.ch"

function Main()

   local oWnd, oIco, oBar, oBtn

   DEFINE ICON oIco RESOURCE "BOOKSICO"
   DEFINE WINDOW oWnd ICON oIco SIZE 600,400 PIXEL
   DEFINE BUTTONBAR oBar SIZE 140,30 2007

   DEFINE BUTTON OF oBar PROMPT "OLGA.JPG->PNG" CENTER ACTION ( ;
      FW_SaveImage( "OLGA", "olga.png" ), XImage( "olga.png" ) )

   DEFINE BUTTON OF oBar PROMPT "SEA.BMP->JPG" CENTER ACTION ( ;
      FW_SaveImage( "SEA", "sea.jpg", 100 ), XImage( "sea.jpg" ) )

   DEFINE BUTTON OF oBar PROMPT "SAVE-ICO" CENTER ACTION ( ;
      FW_SaveHIconToIco( LoadIcon( GetResources(), "BOOKSICO" ), "books2.ico" ), ;
      XImage( "books2.ico" ) )

   ACTIVATE WINDOW oWnd CENTERED

return nil
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: icon from a .RC file

Post by Natter »

Thank you ! That's just what I need.
Post Reply