inc/memgfx.h File Reference

#include "gfxPoly.h"

Include dependency graph for memgfx.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rgbColor
struct  memGfx

Defines

#define MG_WHITE   0
#define MG_BLACK   1
#define MG_RED   2
#define MG_GREEN   3
#define MG_BLUE   4
#define MG_CYAN   5
#define MG_MAGENTA   6
#define MG_YELLOW   7
#define MG_GRAY   8
#define MG_FREE_COLORS_START   9
#define _mgBpr(mg)   ((mg)->width)
#define _mgPixAdr(mg, x, y)   ((mg)->pixels+_mgBpr(mg) * (y) + (x))
#define _mgPutDot(mg, x, y, color)   (*_mgPixAdr(mg,x,y) = (color))
#define _mgGetDot(mg, x, y)   (*_mgPixAdr(mg,x,y))
#define mgPutDot(mg, x, y, color)   if ((x)>=(mg)->clipMinX && (x) < (mg)->clipMaxX && (y)>=(mg)->clipMinY && (y) < (mg)->clipMaxY) _mgPutDot(mg,x,y,color)
#define mgGetDot(mg, x, y)   ((x)>=(mg)->clipMinX && (x) < (mg)->clipMaxX && (y)>=(mg)->clipMinY && (y) < (mg)->clipMaxY) ? _mgGetDot(mg,x,y) : 0

Typedefs

typedef unsigned char Color
typedef void(*) TextBlit (int bitWidth, int bitHeight, int bitX, int bitY, unsigned char *bitData, int bitDataRowBytes, struct memGfx *dest, int destX, int destY, Color color, Color backgroundColor)
typedef font_hdr MgFont

Functions

memGfxmgNew (int width, int height)
void mgFree (struct memGfx **pmg)
void mgClearPixels (struct memGfx *mg)
void mgSetClip (struct memGfx *mg, int x, int y, int width, int height)
void mgUnclip (struct memGfx *mg)
Color mgFindColor (struct memGfx *mg, unsigned char r, unsigned char g, unsigned char b)
Color mgClosestColor (struct memGfx *mg, unsigned char r, unsigned char g, unsigned char b)
Color mgAddColor (struct memGfx *mg, unsigned char r, unsigned char g, unsigned char b)
int mgColorsFree (struct memGfx *mg)
void mgPutSeg (struct memGfx *mg, int x, int y, int width, Color *dots)
void mgPutSegZeroClear (struct memGfx *mg, int x, int y, int width, Color *dots)
void mgDrawBox (struct memGfx *mg, int x, int y, int width, int height, Color color)
void mgDrawLine (struct memGfx *mg, int x1, int y1, int x2, int y2, Color color)
void mgDrawHorizontalLine (struct memGfx *mg, int y1, Color color)
void mgLineH (struct memGfx *mg, int y, int x1, int x2, Color color)
void mgSaveGif (struct memGfx *mg, char *name)
boolean mgSaveToGif (FILE *gif_file, struct memGfx *screen)
memGfxmgLoadGif (char *name)
void mgTextBlit (int bitWidth, int bitHeight, int bitX, int bitY, unsigned char *bitData, int bitDataRowBytes, struct memGfx *dest, int destX, int destY, Color color, Color backgroundColor)
void mgTextBlitSolid (int bitWidth, int bitHeight, int bitX, int bitY, unsigned char *bitData, int bitDataRowBytes, struct memGfx *dest, int destX, int destY, Color color, Color backgroundColor)
MgFontmgTinyFont ()
MgFontmgSmallFont ()
MgFontmgMediumFont ()
MgFontmgLargeFont ()
MgFontmgHugeFont ()
MgFontmgTinyBoldFont ()
MgFontmgSmallBoldFont ()
MgFontmgMediumBoldFont ()
MgFontmgLargeBoldFont ()
MgFontmgHugeBoldFont ()
MgFontmgTinyFixedFont ()
MgFontmgSmallFixedFont ()
MgFontmgMediumFixedFont ()
MgFontmgLargeFixedFont ()
MgFontmgHugeFixedFont ()
void mgText (struct memGfx *mg, int x, int y, Color color, MgFont *font, char *text)
void mgTextCentered (struct memGfx *mg, int x, int y, int width, int height, Color color, MgFont *font, char *text)
void mgTextRight (struct memGfx *mg, int x, int y, int width, int height, Color color, MgFont *font, char *text)
int mgFontPixelHeight (MgFont *font)
int mgFontLineHeight (MgFont *font)
int mgFontWidth (MgFont *font, char *chars, int charCount)
int mgFontStringWidth (MgFont *font, char *string)
int mgFontCharWidth (MgFont *font, char c)
void mgFillUnder (struct memGfx *mg, int x1, int y1, int x2, int y2, int bottom, Color color)
memGfxmgRotate90 (struct memGfx *in)
void mgCircle (struct memGfx *mg, int xCen, int yCen, int rad, Color color, boolean filled)
void mgDrawPoly (struct memGfx *mg, struct gfxPoly *poly, Color color, boolean filled)

