FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour icon from a .RC file
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
icon from a .RC file
Posted: Thu Nov 14, 2024 08:26 PM

Is it possible to save an icon from a .RC file to a file ?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: icon from a .RC file
Posted: Thu Nov 14, 2024 09: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
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: icon from a .RC file
Posted: Fri Nov 15, 2024 08:34 AM
Sorry, Antonio, I wrote it wrong. Of course I meant the RES file :(
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: icon from a .RC file
Posted: Fri Nov 15, 2024 01:15 PM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: icon from a .RC file
Posted: Fri Nov 15, 2024 04: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.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: icon from a .RC file
Posted: 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: icon from a .RC file
Posted: Sat Nov 16, 2024 02:20 AM
If you want to save an Icon resource to an icon file "filename.ico"
Code (fw): Select all Collapse
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 (fw): Select all Collapse
FW_SaveImage( BmpResourceName, "name.bmp" )
Ex. Save bmp resource as PNG file.
Code (fw): Select all Collapse
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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: icon from a .RC file
Posted: Sat Nov 16, 2024 03:28 AM
Sample:

Using this rc file:
"saveres.rc"
Code (fw): Select all Collapse
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 (fw): Select all Collapse
#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
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: icon from a .RC file
Posted: Sat Nov 16, 2024 06:13 PM

Thank you ! That's just what I need.

Continue the discussion