[R] using GDD fonts

Luiz Rodrigo Tozzi luizrodrigotozzi at gmail.com
Wed May 3 23:04:07 CEST 2006


Hi

After a little work i found a way of using "near 8bit" color output in
GDD. I edited the GDD/src/GDDtalk.c file...

There was this loop:
	if (!strcmp(it, "png8")) {
		if (nl>3 && strcmp(fn+nl-4,".png")) strcat(fn, ".png");
		out = fopen (fn, "wb");
		if (out) {
			gdImagePng (xd->img, out);
			fclose (out);
		}
		return;
	}

and I added a line...
	if (!strcmp(it, "png8")) {
		if (nl>3 && strcmp(fn+nl-4,".png")) strcat(fn, ".png");
		out = fopen (fn, "wb");
		if (out) {
			gdImageTrueColorToPalette (xd->img, 0, 256);
			gdImagePng (xd->img, out);
			fclose (out);
		}
		return;
	}

I compiled again and now my GDD works in TrueColor, but with only
those 256 colors... Its not an ellegant solution, but it really
dropped the image size... now my files are 3 times smaller!

thanks for your assistance!

2006/4/13, Jeffrey Horner <jeff.horner at vanderbilt.edu>:
> Luiz Rodrigo Tozzi wrote:
> > Hi Tim,
> >
> > It really worked!!
> >
> > thanks!
> >
> > now my only problem is about the image size, that is huge!
> >
> > im using the type="png" and switching to png8 does not reduce the
> > color depth.. do you know something about is?
>
> I've hacked around on the GDD code before. From what I remember, all png
> files are created in true color.
>
> >
> > 2006/4/12, Tim Churches <tchur at optushome.com.au>:
> >> Luiz Rodrigo Tozzi wrote:
> >>> Hi
> >>>
> >>> I was searching for some X replacement for my job in R and i found the GDD
> >>>
> >>> I installed it and I match all the system requirements. My problem
> >>> (maybe a dumb one) is that every plot comes with no font and i cant
> >>> find a simgle example of a plot WITH FONT DETAIL in the list
> >>>
> >>> can anybody help me?
> >>>
> >>> a simple example:
> >>>
> >>> library(GDD)
> >>> GDD("something.png", type="png", width = 700, height = 500)
> >>> par(cex.axis=0.65,lab=c(12,12,0),mar=c(2.5, 2.5, 2.5, 2.5))
> >>> plot(rnorm(100))
> >>> mtext("Something",side=3,padj=-0.33,cex=1)
> >>> dev.off()
> >>>
> >>> thanks in advance!
> >> This might help - we found that we needed to install the MS TT fonts and
> >> make sure that GDD can find them, as per the README. :
> >>
> >> Simon Urbanek <simon.urbanek at r-project.org> wrote:
> >>> Tim,
> >>>
> >>> On Jun 9, 2005, at 3:51 AM, Tim CHURCHES wrote:
> >>>
> >>>> I tried GDD 0.1-7 with Lattice graphs in R 2.1.0 (on Linux). It
> >>>> doesn't segfault now but it is still not producing any usable output
> >>>> - the output png file is produced but nly with a few lines on it.
> >>>> Still the alpha channel problem? Have you been able to produce any
> >>>> Lattice graphs with it?
> >>> I know of no such problem, I tested a few lattice graphics and they
> >>> worked. Can you, please, send me reproducible example and your output?
> >>> Also send me, please output of
> >>> library(GDD)
> >>> .Call("gdd_look_up_font", NULL)
> >> Sorry, my laziness. GDD was unable to find any fonts. After I installed
> >> the MS TT fonts and set their location as per the GDD README, it worked
> >> perfectly with both old-style R graphics and lattice graphics. The
> >> output looks very nice indeed. We'll do a bit more testing (and let you
> >> know if we find any problems), but it looks like we can at last drop the
> >> requirement for Xvfb when using R in a Web application. Great work! From
> >> our point of view, GDD solves one the biggest problem with R for Web
> >> applications.
> >>
> >> Cheers,
> >>
> >> Tim C
> >>
> >
> >
> > --
> >> <> ><> ><> ><> ><> ><> ><> ><> ><>
> >      Luiz Rodrigo Lins Tozzi
> >
> > <>< <>< <>< <>< <>< <>< <>< <>< <><
> >     luizrodrigotozzi at gmail.com
> >           (21)91318150
> >
> >> <> ><> ><> ><> ><> ><> ><> ><> ><>
> >     http://luizrodrigotozzi.multiply.com/
> >     http://www.flogao.com.br/luizrodrigotozzi
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
> --
> Jeffrey Horner       Computer Systems Analyst         School of Medicine
> 615-322-8606         Department of Biostatistics   Vanderbilt University
>


--
><> ><> ><> ><> ><> ><> ><> ><> ><>
     Luiz Rodrigo Lins Tozzi

<>< <>< <>< <>< <>< <>< <>< <>< <><
    luizrodrigotozzi at gmail.com
          (21)91318150

><> ><> ><> ><> ><> ><> ><> ><> ><>
    http://luizrodrigotozzi.multiply.com/
    http://www.flogao.com.br/luizrodrigotozzi




More information about the R-help mailing list