LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-25-2008, 01:22 AM   #1
MiniMe001
Member
 
Registered: Nov 2004
Location: US
Distribution: Gentoo
Posts: 59

Rep: Reputation: 15
Compile (gcc) icons (png) into a program


Maybe I don't know what to search for. I really can't find anything through google for compiling an icon into a program. I found help for windows (blah), but nothing for unix.

How might I go about this...?

Note: very much a beginner at c/c++.
 
Old 03-25-2008, 05:42 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
Why are you trying to do this, what are you trying to achieve? Its hard to how how to answer you, as that could mean several things.
 
Old 03-25-2008, 04:31 PM   #3
MiniMe001
Member
 
Registered: Nov 2004
Location: US
Distribution: Gentoo
Posts: 59

Original Poster
Rep: Reputation: 15
mm. Well, maybe I should have been more specific.
Ok, so in windows you can compile an icon into an exe file basically by turning the ico file into an o file. How would I manage the same in unix? Is there a way to compile a png as such, or is there something I can run to associate an existing png with a file?
 
Old 03-25-2008, 05:11 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You may have a look at reswrap, a command line utility coming with the Fox Toolkit. It turns images into C or C++ data arrays which can be embedded in the source code and compiled into an application, as described in its own man page. You can find detailed information here. Look at sections "Incorporating Icons and Images into an Application" and "More on reswrap".
 
Old 03-25-2008, 06:37 PM   #5
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Rep: Reputation: 31
XPM is the traditional way.
 
Old 04-05-2008, 10:16 AM   #6
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
an xpm example from gtk.org

#include <gtk/gtk.h>

/* XPM */
static char * WheelbarrowFull_xpm[] = {
"48 48 64 1",
" c None",
". c #DF7DCF3CC71B",
"X c #965875D669A6",
"o c #71C671C671C6",
"O c #A699A289A699",
"+ c #965892489658",
"@ c #8E38410330C2",
"# c #D75C7DF769A6",
"$ c #F7DECF3CC71B",
"% c #96588A288E38",
"& c #A69992489E79",
"* c #8E3886178E38",
"= c #104008200820",
"- c #596510401040",
"; c #C71B30C230C2",
": c #C71B9A699658",
"> c #618561856185",
", c #20811C712081",
"< c #104000000000",
"1 c #861720812081",
"2 c #DF7D4D344103",
"3 c #79E769A671C6",
"4 c #861782078617",
"5 c #41033CF34103",
"6 c #000000000000",
"7 c #49241C711040",
"8 c #492445144924",
"9 c #082008200820",
"0 c #69A618611861",
"q c #B6DA71C65144",
"w c #410330C238E3",
"e c #CF3CBAEAB6DA",
"r c #71C6451430C2",
"t c #EFBEDB6CD75C",
"y c #28A208200820",
"u c #186110401040",
"i c #596528A21861",
"p c #71C661855965",
"a c #A69996589658",
"s c #30C228A230C2",
"d c #BEFBA289AEBA",
"f c #596545145144",
"g c #30C230C230C2",
"h c #8E3882078617",
"j c #208118612081",
"k c #38E30C300820",
"l c #30C2208128A2",
"z c #38E328A238E3",
"x c #514438E34924",
"c c #618555555965",
"v c #30C2208130C2",
"b c #38E328A230C2",
"n c #28A228A228A2",
"m c #41032CB228A2",
"M c #104010401040",
"N c #492438E34103",
"B c #28A2208128A2",
"V c #A699596538E3",
"C c #30C21C711040",
"Z c #30C218611040",
"A c #965865955965",
"S c #618534D32081",
"D c #38E31C711040",
"F c #082000000820",
" ",
" .XoO ",
" +@#$%o& ",
" *=-;#:+ ",
" >,<12#:34 ",
" 45671#:X3 ",
" +89<02qwo ",
"e* >,67;ro ",
"ty> 459@>+&& ",
"$2u+ ><ipas8* ",
"%$;=* *3:.Xa.dfg> ",
"Oh$;ya *3d.a8j,Xe.d3g8+ ",
" Oh$;ka *3d$a8lz,,xxc:.e3g54 ",
" Oh$;kO *pd$%svbzz,sxxxxfX..&wn> ",
" Oh$@mO *3dthwlsslszjzxxxxxxx3:td8M4 ",
" Oh$@g& *3d$XNlvvvlllm,mNwxxxxxxxfa.:,B* ",
" Oh$@,Od.czlllllzlmmqV@V#V@fxxxxxxxf:%j5& ",
" Oh$1hd5lllslllCCZrV#r#:#2AxxxxxxxxxcdwM* ",
" OXq6c.%8vvvllZZiqqApA:mq:Xxcpcxxxxxfdc9* ",
" 2r<6gde3bllZZrVi7S@SV77A::qApxxxxxxfdcM ",
" :,q-6MN.dfmZZrrSS:#riirDSAX@Af5xxxxxfevo",
" +A26jguXtAZZZC7iDiCCrVVii7Cmmmxxxxxx%3g",
" *#16jszN..3DZZZZrCVSA2rZrV7Dmmwxxxx&en",
" p2yFvzssXe:fCZZCiiD7iiZDiDSSZwwxx8e*>",
" OA1<jzxwwc:$d%NDZZZZCCCZCCZZCmxxfd.B ",
" 3206Bwxxszx%et.eaAp77m77mmmf3&eeeg* ",
" @26MvzxNzvlbwfpdettttttttttt.c,n& ",
" *;16=lsNwwNwgsvslbwwvccc3pcfu<o ",
" p;<69BvwwsszslllbBlllllllu<5+ ",
" OS0y6FBlvvvzvzss,u=Blllj=54 ",
" c1-699Blvlllllu7k96MMMg4 ",
" *10y8n6FjvllllB<166668 ",
" S-kg+>666<M<996-y6n<8* ",
" p71=4 m69996kD8Z-66698&& ",
" &i0ycm6n4 ogk17,0<6666g ",
" N-k-<> >=01-kuu666> ",
" ,6ky& &46-10ul,66, ",
" Ou0<> o66y<ulw<66& ",
" *kk5 >66By7=xu664 ",
" <<M4 466lj<Mxu66o ",
" *>> +66uv,zN666* ",
" 566,xxj669 ",
" 4666FF666> ",
" >966666M ",
" oM6668+ ",
" *4 ",
" ",
" "};


