6e83488e9bcbaa22141e6896ad5f871eefd7fc41
galt
Wed Jan 15 16:45:42 2014 -0800
It turns out that although it compiles,it does not actually work unless one turns off COLOR32 setting in common.mk,
which is not going to happen.
I have a local development branch where this works.
Alternatives such as converting color values from 32-bit to 256 colors for gif saving
could be explored in the future.
Revert "Changing output of phyloGif back go actual gif instead of png. I first tried changing stuff to be png, but there were many references in html files that would be a real pain to change back. Besides, the gif code is stable and works well. There is no patents on it anymore, and no reason to not use it when it is convenient, which it is here."
This reverts commit 6f8f179499a5fccd49717db4af56d7aec5c9b26c.
diff --git src/hg/phyloGif/phyloGif.c src/hg/phyloGif/phyloGif.c
index 39665ab..667ed9a 100644
--- src/hg/phyloGif/phyloGif.c
+++ src/hg/phyloGif/phyloGif.c
@@ -1,754 +1,752 @@
/* phyloGif.c for parsing phylo tree and outputting a gif.
*
* Author: Galt Barber 2006
*
* Designed to be run either as a cgi or as a command-line utility.
* The input file spec matches the .nh tree format e.g. (cat:0.5,dog:0.6):1.2;
* The output gif layout was originally designed to ignore branch lengths.
* However, options have now been added to allow it to use branchlengths,
* and to label the length of the branches.
* Any _suffix is stripped from labels both because pyloTree.c
* can't tolerate underscores and because we don't want suffixes anyway.
* A semi-colon is automatically appended to the input if left off.
* Because phyloTree.c does errAbort on bad input, this causes cgi err 500
* if the input data has incorrect syntax. See the apache error_log.
* Added another option to place form output in a static html page
* so that we can prevent IE6 save-as bug, and FF auto-shrunk output.
* Added an option to display a length-scale legend or ruler at the bottom.
* Added an option to preserve underscores in input as spaces in output.
*
*
* One may use as a cgi in html GET:
*
*
* Or as cgi in html POST:
\n" "((A:0.1,B:0.1):0.2,C:0.15);\n" " | \n"
" |
\n" "((A:0.1,B:0.1)D:0.2,C:0.15)E;\n" " | \n"
" (internal or ancestral node labels)\n" " |
\n" " ((((\n" " (\n" " ((mouse,rat),human),\n" " (dog,cow)\n" " ),\n" " opossum),\n" " chicken),\n" " xenopus),\n" " (tetraodon,zebrafish));\n" " | \n"
" |
"); /* we dont think the specific error message coming back are correct or useful * so supply a generic err msg */ printf("Original input tree:\n[%s]\n\n",cgiString("phyloGif_tree")); printf("Input tree as passed to parser:\n[%s]\n\n",phyloData); printf("Parser syntax error:\n%s",errMsg); puts(""); } else { warn("%s", errMsg); } freez(&errMsg); freez(&phyloData); return 0; } } MgFont *font = NULL; if (monospace) font = mgMenloMediumFont(); else font = mgMediumBoldFont(); if (phyloTree) { mg = mgNew(width,height); mgClearPixels(mg); lengthLegend = lengthLegend && branchLengths; /* moot without lengths */ if (lengthLegend) { int fHeight = mgFontPixelHeight(font); height -= (MARGIN+2*fHeight); } phyloTreeLayoutBL(phyloTree, &maxDepth, &numLeafs, 0, font, &maxLabelWidth, width, &minMaxFactor, 0.0); if (layoutErrMsg[0] != 0) { if (onWeb) { printf("Content-type: text/html\r\n"); printf("\r\n"); puts("
"); printf("input tree: [%s]\n\n%s",cgiString("phyloGif_tree"),layoutErrMsg); puts(""); } else { warn("%s", layoutErrMsg); } freez(&phyloData); mgFree(&mg); return 0; } if (branchLengths) phyloTreeGifBL(phyloTree, maxDepth, numLeafs, maxLabelWidth, width, height, mg, font, minMaxFactor, FALSE); else phyloTreeGif(phyloTree, maxDepth, numLeafs, maxLabelWidth, width, height, mg, font); if (lengthLegend) { int i = 0; char out[256]; double scaleEnd = (width - 2*MARGIN); int fHeight = mgFontPixelHeight(font); int x=0; int dh=0; mgDrawLine(mg, MARGIN, height+fHeight/2, width-MARGIN, height+fHeight/2, MG_BLACK); while(TRUE) { x=((minMaxFactor*i)/10); if (x >= scaleEnd) break; if ((i % 5) == 0) { int y = mgFontCharWidth(font,'0'); y += 0.5*mgFontCharWidth(font,'.'); safef(out,sizeof(out),"%3.2f",branchMultiplier*i/10.0); if (branchMultiplier > 10) safef(out,sizeof(out),"%3.0f",branchMultiplier*i/10.0); mgText(mg, MARGIN+x-y, height+fHeight, MG_BLACK, font, out); dh=fHeight/2; } else { dh = fHeight / 4; } mgDrawLine(mg, MARGIN+x, height+fHeight/2-dh, MARGIN+x, height+fHeight/2+dh, MG_BLACK); ++i; } } } if (onWeb) { - printf("Content-type: image/gif\r\n"); + printf("Content-type: image/png\r\n"); printf("\r\n"); } -if (!mgSaveToGif(stdout, mg, FALSE)) +if (!mgSaveToPng(stdout, mg, FALSE)) { - errAbort("Couldn't save gif to stdout"); + errAbort("Couldn't save png to stdout"); } if (cgiOptionalString("phyloGif_submit")) cartCheckout(&cart); /* there's no code for freeing the phyloTree yet in phyloTree.c */ mgFree(&mg); freez(&phyloData); return 0; }