C99 (using SDL & SDL_ttf), 414 354 346 - 15% = 294.1
#include<SDL_ttf.h>
#define Q(P)char*q=#P;P
Q(
i=5;main(){for(SDL_Surface*s=SDL_SetVideoMode(2048,80,SDL_Init(SDL_INIT_VIDEO),TTF_Init());i--;SDL_SaveBMP(s,"q.bmp"))SDL_BlitSurface(TTF_RenderText_Blended(TTF_OpenFont("q.ttf",9),(char*[]){"#include<SDL_ttf.h>","#define Q(P)char*q=#P;P","Q(",q,")"}[i],(SDL_Color){~0}),0,s,&(SDL_Rect){0,16*i});}
)
This is pretty ugly without more line breaks, but unfortunately they need to be absent. The text-rendering function doesn't grok control characters at all, so any line breaks in the code have to be rendered manually in the output.
Here's the same code but with some extra line breaks thrown in for legibility:
#include<SDL_ttf.h>
#define Q(P)char*q=#P;P
Q(
i=5;main(){for(SDL_Surface*s=SDL_SetVideoMode(2048,80,
SDL_Init(SDL_INIT_VIDEO),TTF_Init());i--;SDL_SaveBMP(s,"q.bmp"))
SDL_BlitSurface(TTF_RenderText_Blended(TTF_OpenFont("q.ttf",9),
(char*[]){"#include<SDL_ttf.h>","#define Q(P)char*q=#P;P","Q(",q,")"}[i],
(SDL_Color){~0}),0,s,&(SDL_Rect){0,16*i});}
)
Sadly, this doesn't also add line breaks to the graphical output:
The output is still legible, though with 9-point output and the red font color, it's a bit squinty. You can improve it at the cost of a character by replacing the 9
with 12
. (Note that the dimension of the resulting image is hardcoded to 2048x80. To accommodate the differences in various fonts, a fair bit of excess has been added to the right margin and the leading, enough so that a size-12 font should still fit comfortably. If you wish to increase it further, however, the dimensions will probably need to be altered as well.)
The command to build the program is:
gcc -Wall -o imgquine imgquine.c -lSDL_ttf `sdl-config --cflags --libs`
The program assumes that there is a font file called q.ttf
in the current directory when run. I took care of this beforehand by running the following command (which should work on most modern Linuxes):
ln -s `fc-match --format='%{file}' sans` ./q.ttf
(Feel free to import your own favorite TrueType font instead.)
After running the program, the image output will be created in the current directory, in a file named q.bmp
. Unfortunately Windows bitmap files are the only output format that this program provides. Adding more output formats would require linking in more libraries.
Note that this program takes advantage of C99's syntax for introducing non-simple literal values, thus significantly reducing the number of variables that need to be defined. This is something that more C golfers should take advantage of.
I assume you must output just the code, and not just print screen and output – sagiksp – 2017-05-04T05:20:25.987
@sagiksp nope
– Pureferret – 2017-05-04T09:51:18.617@Pureferret It was worth a shot haha – sagiksp – 2017-05-05T05:25:45.527
Does it have to be legible? – Tim Seguine – 2014-03-06T14:53:33.680
@TimSeguine, the image should allow someone to copy it by hand and reproduce tt exactly. – Pureferret – 2014-03-06T14:59:53.883
7"Must output the code image itself, not a stored version from elsewhere." Is it allowed and/or required to read the source code file? – Tim Seguine – 2014-03-06T15:07:23.107
+1 Tim's question, because normally reading the source file is forbidden for quines. – Jonathan Van Matre – 2014-03-06T15:17:36.970
29I have just implemented a solution in whitespace. The resulting image looks quite boring. – Howard – 2014-03-06T15:32:18.797
7
Here is an interesting image quine written in Piet: http://mamememo.blogspot.be/2009/10/piet-quine.html
– ProgramFOX – 2014-03-06T15:32:38.977@Howard Indeed. – duci9y – 2014-03-06T18:31:16.143
What I'm getting from the answers is
$0
or the equivalent ought to be forbidden just as the source file is. – Ryan Reich – 2014-03-06T19:27:49.113What i was trying to prevent is someone writing minimal code manually printing the screen and say 'renaming it's or re-outputting it. – Pureferret – 2014-03-06T19:32:22.410
So if I have -15% and -30% is it
score * (1 - 0.15) * (1 - 0.30)
orscore * (1 - 0.15 - 0.30)
? – The Guy with The Hat – 2014-03-06T23:54:22.427@TheGuywithTheHat add each separately, so the former. – Pureferret – 2014-03-06T23:57:34.653
My PostScript CV does this.
– luser droog – 2014-03-07T07:58:08.6203
Have a look here!!! http://en.wikipedia.org/wiki/Tupper%27s_self-referential_formula
– Kaz – 2014-03-07T10:00:58.940