LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gimp export to c source file. (https://www.linuxquestions.org/questions/programming-9/gimp-export-to-c-source-file-4175533726/)

schneidz 02-11-2015 11:48 AM

gimp export to c source file.
 
1 Attachment(s)
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,

genss 02-11-2015 11:55 AM

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

schneidz 02-11-2015 12:16 PM

thanks, any kool hello-world type of hax i can play around with incorporating this file ?

genss 02-11-2015 01:33 PM

Quote:

Originally Posted by schneidz (Post 5315627)
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

rtmistler 02-12-2015 10:13 AM

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.

gdejonge 02-19-2015 06:12 PM

Quote:

Originally Posted by schneidz (Post 5315610)
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


All times are GMT -5. The time now is 05:20 PM.