lib/memgfx.c File Reference

#include "common.h"
#include "memgfx.h"
#include "gemfont.h"
#include "localmem.h"
#include "vGfx.h"
#include "vGfxPrivate.h"
#include "colHash.h"

Include dependency graph for memgfx.c:

Go to the source code of this file.

Functions

static void mgSetDefaultColorMap (struct memGfx *mg)
void mgSetClip (struct memGfx *mg, int x, int y, int width, int height)
void mgUnclip (struct memGfx *mg)
memGfxmgNew (int width, int height)
void mgClearPixels (struct memGfx *mg)
Color mgFindColor (struct memGfx *mg, unsigned char r, unsigned char g, unsigned char b)
rgbColor mgColorIxToRgb (struct memGfx *mg, int colorIx)
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 mgFree (struct memGfx **pmg)
static void nonZeroCopy (Color *d, Color *s, int width)
static void mgPutSegMaybeZeroClear (struct memGfx *mg, int x, int y, int width, Color *dots, boolean zeroClear)
void mgVerticalSmear (struct memGfx *mg, int xOff, int yOff, int width, int height, unsigned char *dots, boolean zeroClear)
void mgDrawBox (struct memGfx *mg, int x, int y, int width, int height, Color color)
void mgBrezy (struct memGfx *mg, int x1, int y1, int x2, int y2, Color color, int yBase, boolean fillFromBase)
void mgDrawLine (struct memGfx *mg, int x1, int y1, int x2, int y2, Color color)
void mgFillUnder (struct memGfx *mg, int x1, int y1, int x2, int y2, int bottom, Color color)
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 mgDrawHorizontalLine (struct memGfx *mg, int y1, Color color)
void mgLineH (struct memGfx *mg, int y, int x1, int x2, Color color)
boolean mgClipForBlit (int *w, int *h, int *sx, int *sy, struct memGfx *dest, int *dx, int *dy)
void mgTextBlit (int width, int height, int bitX, int bitY, unsigned char *bitData, int bitDataRowBytes, struct memGfx *dest, int destX, int destY, Color color, Color backgroundColor)
void mgTextBlitSolid (int width, int height, int bitX, int bitY, unsigned char *bitData, int bitDataRowBytes, struct memGfx *dest, int destX, int destY, Color color, Color backgroundColor)
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 mgSlowDot (struct memGfx *mg, int x, int y, int colorIx)
int mgSlowGetDot (struct memGfx *mg, int x, int y)
memGfxmgRotate90 (struct memGfx *in)
void mgSetHint (char *hint)
char * mgGetHint (char *hint)
void vgMgMethods (struct vGfx *vg)

Variables

static char const rcsid [] = "$Id: memgfx.c,v 1.47 2007/04/15 00:33:35 galt Exp $"


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 mgBrezy ( struct memGfx mg,
int  x1,
int  y1,
int  x2,
int  y2,
Color  color,
int  yBase,
boolean  fillFromBase 
)

Definition at line 244 of file memgfx.c.

References dots, memGfx::height, mgDrawBox(), mgPutDot, and memGfx::width.

Referenced by mgDrawLine(), and mgFillUnder().

