LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-11-2015, 11:48 AM   #1
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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,
Attached Images
 
 
Old 02-11-2015, 11:55 AM   #2
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled
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
 
Old 02-11-2015, 12:16 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
thanks, any kool hello-world type of hax i can play around with incorporating this file ?
 
Old 02-11-2015, 01:33 PM   #4
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
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.
 
Old 02-12-2015, 10:13 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
Old 02-19-2015, 06:12 PM   #6
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Quote:
Originally Posted by schneidz View Post
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.
 
  


Reply



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
[SOLVED] How to export just source/destination field of pcap file into a plain text file kikilinux Linux - Networking 5 11-27-2014 07:13 AM
[SOLVED] why does gimp need to export jpeg? SharpyWarpy Linux - Software 4 03-26-2013 05:24 PM
LXer: GIMP Painter And GIMP Paint Studio Transform GIMP Into The Ultimate Painting Tool LXer Syndicated Linux News 0 02-08-2011 05:40 PM
GIMP SVG export support prushik Linux - Software 5 04-26-2010 01:56 AM
Firefox crash on actions: File -> open file, bookmarks->Manage->Export mak_mailbox Linux - Desktop 2 09-29-2009 04:17 PM

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

All times are GMT -5. The time now is 11:55 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
Open Source Consulting | Domain Registration