Variables

rgbColor mgFixedColors [9]


Define Documentation

#define _mgBpr ( mg   )     ((mg)->width)

Definition at line 80 of file memgfx.h.

Referenced by mgDrawBox(), mgRotate90(), mgTextBlit(), and mgTextBlitSolid().

#define _mgGetDot ( mg,
x,
 )     (*_mgPixAdr(mg,x,y))

Definition at line 89 of file memgfx.h.

#define _mgPixAdr ( mg,
x,
 )     ((mg)->pixels+_mgBpr(mg) * (y) + (x))

Definition at line 83 of file memgfx.h.

Referenced by mgDrawBox(), mgLineH(), mgPutSegMaybeZeroClear(), mgTextBlit(), and mgTextBlitSolid().

#define _mgPutDot ( mg,
x,
y,
color   )     (*_mgPixAdr(mg,x,y) = (color))

Definition at line 86 of file memgfx.h.

#define MG_BLACK   1

Definition at line 19 of file memgfx.h.

Referenced by altColorLabels(), and vgContrastingColor().

#define MG_BLUE   4

Definition at line 22 of file memgfx.h.

#define MG_CYAN   5

Definition at line 23 of file memgfx.h.

#define MG_FREE_COLORS_START   9

Definition at line 27 of file memgfx.h.

#define MG_GRAY   8

Definition at line 26 of file memgfx.h.

#define MG_GREEN   3

Definition at line 21 of file memgfx.h.

#define MG_MAGENTA   6

Definition at line 24 of file memgfx.h.

#define MG_RED   2

Definition at line 20 of file memgfx.h.

#define MG_WHITE   0

Definition at line 18 of file memgfx.h.

Referenced by cdaShowAlignmentTrack(), mgText(), and vgContrastingColor().

#define MG_YELLOW   7

Definition at line 25 of file memgfx.h.

#define mgGetDot ( mg,
x,
 )     ((x)>=(mg)->clipMinX && (x) < (mg)->clipMaxX && (y)>=(mg)->clipMinY && (y) < (mg)->clipMaxY) ? _mgGetDot(mg,x,y) : 0

Definition at line 96 of file memgfx.h.

Referenced by mgSlowGetDot().

#define mgPutDot ( mg,
x,
y,
color   )     if ((x)>=(mg)->clipMinX && (x) < (mg)->clipMaxX && (y)>=(mg)->clipMinY && (y) < (mg)->clipMaxY) _mgPutDot(mg,x,y,color)

Definition at line 93 of file memgfx.h.

Referenced by mgBrezy(), mgCircle(), and mgSlowDot().


Typedef Documentation

typedef unsigned char Color

Definition at line 30 of file memgfx.h.

typedef struct font_hdr MgFont

Definition at line 153 of file memgfx.h.

typedef void(*) TextBlit(int bitWidth, int bitHeight, int bitX, int bitY, unsigned char *bitData, int bitDataRowBytes, struct memGfx *dest, int destX, int destY, Color color, Color backgroundColor)

Definition at line 133 of file memgfx.h.


Function Documentation