/* When invoked (via signal delete_event), terminates the application */
gint close_application( GtkWidget *widget,
GdkEvent *event,
gpointer data )
{
gtk_main_quit();
return(FALSE);
}

int main (int argc,
char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window, *pixmap, *fixed;
GdkPixmap *gdk_pixmap;
GdkBitmap *mask;
GtkStyle *style;
GdkGC *gc;

/* Create the main window, and attach delete_event signal to terminate
* the application. Note that the main window will not have a titlebar
* since we're making it a popup. */
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_POPUP);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (close_application), NULL);
gtk_widget_show (window);

/* Now for the pixmap and the pixmap widget */
style = gtk_widget_get_default_style();
gc = style->black_gc;
gdk_pixmap = gdk_pixmap_create_from_xpm_d (window->window, &mask,
&style->bg[GTK_STATE_NORMAL],
WheelbarrowFull_xpm);
pixmap = gtk_image_new_from_pixmap (gdk_pixmap, mask);
gtk_widget_show (pixmap);

/* To display the pixmap, we use a fixed widget to place the pixmap */
fixed = gtk_fixed_new ();
gtk_widget_set_size_request (fixed, 200, 200);
gtk_fixed_put (GTK_FIXED (fixed), pixmap, 0, 0);
gtk_container_add (GTK_CONTAINER (window), fixed);
gtk_widget_show (fixed);

/* This masks out everything except for the image itself */
gtk_widget_shape_combine_mask (window, mask, 0, 0);

/* show the window */
gtk_widget_show (window);
gtk_main ();

return 0;
}
 
Old 04-05-2008, 10:17 AM   #7
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
does not look good without spaces. wellwell
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
AMD gcc compile program to INTEL myrmidon Programming 2 09-14-2007 10:13 PM
OpenGL program compile error with gcc 4.1.1 and Mesa 6.5.2 iam_techno Linux - Software 1 01-07-2007 05:25 PM
How to compile C program using the OSSP mm library and gcc? seleria Linux - Software 0 11-06-2006 03:08 AM
Can't compile c++ program using gcc pengu Programming 9 02-22-2006 01:59 PM
Do I have to use .PNG for Icons? patientzero Linux - General 6 09-21-2003 03:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration