icon from a .RC file

icon from a .RC file

Postby Natter » Thu Nov 14, 2024 8:26 pm

Is it possible to save an icon from a .RC file to a file ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: icon from a .RC file

Postby Antonio Linares » Thu Nov 14, 2024 9:25 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: icon from a .RC file

Postby Natter » Fri Nov 15, 2024 8:34 am

Sorry, Antonio, I wrote it wrong. Of course I meant the RES file :(
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: icon from a .RC file

Postby Antonio Linares » Fri Nov 15, 2024 1:15 pm

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: icon from a .RC file

Postby Natter » Fri Nov 15, 2024 4:20 pm

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.
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: icon from a .RC file

Postby Antonio Linares » Fri Nov 15, 2024 10:24 pm

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: icon from a .RC file

Postby nageswaragunupudi » Sat Nov 16, 2024 2:20 am

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

Code: Select all  Expand view
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 view
FW_SaveImage( BmpResourceName, "name.bmp" )


Ex. Save bmp resource as PNG file.
Code: Select all  Expand view
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: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: icon from a .RC file

Postby nageswaragunupudi » Sat Nov 16, 2024 3:28 am

Sample:

Using this rc file:
"saveres.rc"
Code: Select all  Expand view
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 view
#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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: icon from a .RC file

Postby Natter » Sat Nov 16, 2024 6:13 pm

Thank you ! That's just what I need.
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 37 guests