Color mgAddColor ( struct memGfx mg,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Definition at line 124 of file memgfx.c.

References rgbColor::b, colHashAdd(), memGfx::colorHash, memGfx::colorMap, memGfx::colorsUsed, rgbColor::g, and rgbColor::r.

Referenced by mgFindColor(), and mgSetDefaultColorMap().

00126 {
00127 int colIx = mg->colorsUsed;
00128 if (colIx < 256)
00129     {
00130     struct rgbColor *c = mg->colorMap + mg->colorsUsed;
00131     c->r = r;
00132     c->g = g;
00133     c->b = b;
00134     mg->colorsUsed += 1;
00135     colHashAdd(mg->colorHash, r, g, b, colIx);
00136     }
00137 return (Color)colIx;
00138 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgCircle ( struct memGfx mg,
int  xCen,
int  yCen,
int  rad,
Color  color,
boolean  filled 
)

Definition at line 7 of file mgCircle.c.

References mgLineH(), and mgPutDot.

00011 {
00012 int err;
00013 int derr, yerr, xerr;
00014 int aderr, ayerr, axerr;
00015 register int x,y;
00016 int lasty;
00017 
00018 if (rad <= 0)
00019     {
00020     mgPutDot(mg, xCen, yCen, color);
00021     return;
00022     }
00023 err = 0;
00024 x = rad;
00025 lasty = y = 0;
00026 for (;;)
00027     {
00028     if (filled)
00029         {
00030         if (y == 0)
00031             mgLineH(mg, yCen, xCen-x, xCen+x, color);
00032         else
00033             {
00034             if (lasty != y)
00035                 {
00036                 mgLineH(mg, yCen-y, xCen-x, xCen+x, color);
00037                 mgLineH(mg, yCen+y, xCen-x, xCen+x, color);
00038                 lasty = y;
00039                 }
00040             }
00041         }
00042     else
00043         {
00044         /* draw 4 quadrandts of a circle */
00045         mgPutDot(mg, xCen+x, yCen+y, color);
00046         mgPutDot(mg, xCen+x, yCen-y, color);
00047         mgPutDot(mg, xCen-x, yCen+y, color);
00048         mgPutDot(mg, xCen-x, yCen-y, color);
00049         }
00050     axerr = xerr = err -x-x+1;
00051     ayerr = yerr = err +y+y+1;
00052     aderr = derr = yerr+xerr-err;
00053     if (aderr < 0)
00054         aderr = -aderr;
00055     if (ayerr < 0)
00056         ayerr = -ayerr;
00057     if (axerr < 0)
00058         axerr = -axerr;
00059     if (aderr <= ayerr && aderr <= axerr)
00060         {
00061         err = derr;
00062         x -= 1;
00063         y += 1;
00064         }
00065     else if (ayerr <= axerr)
00066         {
00067         err = yerr;
00068         y += 1;
00069         }
00070     else
00071         {
00072         err = xerr;
00073         x -= 1;
00074         }
00075     if (x < 0)
00076         break;
00077     }
00078 }

Here is the call graph for this function:

void mgClearPixels ( struct memGfx mg  ) 

Definition at line 71 of file memgfx.c.

References memGfx::height, memGfx::pixels, memGfx::width, and zeroBytes().

Referenced by vgOpenGif().

00073 {
00074 zeroBytes(mg->pixels, mg->width*mg->height);
00075 }

Here is the call graph for this function:

Here is the caller graph for this function:

Color mgClosestColor ( struct memGfx mg,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Definition at line 97 of file memgfx.c.

References rgbColor::b, memGfx::colorMap, memGfx::colorsUsed, rgbColor::g, and rgbColor::r.

Referenced by mgFindColor().

00099 {
00100 struct rgbColor *c = mg->colorMap;
00101 int closestDist = 0x7fffffff;
00102 int closestIx = -1;
00103 int dist, dif;
00104 int i;
00105 for (i=0; i<mg->colorsUsed; ++i)
00106     {
00107     dif = c->r - r;
00108     dist = dif*dif;
00109     dif = c->g - g;
00110     dist += dif*dif;
00111     dif = c->b - b;
00112     dist += dif*dif;
00113     if (dist < closestDist)
00114         {
00115         closestDist = dist;
00116         closestIx = i;
00117         }
00118     ++c;
00119     }
00120 return closestIx;
00121 }

Here is the caller graph for this function:

int mgColorsFree ( struct memGfx mg  ) 

Definition at line 140 of file memgfx.c.

References memGfx::colorsUsed.

Referenced by mgFindColor().

00142 {
00143 return 256-mg->colorsUsed;
00144 }

Here is the caller graph for this function:

void mgDrawBox ( struct memGfx mg,
int  x,
int  y,
int  width,
int  height,
Color  color 
)

Definition at line 211 of file memgfx.c.

References _mgBpr, _mgPixAdr, memGfx::clipMaxX, memGfx::clipMaxY, memGfx::clipMinX, and memGfx::clipMinY.

Referenced by altColorLabels(), cdaShowAlignmentTrack(), mgBrezy(), and vgMgMethods().

00212 {
00213 int i;
00214 Color *pt;
00215 int x2 = x + width;
00216 int y2 = y + height;
00217 int wrapCount;
00218 
00219 if (x < mg->clipMinX)
00220     x = mg->clipMinX;
00221 if (y < mg->clipMinY)
00222     y = mg->clipMinY;
00223 if (x2 > mg->clipMaxX)
00224     x2 = mg->clipMaxX;
00225 if (y2 > mg->clipMaxY)
00226     y2 = mg->clipMaxY;
00227 width = x2-x;
00228 height = y2-y;
00229 if (width > 0 && height > 0)
00230     {
00231     pt = _mgPixAdr(mg,x,y);
00232     /*colorBin[x][color]++;  increment color count for this pixel */
00233     wrapCount = _mgBpr(mg) - width;
00234     while (--height >= 0)
00235         {
00236         i = width;
00237         while (--i >= 0)
00238             *pt++ = color;
00239         pt += wrapCount;
00240         }
00241     }
00242 }

Here is the caller graph for this function:

void mgDrawHorizontalLine ( struct memGfx mg,
int  y1,
Color  color 
)

Definition at line 392 of file memgfx.c.

References memGfx::clipMaxX, memGfx::clipMinX, and mgDrawLine().

00395 {
00396 mgDrawLine( mg, mg->clipMinX, y1, mg->clipMaxX, y1, color);
00397 }

Here is the call graph for this function:

void mgDrawLine ( struct memGfx mg,
int  x1,
int  y1,
int  x2,
int  y2,
Color  color 
)

Definition at line 362 of file memgfx.c.

References FALSE, and mgBrezy().

Referenced by mgDrawHorizontalLine(), mgDrawPolyOutline(), and vgMgMethods().

00364 {
00365 mgBrezy(mg, x1, y1, x2, y2, color, 0, FALSE);
00366 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgDrawPoly ( struct memGfx mg,
struct gfxPoly poly,
Color  color,
boolean  filled 
)

Definition at line 426 of file mgPolygon.c.

References fillConcave(), and mgDrawPolyOutline().

Referenced by vgMgMethods().

00429 {
00430 if (filled)
00431     fillConcave(mg, poly, color);
00432     // mgDrawPolyFilled(mg, poly, color);
00433 mgDrawPolyOutline(mg, poly, color);
00434 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgFillUnder ( struct memGfx mg,
int  x1,
int  y1,
int  x2,
int  y2,
int  bottom,
Color  color 
)

Definition at line 368 of file memgfx.c.

References mgBrezy(), and TRUE.

Referenced by vgMgMethods().

00374 {
00375 mgBrezy(mg, x1, y1, x2, y2, color, bottom, TRUE);
00376 }

Here is the call graph for this function:

Here is the caller graph for this function:

Color mgFindColor ( struct memGfx mg,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Definition at line 77 of file memgfx.c.

References colHashLookup(), memGfx::colorHash, colHashEl::ix, mgAddColor(), mgClosestColor(), and mgColorsFree().

Referenced by altColorLabels(), and vgMgMethods().

00081 {
00082 struct colHashEl *che;
00083 if ((che = colHashLookup(mg->colorHash, r, g, b)) != NULL)
00084     return che->ix;
00085 if (mgColorsFree(mg))
00086     return mgAddColor(mg, r, g, b);
00087 return mgClosestColor(mg, r, g, b);
00088 }

Here is the call graph for this function:

Here is the caller graph for this function:

int mgFontCharWidth ( MgFont font,
char  c 
)

Definition at line 587 of file memgfx.c.

References mgFontWidth().

Referenced by cdaShowAlignmentTrack().

00589 {
00590 return mgFontWidth(font, &c, 1);
00591 }

Here is the call graph for this function:

Here is the caller graph for this function:

int mgFontLineHeight ( MgFont font  ) 

Definition at line 568 of file memgfx.c.

References font_cel_height().

Referenced by altColorLabels().

00570 {
00571 int celHeight = font_cel_height(font);
00572 return celHeight + 1 + (celHeight/5);
00573 }

Here is the call graph for this function:

Here is the caller graph for this function:

int mgFontPixelHeight ( MgFont font  ) 

Definition at line 562 of file memgfx.c.

References font_cel_height().

Referenced by mgTextCentered(), and mgTextRight().

00564 {
00565 return font_cel_height(font);
00566 }

Here is the call graph for this function:

Here is the caller graph for this function:

int mgFontStringWidth ( MgFont font,
char *  string 
)

Definition at line 581 of file memgfx.c.

References mgFontWidth().

Referenced by gifLabelMaxWidth(), mgTextCentered(), mgTextRight(), and vgDrawRulerBumpText().

00583 {
00584 return mgFontWidth(font, string, strlen(string));
00585 }

Here is the call graph for this function:

Here is the caller graph for this function:

int mgFontWidth ( MgFont font,
char *  chars,
int  charCount 
)

Definition at line 575 of file memgfx.c.

References fnstring_width().

Referenced by mgFontCharWidth(), and mgFontStringWidth().

00577 {
00578 return fnstring_width(font, (unsigned char *)chars, charCount);
00579 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgFree ( struct memGfx **  pmg  ) 

Definition at line 146 of file memgfx.c.

References colHashFree(), memGfx::colorHash, freeMem(), memGfx::pixels, and zeroBytes().

Referenced by gifLabelVerticalText(), memGifClose(), and vgMgMethods().

00147 {
00148 struct memGfx *mg = *pmg;
00149 if (mg != NULL)
00150     {
00151     if (mg->pixels != NULL)
00152         freeMem(mg->pixels);
00153     colHashFree(&mg->colorHash);
00154     zeroBytes(mg, sizeof(*mg));
00155     freeMem(mg);
00156     }
00157 *pmg = NULL;
00158 }

Here is the call graph for this function:

Here is the caller graph for this function:

MgFont* mgHugeBoldFont (  ) 

Definition at line 4476 of file mgHugeFont.c.

References HugeBold_font.

04477 {
04478 return &HugeBold_font;
04479 }

MgFont* mgHugeFixedFont (  ) 

Definition at line 5374 of file mgHugeFont.c.

References HugeFixed_font.

05375 {
05376 return &HugeFixed_font;
05377 }

MgFont* mgHugeFont (  ) 

Definition at line 2218 of file mgHugeFont.c.

References Huge_font.

02219 {
02220 return &Huge_font;
02221 }

MgFont* mgLargeBoldFont (  ) 

Definition at line 1708 of file mgLargeFont.c.

References LargeBold_font.

01709 {
01710 return &LargeBold_font;
01711 }

MgFont* mgLargeFixedFont (  ) 

Definition at line 2388 of file mgLargeFont.c.

References LargeFixed_font.

02389 {
02390 return &LargeFixed_font;
02391 }

MgFont* mgLargeFont (  ) 

Definition at line 836 of file mgLargeFont.c.

References Large_font.

00837 {
00838 return &Large_font;
00839 }

void mgLineH ( struct memGfx mg,
int  y,
int  x1,
int  x2,
Color  color 
)

Definition at line 399 of file memgfx.c.

References _mgPixAdr, memGfx::clipMaxX, memGfx::clipMaxY, memGfx::clipMinX, and memGfx::clipMinY.

Referenced by drawAfterOnOff(), fillConcave(), and mgCircle().

00401 {
00402 if (y >= mg->clipMinY && y < mg->clipMaxY)
00403     {
00404     int w;
00405     if (x1 < mg->clipMinX)
00406         x1 = mg->clipMinX;
00407     if (x2 > mg->clipMaxX)
00408         x2 = mg->clipMaxX;
00409     w = x2 - x1;
00410     if (w > 0)
00411         {
00412         Color *pt = _mgPixAdr(mg,x1,y);
00413         while (--w >= 0)
00414             *pt++ = color;
00415         }
00416     }
00417 }

Here is the caller graph for this function:

struct memGfx* mgLoadGif ( char *  name  )  [read]

Definition at line 74 of file gifread.c.

References COLTAB, errAbort(), gif, gif_cmap, gif_file, gif_height, gif_line, gif_mg, gif_width, gim, iphase, iy, mgNew(), mustOpen(), PIXMASK, READ_ERROR, sameString, and startsWith().

00081 {
00082 int c;
00083 char type[7];
00084 int gif_colors = 0;
00085 
00086 gif_line = 0;
00087 iphase = 0;
00088 iy = 0;
00089 gif_mg = NULL;
00090 gif_file = mustOpen(name, "rb");
00091 if (fread(&gif, 1, sizeof(gif), gif_file) < sizeof(gif))
00092     {
00093     goto TRUNCOUT;
00094     }
00095 memcpy(type, gif.giftype, 6);
00096 type[6] = 0;
00097 if (!startsWith("GIF", type))
00098     {
00099     errAbort("Not a good GIF file");
00100     goto BADOUT;
00101     }
00102 if (!sameString("GIF87a", type))
00103     {
00104     errAbort("Gif is version %s, sadly load_gif only speaks version GIF87a", type);
00105     goto BADOUT;
00106     }
00107 gif_colors = (1<<((gif.colpix&PIXMASK)+1));
00108 if (gif.colpix&COLTAB)
00109     {
00110     int size = gif_colors*3;
00111     if (fread(gif_cmap, 1, size, gif_file) < size)
00112         goto TRUNCOUT;
00113     }
00114 for (;;)    /* skip over extension blocks and other junk til get ',' */
00115     {
00116     if ((c = fgetc(gif_file)) == READ_ERROR)
00117         goto TRUNCOUT;
00118     if (c == ',')
00119         break;
00120     if (c == ';')    /* semi-colon is end of piccie */
00121         goto TRUNCOUT;
00122     if (c == '!')    /* extension block */
00123         {
00124         if ((c = fgetc(gif_file)) == READ_ERROR)    /* skip extension type */
00125             goto TRUNCOUT;
00126         for (;;)
00127             {
00128             if ((c = fgetc(gif_file)) == READ_ERROR)
00129                 goto TRUNCOUT;
00130             if (c == 0)    /* zero 'count' means end of extension */
00131                 break;
00132             while (--c >= 0)
00133                 {
00134                 if (fgetc(gif_file) == READ_ERROR)
00135                     goto TRUNCOUT;
00136                 }
00137             }
00138         }
00139     }
00140 if (fread(&gim, 1, sizeof(gim), gif_file) < sizeof(gim))
00141     goto TRUNCOUT;
00142 gif_width = (gim.whi<<8) + gim.wlo;
00143 gif_height = (gim.hhi<<8) + gim.hlo;
00144 
00145 gif_mg = mgNew(gif_width, gif_height);
00146 
00147 /* Gif files can have color maps in two places.  Let
00148  * the gim color map overwrite the one in the gif header
00149  * here. */
00150 if (gim.flags&COLTAB)
00151     {
00152     int size;
00153     gif_colors = (1<<((gim.flags&PIXMASK)+1));
00154     size = gif_colors*3;
00155     if (fread(gif_cmap, 1, size, gif_file) < size)
00156         goto TRUNCOUT;
00157     }
00158 if (gif_colors > 0)
00159     {
00160     if (gif_colors > 256)
00161        errAbort("Too many colors in %s", name);
00162     memcpy(gif_mg->colorMap, gif_cmap, 3*gif_colors);
00163     }
00164 
00165 switch (gif_decoder(gif_width))
00166     {
00167     case READ_ERROR:
00168     case BAD_CODE_SIZE:
00169         goto TRUNCOUT;
00170     case OUT_OF_MEMORY:
00171         errAbort("out of memory");
00172         goto BADOUT;
00173     default:
00174         break;
00175     }
00176 carefulClose(&gif_file);
00177 return(gif_mg);
00178 
00179 TRUNCOUT:
00180 errAbort("%s is truncated", name);
00181 BADOUT:
00182 carefulClose(&gif_file);
00183 mgFree(&gif_mg);
00184 return(NULL);
00185 }

Here is the call graph for this function:

MgFont* mgMediumBoldFont (  ) 

Definition at line 1085 of file mgMediumFont.c.

References MediumBold_font.

01086 {
01087 return &MediumBold_font;
01088 }

MgFont* mgMediumFixedFont (  ) 

Definition at line 1427 of file mgMediumFont.c.

References MediumFixed_font.

01428 {
01429 return &MediumFixed_font;
01430 }

MgFont* mgMediumFont (  ) 

Definition at line 518 of file mgMediumFont.c.

References Medium_font.

Referenced by altColorLabels(), and gifLabelMaxWidth().

00519 {
00520 return &Medium_font;
00521 }

Here is the caller graph for this function:

struct memGfx* mgNew ( int  width,
int  height 
) [read]

Definition at line 56 of file memgfx.c.

References colHashNew(), mgSetDefaultColorMap(), mgUnclip(), needLargeMem(), and needMem().

Referenced by altColorLabels(), mgLoadGif(), mgRotate90(), and vgOpenGif().

00058 {
00059 struct memGfx *mg;
00060 
00061 mg = needMem(sizeof(*mg));
00062 mg->pixels = needLargeMem(width*height);
00063 mg->width = width;
00064 mg->height = height;
00065 mg->colorHash = colHashNew();
00066 mgSetDefaultColorMap(mg);
00067 mgUnclip(mg);
00068 return mg;
00069 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgPutSeg ( struct memGfx mg,
int  x,
int  y,
int  width,
Color dots 
)

Definition at line 378 of file memgfx.c.

References FALSE, and mgPutSegMaybeZeroClear().

00380 {
00381 mgPutSegMaybeZeroClear(mg, x, y, width, dots, FALSE);
00382 }

Here is the call graph for this function:

void mgPutSegZeroClear ( struct memGfx mg,
int  x,
int  y,
int  width,
Color dots 
)

Definition at line 384 of file memgfx.c.

References mgPutSegMaybeZeroClear(), and TRUE.

00387 {
00388 mgPutSegMaybeZeroClear(mg, x, y, width, dots, TRUE);
00389 }

Here is the call graph for this function:

struct memGfx* mgRotate90 ( struct memGfx in  )  [read]

Definition at line 605 of file memgfx.c.

References _mgBpr, memGfx::colorMap, memGfx::height, mgNew(), memGfx::pixels, and memGfx::width.

Referenced by gifLabelVerticalText().

00607 {
00608 int iWidth = in->width, iHeight = in->height;
00609 struct memGfx *out = mgNew(iHeight, iWidth);
00610 Color *inCol, *outRow, *outRowStart;
00611 int i,j;
00612 
00613 memcpy(out->colorMap, in->colorMap, sizeof(out->colorMap));
00614 outRowStart = out->pixels;
00615 for (i=0; i<iWidth; ++i)
00616     {
00617     inCol = in->pixels + i;
00618     outRow = outRowStart;
00619     outRowStart += _mgBpr(out);
00620     j = iHeight;
00621     while (--j >= 0)
00622         {
00623         outRow[j] = *inCol;
00624         inCol += _mgBpr(in);
00625         }
00626     }
00627 return out;
00628 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgSaveGif ( struct memGfx mg,
char *  name 
)

Definition at line 62 of file gifwrite.c.

References errAbort(), errnoAbort(), mgSaveToGif(), and mustOpen().

Referenced by gifLabelVerticalText(), and memGifClose().

00063 {
00064 FILE *gifFile = mustOpen(name, "wb");
00065 if (!mgSaveToGif(gifFile, screen))
00066     {
00067     remove(name);
00068     errAbort("Couldn't save %s", name);
00069     }
00070 if (fclose(gifFile) != 0)
00071     errnoAbort("fclose failed");
00072 }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean mgSaveToGif ( FILE *  gif_file,
struct memGfx screen 
)

Definition at line 12 of file gifwrite.c.

References memGfx::colorMap, COLPIXVGA13, FALSE, gif_image::flags, gif, gif_compress_data(), gif_wcount, gifsig, gim, memGfx::height, gif_image::hhi, gif_image::hlo, memGfx::pixels, TRUE, warn(), gif_image::whi, memGfx::width, gif_image::wlo, gif_image::xhi, gif_image::xlo, gif_image::yhi, gif_image::ylo, and zeroBytes().

Referenced by mgSaveGif().

00014 {
00015 int i;
00016 struct gif_header gif;
00017 struct gif_image gim;
00018 long gif_wcount;
00019 
00020 gif_wcount = (long)screen->width * screen->height;
00021 zeroBytes(&gif, sizeof(gif));
00022 strcpy(gif.giftype, gifsig);
00023 gif.wlo = gim.wlo = ((screen->width)&0xff);
00024 gif.whi = gim.whi = ((screen->width>>8)&0xff);
00025 gif.hlo = gim.hlo = ((screen->height)&0xff);
00026 gif.hhi = gim.hhi = ((screen->height>>8)&0xff);
00027 gim.xlo = gim.xhi = gim.ylo = gim.yhi = gim.flags = 0;
00028 gif.colpix = COLPIXVGA13;
00029 if (fwrite(&gif, sizeof(gif), 1, gif_file ) < 1)
00030     goto TRUNCOUT;
00031 /* write global color map */
00032 if (fwrite(screen->colorMap, 3, 256, gif_file) < 256)
00033     goto TRUNCOUT;
00034 if (fputc(',', gif_file) < 0) /* comma to start image */
00035     goto TRUNCOUT;
00036 if (fwrite(&gim, sizeof(gim), 1, gif_file) < 1)
00037     goto TRUNCOUT;
00038 fputc(8,gif_file);
00039 fflush(gif_file);
00040 i = gif_compress_data(8, screen->pixels, gif_wcount, gif_file);
00041 switch (i)
00042     {
00043     case 0:
00044         break;
00045     case -2:
00046         warn("Out of memory writing GIF");
00047         goto BADOUT;
00048     case -3:
00049         goto TRUNCOUT;
00050     default:
00051         warn("Error code %d writing gif", i);
00052         goto BADOUT;
00053     }
00054 fputc(';', gif_file); /* end of file for gif */
00055 return(TRUE);
00056 TRUNCOUT:
00057 warn("Disk full writing GIF");
00058 BADOUT:
00059 return(FALSE);
00060 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgSetClip ( struct memGfx mg,
int  x,
int  y,
int  width,
int  height 
)

Definition at line 30 of file memgfx.c.

References memGfx::clipMaxX, memGfx::clipMaxY, memGfx::clipMinX, memGfx::clipMinY, memGfx::height, and memGfx::width.

Referenced by mgUnclip(), and vgMgMethods().

00032 {
00033 int x2, y2;
00034 if (x < 0)
00035     x = 0;
00036 if (y < 0)
00037     y = 0;
00038 x2 = x + width;
00039 if (x2 > mg->width)
00040     x2 = mg->width;
00041 y2 = y + height;
00042 if (y2 > mg->height)
00043     y2 = mg->height;
00044 mg->clipMinX = x;
00045 mg->clipMaxX = x2;
00046 mg->clipMinY = y;
00047 mg->clipMaxY = y2;
00048 }

Here is the caller graph for this function:

MgFont* mgSmallBoldFont (  ) 

Definition at line 440 of file mgSmallFont.c.

References SmallBold_font.

00441 {
00442 return &SmallBold_font;
00443 }

MgFont* mgSmallFixedFont (  ) 

Definition at line 706 of file mgSmallFont.c.

References SmallFixed_font.

00707 {
00708 return &SmallFixed_font;
00709 }

MgFont* mgSmallFont (  ) 

Definition at line 107 of file mgSmallFont.c.

References sail_font.

Referenced by cdaShowAlignmentTrack(), mgTextCentered(), and mgTextRight().

00108 {
00109 return &sail_font;
00110 }

Here is the caller graph for this function:

void mgText ( struct memGfx mg,
int  x,
int  y,
Color  color,
MgFont font,
char *  text 
)

Definition at line 519 of file memgfx.c.

References gfText(), MG_WHITE, and mgTextBlit().

Referenced by mgTextCentered(), mgTextRight(), and vgMgMethods().

00522 {
00523 gfText(mg, font, text, x, y, color, mgTextBlit, MG_WHITE);
00524 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgTextBlit ( int  bitWidth,
int  bitHeight,
int  bitX,
int  bitY,
unsigned char *  bitData,
int  bitDataRowBytes,
struct memGfx dest,
int  destX,
int  destY,
Color  color,
Color  backgroundColor 
)

Definition at line 445 of file memgfx.c.

References _mgBpr, _mgPixAdr, mgClipForBlit(), and UBYTE.

Referenced by mgText().

00449 {
00450 UBYTE *inLine;
00451 UBYTE *outLine;
00452 UBYTE inLineBit;
00453 
00454 if (!mgClipForBlit(&width, &height, &bitX, &bitY, dest, &destX, &destY))
00455     return;
00456 
00457 inLine = bitData + (bitX>>3) + bitY * bitDataRowBytes;
00458 inLineBit = (0x80 >> (bitX&7));
00459 outLine = _mgPixAdr(dest,destX,destY);
00460 while (--height >= 0)
00461     {
00462     UBYTE *in = inLine;
00463     UBYTE *out = outLine;
00464     UBYTE inBit = inLineBit;
00465     UBYTE inByte = *in++;
00466     int i = width;
00467     while (--i >= 0)
00468         {
00469         if (inBit & inByte)
00470             *out = color;
00471         ++out;
00472         if ((inBit >>= 1) == 0)
00473             {
00474             inByte = *in++;
00475             inBit = 0x80;
00476             }
00477         }
00478     inLine += bitDataRowBytes;
00479     outLine += _mgBpr(dest);
00480     }
00481 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgTextBlitSolid ( int  bitWidth,
int  bitHeight,
int  bitX,
int  bitY,
unsigned char *  bitData,
int  bitDataRowBytes,
struct memGfx dest,
int  destX,
int  destY,
Color  color,
Color  backgroundColor 
)

Definition at line 483 of file memgfx.c.

References _mgBpr, _mgPixAdr, mgClipForBlit(), and UBYTE.

00487 {
00488 UBYTE *inLine;
00489 UBYTE *outLine;
00490 UBYTE inLineBit;
00491 
00492 if (!mgClipForBlit(&width, &height, &bitX, &bitY, dest, &destX, &destY))
00493     return;
00494 inLine = bitData + (bitX>>3) + bitY * bitDataRowBytes;
00495 inLineBit = (0x80 >> (bitX&7));
00496 outLine = _mgPixAdr(dest,destX,destY);
00497 while (--height >= 0)
00498     {
00499     UBYTE *in = inLine;
00500     UBYTE *out = outLine;
00501     UBYTE inBit = inLineBit;
00502     UBYTE inByte = *in++;
00503     int i = width;
00504     while (--i >= 0)
00505         {
00506         *out++ = ((inBit & inByte) ? color : backgroundColor);
00507         if ((inBit >>= 1) == 0)
00508             {
00509             inByte = *in++;
00510             inBit = 0x80;
00511             }
00512         }
00513     inLine += bitDataRowBytes;
00514     outLine += _mgBpr(dest);
00515     }
00516 }

Here is the call graph for this function:

void mgTextCentered ( struct memGfx mg,
int  x,
int  y,
int  width,
int  height,
Color  color,
MgFont font,
char *  text 
)

Definition at line 526 of file memgfx.c.

References mgFontPixelHeight(), mgFontStringWidth(), mgSmallFont(), and mgText().

Referenced by cdaShowAlignmentTrack(), and vgMgMethods().

00529 {
00530 int fWidth, fHeight;
00531 int xoff, yoff;
00532 fWidth = mgFontStringWidth(font, text);
00533 fHeight = mgFontPixelHeight(font);
00534 xoff = x + (width - fWidth)/2;
00535 yoff = y + (height - fHeight)/2;
00536 if (font == mgSmallFont())
00537     {
00538     xoff += 1;
00539     yoff += 1;
00540     }
00541 mgText(mg, xoff, yoff, color, font, text);
00542 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgTextRight ( struct memGfx mg,
int  x,
int  y,
int  width,
int  height,
Color  color,
MgFont font,
char *  text 
)

Definition at line 544 of file memgfx.c.

References mgFontPixelHeight(), mgFontStringWidth(), mgSmallFont(), and mgText().

Referenced by altColorLabels(), and vgMgMethods().

00547 {
00548 int fWidth, fHeight;
00549 int xoff, yoff;
00550 fWidth = mgFontStringWidth(font, text);
00551 fHeight = mgFontPixelHeight(font);
00552 xoff = x + width - fWidth - 1;
00553 yoff = y + (height - fHeight)/2;
00554 if (font == mgSmallFont())
00555     {
00556     xoff += 1;
00557     yoff += 1;
00558     }
00559 mgText(mg, xoff, yoff, color, font, text);
00560 }

Here is the call graph for this function:

Here is the caller graph for this function:

MgFont* mgTinyBoldFont (  ) 

Definition at line 477 of file mgTinyFont.c.

References TinyBold_font.

00478 {
00479 return &TinyBold_font;
00480 }

MgFont* mgTinyFixedFont (  ) 

Definition at line 697 of file mgTinyFont.c.

References TinyFixed_font.

00698 {
00699 return &TinyFixed_font;
00700 }

MgFont* mgTinyFont (  ) 

Definition at line 204 of file mgTinyFont.c.

References sixhi_font.

00205 {
00206 return &sixhi_font;
00207 }

void mgUnclip ( struct memGfx mg  ) 

Definition at line 50 of file memgfx.c.

References memGfx::height, mgSetClip(), and memGfx::width.

Referenced by mgNew(), and vgMgMethods().

00052 {
00053 mgSetClip(mg, 0,0,mg->width, mg->height);
00054 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct rgbColor mgFixedColors[9]

Definition at line 7 of file fixColor.c.

Referenced by mgSetDefaultColorMap(), and pscmSetDefaultColorMap().


Generated on Tue Dec 25 19:06:15 2007 for blat by  doxygen 1.5.2