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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-11-2015, 11:48 AM
|
#1
|
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,335
|
gimp export to c source file.
hi, i have an image that looke like the attached:
in gimp i exported it to a c source file and it looks like this:
Code:
[schneidz@hyper gimp-c]$ cat schneidz.c
/* GIMP RGBA C-Source image dump (schneidz.c) */
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
unsigned char pixel_data[15 * 15 * 4 + 1];
} gimp_image = {
15, 15, 4,
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\377"
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\377\377\377\377\0\0\0\377\0\0\0\377\377\374\334"
"\377\377\374\330\377\377\373\322\377\377\373\312\377\377\372\300\377\0\0"
"\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\0\0\0\377\377\374\334\377\377\374\335\377\377\374"
"\334\377\377\374\325\377\377\373\316\377\377\373\306\377\377\372\273\377"
"\377\371\260\377\377\370\247\377\0\0\0\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\0\0\0\377\377\374\327\377\377\374\331\377\377\374\331\377"
"\377\374\325\377\377\373\316\377\377\373\307\377\377\372\277\377\377\371"
"\264\377\377\370\247\377\377\367\235\377\372\362\226\377\0\0\0\377\377\377"
"\377\377\377\377\377\377\0\0\0\377\377\373\322\377\0\0\0\377\377\373\321"
"\377\377\373\313\377\0\0\0\377\377\372\273\377\377\371\265\377\0\0\0\377"
"\0\0\0\377\373\363\226\377\361\352\221\377\0\0\0\377\377\377\377\377\0\0"
"\0\377\377\373\307\377\377\373\312\377\377\373\311\377\0\0\0\377\0\0\0\377"
"\377\371\260\377\377\370\253\377\377\370\247\377\0\0\0\377\0\0\0\377\361"
"\352\221\377\351\342\214\377\341\332\207\377\0\0\0\377\0\0\0\377\377\372"
"\275\377\377\372\275\377\377\372\274\377\377\371\265\377\377\370\253\377"
"\377\370\242\377\377\367\235\377\377\367\233\377\373\363\227\377\361\352"
"\221\377\346\337\212\377\335\326\204\377\325\317\200\377\0\0\0\377\0\0\0"
"\377\377\371\261\377\377\371\261\377\377\371\257\377\377\370\253\377\377"
"\370\242\377\377\367\233\377\377\367\231\377\375\365\230\377\366\356\223"
"\377\351\342\214\377\335\326\204\377\322\313~\377\313\305z\377\0\0\0\377"
"\0\0\0\377\377\370\245\377\377\370\242\377\377\370\242\377\377\370\240\377"
"\377\367\233\377\375\365\230\377\374\364\227\377\371\361\225\377\356\347"
"\217\377\337\330\206\377\322\313~\377\307\301w\377\302\274u\377\0\0\0\377"
"\0\0\0\377\376\366\230\377\372\362\226\377\0\0\0\377\366\356\224\377\364"
"\355\223\377\361\352\221\377\360\350\220\377\352\343\214\377\336\327\205"
"\377\316\310|\377\0\0\0\377\301\273t\377\301\273t\377\0\0\0\377\377\377\377"
"\377\0\0\0\377\356\347\217\377\352\343\214\377\0\0\0\377\343\334\210\377"
"\337\330\206\377\335\326\204\377\325\317\200\377\312\303y\377\0\0\0\377\301"
"\273t\377\301\273t\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377"
"\346\337\212\377\337\330\206\377\331\322\202\377\0\0\0\377\0\0\0\377\0\0"
"\0\377\0\0\0\377\0\0\0\377\301\273t\377\301\273t\377\301\273t\377\0\0\0\377"
"\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\325\317\200\377"
"\316\310|\377\307\301w\377\301\273t\377\301\273t\377\301\273t\377\301\273"
"t\377\301\273t\377\301\273t\377\0\0\0\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377\0\0\0\377\301"
"\273t\377\301\273t\377\301\273t\377\301\273t\377\301\273t\377\0\0\0\377\0"
"\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377"
"\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\377\377\377\377\377\377",
};
[schneidz@hyper gimp-c]$ gcc schneidz.c
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
is there anything useful i can do with this c program (doesnt seem to compile) ?
thanks,
|
|
|
|
02-11-2015, 11:55 AM
|
#2
|
|
Member
Registered: Nov 2013
Posts: 748
Rep: 
|
it's a C struct with metadata and the actual image
it is not a program, just something to use in a program
anyway, didn't know gimp exported to C struct
a similar format is netpbm, it might help you understand
|
|
|
|
02-11-2015, 12:16 PM
|
#3
|
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,335
Original Poster
|
thanks, any kool hello-world type of hax i can play around with incorporating this file ?
|
|
|
|
02-11-2015, 01:33 PM
|
#4
|
|
Member
Registered: Nov 2013
Posts: 748
Rep: 
|
Quote:
Originally Posted by schneidz
thanks, any kool hello-world type of hax i can play around with incorporating this file ?
|
mhm
cool would be like... displaying it at boot in a framebuffer ala plymouth style
it's not hard, but not really basic (alignment, shared memory, hacking boot and such)
simple, idk
export it in ppm
display it using SDL
display it in SDL then draw something on it, or invert the colors or idk
calculate avg brightness per color
some basic filtering shouldn't be that hard either, but... thats a little in space-time wibbly woobly
Last edited by genss; 02-11-2015 at 01:36 PM.
|
|
|
|
02-12-2015, 10:13 AM
|
#5
|
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,986
|
I'd use something like FLTK, Qt, or GTK to make a rudimentary Hello World frame/window under your X Window environment and then place that image into the window.
Doing it directly to the frame buffer is sometimes a problem. It depends on your hardware as well as support from whatever distribution you're running.
|
|
|
|
02-19-2015, 06:12 PM
|
#6
|
|
Member
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317
Rep:
|
Quote:
Originally Posted by schneidz
hi,
[schneidz@hyper gimp-c]$ gcc schneidz.c
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
is there anything useful i can do with this c program (doesnt seem to compile) ?
thanks,
|
It compiles alright, the error that you get is from the linker, because you have no main() function.
Try to compile with the -c flag, which tells gcc to only compile but not to link.
Cheers
Last edited by gdejonge; 02-19-2015 at 06:14 PM.
|
|
|
|
All times are GMT -5. The time now is 03:17 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|