00247 {
00248 if (x1 == x2)
00249     {
00250     int y,height;
00251     if (y1 > y2)
00252         {
00253         y = y2;
00254         height = y1-y2+1;
00255         }
00256     else
00257         {
00258         y = y1;
00259         height = y2-y1+1;
00260         }
00261     if (fillFromBase)
00262         {
00263         if (y < yBase)
00264             mgDrawBox(mg, x1, y, 1, yBase-y, color);
00265         }
00266     else
00267         mgDrawBox(mg, x1, y, 1, height, color);
00268     }
00269 else if (y1 == y2)
00270     {
00271     int x,width;
00272     if (x1 > x2)
00273         {
00274         x = x2;
00275         width = x1-x2+1;
00276         }
00277     else
00278         {
00279         x = x1;
00280         width = x2-x1+1;
00281         }
00282     if (fillFromBase)
00283         {
00284         if (y1 < yBase)
00285             mgDrawBox(mg, x, y1, width, yBase - y1, color);
00286         }
00287     else
00288         {
00289         mgDrawBox(mg, x, y1, width, 1, color);
00290         }
00291     }
00292 else
00293     {
00294     int duty_cycle;
00295     int incy;
00296     int delta_x, delta_y;
00297     int dots;
00298     delta_y = y2-y1;
00299     delta_x = x2-x1;
00300     if (delta_y < 0) 
00301         {
00302         delta_y = -delta_y;
00303         incy = -1;
00304         }
00305     else
00306         {
00307         incy = 1;
00308         }
00309     if (delta_x < 0) 
00310         {
00311         delta_x = -delta_x;
00312         incy = -incy;
00313         x1 = x2;
00314         y1 = y2;
00315         }
00316     duty_cycle = (delta_x - delta_y)/2;
00317     if (delta_x >= delta_y)
00318         {
00319         dots = delta_x+1;
00320         while (--dots >= 0)
00321             {
00322             if (fillFromBase)
00323                 {
00324                 if (y1 < yBase)
00325                     mgDrawBox(mg,x1,y1,1,yBase-y1,color);
00326                 }
00327             else
00328                 mgPutDot(mg,x1,y1,color);
00329             duty_cycle -= delta_y;
00330             x1 += 1;
00331             if (duty_cycle < 0)
00332                 {
00333                 duty_cycle += delta_x;    /* update duty cycle */
00334                 y1+=incy;
00335                 }
00336             }
00337         }
00338     else
00339         {
00340         dots = delta_y+1;
00341         while (--dots >= 0)
00342             {
00343             if (fillFromBase)
00344                 {
00345                 if (y1 < yBase)
00346                     mgDrawBox(mg,x1,y1,1,yBase-y1,color);
00347                 }
00348             else
00349                 mgPutDot(mg,x1,y1,color);
00350             duty_cycle += delta_x;
00351             y1+=incy;
00352             if (duty_cycle > 0)
00353                 {
00354                 duty_cycle -= delta_y;    /* update duty cycle */
00355                 x1 += 1;
00356                 }
00357             }
00358         }
00359     }
00360 }

Here is the call graph for this function:

Here is the caller 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:

boolean mgClipForBlit ( int *  w,
int *  h,
int *  sx,
int *  sy,
struct memGfx dest,
int *  dx,
int *  dy 
)

Definition at line 420 of file memgfx.c.

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

Referenced by mgTextBlit(), and mgTextBlitSolid().

00422 {
00423 /* Make sure we don't overwrite destination. */
00424 int over;
00425 
00426 if ((over = dest->clipMinX - *dx) > 0)
00427     {
00428     *w -= over;
00429     *sx += over;
00430     *dx = dest->clipMinX;
00431     }
00432 if ((over = dest->clipMinY - *dy) > 0)
00433     {
00434     *h -= over;
00435     *sy += over;
00436     *dy = dest->clipMinY;
00437     }
00438 if ((over = *w + *dx - dest->clipMaxX) > 0)
00439     *w -= over; 
00440 if ((over = *h + *dy - dest->clipMaxY) > 0)
00441     *h -= over;
00442 return (*h > 0 && *w > 0);
00443 }

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:

struct rgbColor mgColorIxToRgb ( struct memGfx mg,
int  colorIx 
) [read]

Definition at line 91 of file memgfx.c.

Referenced by vgMgMethods().

00093 {
00094 return mg->colorMap[colorIx];
00095 }

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 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:

char* mgGetHint ( char *  hint  ) 

Definition at line 636 of file memgfx.c.

Referenced by vgMgMethods().

00638 {
00639 return "";
00640 }

Here is the caller graph for this function:

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* 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:

static void mgPutSegMaybeZeroClear ( struct memGfx mg,
int  x,
int  y,
int  width,
Color dots,
boolean  zeroClear 
) [static]

Definition at line 172 of file memgfx.c.

References _mgPixAdr, memGfx::clipMaxX, memGfx::clipMaxY, memGfx::clipMinX, memGfx::clipMinY, and nonZeroCopy().

Referenced by mgPutSeg(), mgPutSegZeroClear(), and mgVerticalSmear().

00175 {
00176 int x2;
00177 Color *pt;
00178 if (y < mg->clipMinY || y > mg->clipMaxY)
00179     return;
00180 x2 = x + width;
00181 if (x2 > mg->clipMaxX)
00182     x2 = mg->clipMaxX;
00183 if (x < mg->clipMinX)
00184     {
00185     dots += mg->clipMinX - x;
00186     x = mg->clipMinX;
00187     }
00188 width = x2 - x;
00189 if (width > 0)
00190     {
00191     pt = _mgPixAdr(mg, x, y);
00192     if (zeroClear)
00193         nonZeroCopy(pt, dots, width);
00194     else
00195         memcpy(pt, dots, width);
00196     }
00197 }

Here is the call graph for this function:

Here is the caller 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 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:

static void mgSetDefaultColorMap ( struct memGfx mg  )  [static]

Definition at line 17 of file memgfx.c.

References ArraySize, mgAddColor(), and mgFixedColors.

Referenced by mgNew().

00019 {
00020 /* Note dependency in order here and in MG_WHITE, MG_BLACK, etc. */
00021 int i;
00022 for (i=0; i<ArraySize(mgFixedColors); ++i)
00023     {
00024     struct rgbColor *c = &mgFixedColors[i];
00025     mgAddColor(mg, c->r, c->g, c->b);
00026     }
00027 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mgSetHint ( char *  hint  ) 

Definition at line 630 of file memgfx.c.

Referenced by vgMgMethods().

00632 {
00633 return;
00634 }

Here is the caller graph for this function:

void mgSlowDot ( struct memGfx mg,
int  x,
int  y,
int  colorIx 
)

Definition at line 593 of file memgfx.c.

References mgPutDot.

Referenced by vgMgMethods().

00595 {
00596 mgPutDot(mg, x, y, colorIx);
00597 }

Here is the caller graph for this function:

int mgSlowGetDot ( struct memGfx mg,
int  x,
int  y 
)

Definition at line 599 of file memgfx.c.

References mgGetDot.

Referenced by vgMgMethods().

00601 {
00602 return mgGetDot(mg, x, y);
00603 }

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  width,
int  height,
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  width,
int  height,
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:

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:

void mgVerticalSmear ( struct memGfx mg,
int  xOff,
int  yOff,
int  width,
int  height,
unsigned char *  dots,
boolean  zeroClear 
)

Definition at line 199 of file memgfx.c.

References mgPutSegMaybeZeroClear().

Referenced by vgMgMethods().

00203 {
00204 while (--height >= 0)
00205     {
00206     mgPutSegMaybeZeroClear(mg, xOff, yOff, width, dots, zeroClear);
00207     ++yOff;
00208     }
00209 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nonZeroCopy ( Color d,
Color s,
int  width 
) [static]

Definition at line 160 of file memgfx.c.

Referenced by mgPutSegMaybeZeroClear().

00162 {
00163 Color c;
00164 int i;
00165 for (i=0; i<width; ++i)
00166     {
00167     if ((c = s[i]) != 0)
00168         d[i] = c;
00169     }
00170 }

Here is the caller graph for this function:

void vgMgMethods ( struct vGfx vg  ) 

Definition at line 642 of file memgfx.c.

References vGfx::box, vGfx::close, vGfx::colorIxToRgb, vGfx::dot, vGfx::drawPoly, vGfx::fillUnder, vGfx::findColorIx, vGfx::getDot, vGfx::getHint, vGfx::line, mgColorIxToRgb(), mgDrawBox(), mgDrawLine(), mgDrawPoly(), mgFillUnder(), mgFindColor(), mgFree(), mgGetHint(), mgSetClip(), mgSetHint(), mgSlowDot(), mgSlowGetDot(), mgText(), mgTextCentered(), mgTextRight(), mgUnclip(), mgVerticalSmear(), vGfx::pixelBased, vGfx::setClip, vGfx::setHint, vGfx::text, vGfx::textCentered, vGfx::textRight, TRUE, vGfx::unclip, vGfx::verticalSmear, and vg_colorIxToRgb.

Referenced by vgOpenGif().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char const rcsid[] = "$Id: memgfx.c,v 1.47 2007/04/15 00:33:35 galt Exp $" [static]

Definition at line 15 of file memgfx.c.


Generated on Tue Dec 25 20:02:35 2007 for blat by  doxygen 1.5.2