IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29814


Ignore:
Timestamp:
Nov 24, 2010, 11:53:59 AM (15 years ago)
Author:
eugene
Message:

enable overplotting of image and graph (png & ps); remove static vars in bDrawFuncs: pass bDrawBuffer instead

Location:
branches/eam_branches/ipp-20101103/Ohana/src/libkapa
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/Ohana/src/libkapa/include/kapa.h

    r29537 r29814  
    115115
    116116typedef struct {
    117   int Nx, Ny;
     117  int Nx, Ny, Nbyte;
    118118  bDrawColor **pixels;
     119  png_color *palette;
     120  int Npalette;
     121  // current drawing values:
     122  int bWeight;
     123  int bType;
     124  bDrawColor bColor;
     125  bDrawColor bColor_R;
     126  bDrawColor bColor_G;
     127  bDrawColor bColor_B;
    119128} bDrawBuffer;
    120129
     
    165174/* KapaWindow.c */
    166175int KiiResize (int fd, int Nx, int Ny);
     176int KiiResizeByImage (int fd);
    167177int KiiRelocate (int fd, int x, int y);
    168178int KiiCenter (int fd, double x, double y, int zoom);
     
    182192int KapaGetLimits (int fd, float *dx, float *dy);
    183193int KapaSetSection (int fd, KapaSection *section);
     194int KapaSetSectionByImage (int fd, KapaSection *section);
    184195int KapaSelectSection (int fd, char *name);
    185196int KapaGetSection (int fd, char *name);
     
    221232
    222233/* bDrawFuncs.c */
    223 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny);
     234bDrawBuffer *bDrawBufferCreate (int Nx, int Ny, int Nbyte, png_color *palette, int Npalette);
    224235void bDrawBufferFree (bDrawBuffer *buffer);
    225236void bDrawSetBuffer (bDrawBuffer *buffer);
    226 void bDrawSetStyle (bDrawColor color, int lw, int lt);
    227 void bDrawPoint (int x, int y);
    228 void bDrawPointf (float x, float y);
    229 
    230 void bDrawArc (double Xc, double Yc, double Xr, double Yr, double Ts, double Te);
    231 void bDrawCircle (double Xc, double Yc, double radius);
    232 void bDrawCircleFill (double xc, double yc, double radius);
    233 
    234 void bDrawLine (double x1, double y1, double x2, double y2);
    235 void bDrawLineWeight (int X1, int Y1, int X2, int Y2, int swapcoords);
    236 void bDrawLineBresen (int X1, int Y1, int X2, int Y2, int swapcoords);
    237 void bDrawLineHorizontal (int X1, int X2, int Y);
    238 void bDrawLineVertical (int X, int Y1, int Y2);
    239 
    240 void bDrawRectOpen (double x1, double y1, double x2, double y2);
    241 void bDrawRectFill (double x1, double y1, double x2, double y2);
    242 void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3);
    243 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3);
     237void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt);
     238void bDrawPoint (bDrawBuffer *buffer, int x, int y);
     239void bDrawPointf (bDrawBuffer *buffer, float x, float y);
     240
     241void bDrawArc (bDrawBuffer *buffer, double Xc, double Yc, double Xr, double Yr, double Ts, double Te);
     242void bDrawCircle (bDrawBuffer *buffer, double Xc, double Yc, double radius);
     243void bDrawCircleFill (bDrawBuffer *buffer, double xc, double yc, double radius);
     244
     245void bDrawLine (bDrawBuffer *buffer, double x1, double y1, double x2, double y2);
     246void bDrawLineWeight (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords);
     247void bDrawLineBresen (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords);
     248void bDrawLineHorizontal (bDrawBuffer *buffer, int X1, int X2, int Y);
     249void bDrawLineVertical (bDrawBuffer *buffer, int X, int Y1, int Y2);
     250
     251void bDrawRectOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2);
     252void bDrawRectFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2);
     253void bDrawTriOpen  (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3);
     254void bDrawTriFill  (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3);
    244255
    245256/* bDrawRotFont.c */
    246 int bDrawRotText (int x, int y, char *string, int pos, double angle);
    247 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale);
     257int bDrawRotText (bDrawBuffer *buffer, int x, int y, char *string, int pos, double angle);
     258int bDrawRotBitmap (bDrawBuffer *buffer, int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale);
    248259
    249260/* Kapa Socket functions */
  • branches/eam_branches/ipp-20101103/Ohana/src/libkapa/src/KapaWindow.c

    r27790 r29814  
    2323  KiiSendCommand (fd, 4, "RSIZ");
    2424  KiiSendMessage (fd, "%d %d", Nx, Ny);
     25  KiiWaitAnswer (fd, "DONE");
     26  return (TRUE);
     27}
     28
     29int KiiResizeByImage (int fd) {
     30
     31  KiiSendCommand (fd, 4, "ISIZ");
    2532  KiiWaitAnswer (fd, "DONE");
    2633  return (TRUE);
     
    370377}
    371378
     379int KapaSetSectionByImage (int fd, KapaSection *section) {
     380
     381  KiiSendCommand (fd, 4, "ISEC");
     382  KiiSendMessage (fd, "%s %6.3f %6.3f %3d",
     383                  section[0].name,
     384                  section[0].x,
     385                  section[0].y,
     386                  section[0].bg);
     387  KiiWaitAnswer (fd, "DONE");
     388  return (TRUE);
     389}
     390
    372391int KapaSectionBG (int fd, char *name, int bg) {
    373392
  • branches/eam_branches/ipp-20101103/Ohana/src/libkapa/src/bDrawFuncs.c

    r29782 r29814  
    11# include <kapa_internal.h>
    2 
    3 // XXX we can get rid of these static vars by making them elements of the bDrawBuffer
    4 //
    5 
    6 
    7 static int bWeight;
    8 static int bType;
    9 static bDrawColor bColor;
    10 static bDrawBuffer *bBuffer;
    11 void bDrawCircleSingle (double xc, double yc, double radius);
    12 
    13 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny) {
     2# define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort (); } }
     3
     4// move these to the bDrawBuffer type
     5// static int bWeight;
     6// static int bType;
     7// static bDrawColor bColor;
     8// static bDrawColor bColor_R;
     9// static bDrawColor bColor_G;
     10// static bDrawColor bColor_B;
     11// static bDrawBuffer *bBuffer;
     12
     13void bDrawCircleSingle (bDrawBuffer *buffer, double xc, double yc, double radius);
     14
     15// create a drawing buffer with either 1 or 3 byte colors
     16bDrawBuffer *bDrawBufferCreate (int Nx, int Ny, int Nbyte, png_color *palette, int Npalette) {
    1417
    1518  int i, j;
    16   bDrawColor white;
     19  bDrawColor white, white_R, white_G, white_B;
    1720  bDrawBuffer *buffer;
    1821
     22  myAssert((Nbyte == 1) || (Nbyte == 3), "invalid depth");
     23  myAssert(palette, "missing palette");
     24
    1925  white = KapaColorByName ("white");
     26  white_R = palette[white].red;
     27  white_G = palette[white].green;
     28  white_B = palette[white].blue;
    2029
    2130  ALLOCATE (buffer, bDrawBuffer, 1);
    2231  buffer[0].Nx = Nx;
    2332  buffer[0].Ny = Ny;
     33  buffer[0].Nbyte = Nbyte;
     34  buffer[0].palette = palette;
     35  buffer[0].Npalette = Npalette;
    2436
    2537  ALLOCATE (buffer[0].pixels, bDrawColor *, Ny);
    2638  for (i = 0; i < Ny; i++) {
    27     ALLOCATE (buffer[0].pixels[i], bDrawColor, Nx);
     39    ALLOCATE (buffer[0].pixels[i], bDrawColor, Nbyte*Nx);
    2840    for (j = 0; j < Nx; j++) {
    29       buffer[0].pixels[i][j] = white;
    30     }
    31   }
     41      if (Nbyte == 1) {
     42        buffer[0].pixels[i][j] = white;
     43      } else {
     44        buffer[0].pixels[i][3*j+0] = white_R;
     45        buffer[0].pixels[i][3*j+1] = white_G;
     46        buffer[0].pixels[i][3*j+2] = white_B;
     47      }
     48    }
     49  }
     50
     51  buffer[0].bWeight = 0;
     52  buffer[0].bType = 0;
     53  buffer[0].bColor = white;
     54  buffer[0].bColor_R = white_R;
     55  buffer[0].bColor_G = white_G;
     56  buffer[0].bColor_B = white_B;
    3257  return (buffer);
    3358}
     
    4166  }
    4267  free (buffer[0].pixels);
     68  free (buffer[0].palette);
    4369  free (buffer);
    4470  return;
    4571}
    4672
    47 void bDrawSetBuffer (bDrawBuffer *buffer) {
    48   bBuffer = buffer;
    49   return;
    50 }
    51 
    52 void bDrawSetStyle (bDrawColor color, int lw, int lt) {
    53   bColor = color;
    54   bWeight = lw;
    55   bType = lt;
     73// void bDrawSetBuffer (bDrawBuffer *buffer) {
     74//   myAssert(buffer[0].Nbyte == 1, "invalid depth");
     75//   bBuffer = buffer;
     76//   return;
     77// }
     78
     79void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt) {
     80  buffer->bColor = color;
     81  buffer->bColor_R = buffer->palette[color].red;
     82  buffer->bColor_G = buffer->palette[color].green;
     83  buffer->bColor_B = buffer->palette[color].blue;
     84  buffer->bWeight = lw;
     85  buffer->bType = lt;
    5686  return;
    5787}
    5888
    5989// draw a point in the current color
    60 void bDrawPoint (int x, int y) {
    61 
     90void bDrawPoint (bDrawBuffer *buffer, int x, int y) {
     91
     92  // myAssert(buffer[0].Nbyte == 1, "invalid depth");
    6293  if (x < 0) return;
    6394  if (y < 0) return;
    64   if (x >= bBuffer[0].Nx) return;
    65   if (y >= bBuffer[0].Ny) return;
    66   bBuffer[0].pixels[y][x] = bColor;
     95  if (x >= buffer[0].Nx) return;
     96  if (y >= buffer[0].Ny) return;
     97  if (buffer[0].Nbyte == 1) {
     98    buffer[0].pixels[y][x] = buffer->bColor;
     99  } else {
     100    buffer[0].pixels[y][3*x+0] = buffer->bColor_R;
     101    buffer[0].pixels[y][3*x+1] = buffer->bColor_G;
     102    buffer[0].pixels[y][3*x+2] = buffer->bColor_B;
     103  }
    67104  return;
    68105}
    69106
    70107// draw a point in the current color
    71 void bDrawPointf (float x, float y) {
    72 
    73   bDrawPoint (ROUND(x), ROUND(y));
    74   return;
    75 }
    76 
    77 void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3) {
    78 
    79   bDrawLine (x1, y1, x2, y2);
    80   bDrawLine (x2, y2, x3, y3);
    81   bDrawLine (x3, y3, x1, y1);
    82 
    83   return;
    84 }
    85 
    86 void bDrawRectOpen (double x1, double y1, double x2, double y2) {
     108void bDrawPointf (bDrawBuffer *buffer, float x, float y) {
     109
     110  bDrawPoint (buffer, ROUND(x), ROUND(y));
     111  return;
     112}
     113
     114void bDrawTriOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3) {
     115
     116  bDrawLine (buffer, x1, y1, x2, y2);
     117  bDrawLine (buffer, x2, y2, x3, y3);
     118  bDrawLine (buffer, x3, y3, x1, y1);
     119
     120  return;
     121}
     122
     123void bDrawRectOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) {
    87124
    88125  int X1, Y1, X2, Y2;
     
    91128  if (y1 > y2) SWAP (y1, y2);
    92129
    93   X1 = MIN (MAX (ROUND (x1), 0), bBuffer[0].Nx - 1);
    94   X2 = MIN (MAX (ROUND (x2), 1), bBuffer[0].Nx - 1);
    95 
    96   Y1 = MIN (MAX (ROUND (y1), 0), bBuffer[0].Ny - 1);
    97   Y2 = MIN (MAX (ROUND (y2), 1), bBuffer[0].Ny - 1);
    98 
    99   bDrawLineHorizontal (X1, X2, Y1);
    100   bDrawLineHorizontal (X1, X2, Y2);
    101   bDrawLineVertical (X1, Y1, Y2);
    102   bDrawLineVertical (X2, Y1, Y2);
    103   return;
    104 }
    105 
    106 void bDrawRectFill (double x1, double y1, double x2, double y2) {
     130  X1 = MIN (MAX (ROUND (x1), 0), buffer[0].Nx - 1);
     131  X2 = MIN (MAX (ROUND (x2), 1), buffer[0].Nx - 1);
     132
     133  Y1 = MIN (MAX (ROUND (y1), 0), buffer[0].Ny - 1);
     134  Y2 = MIN (MAX (ROUND (y2), 1), buffer[0].Ny - 1);
     135
     136  bDrawLineHorizontal (buffer, X1, X2, Y1);
     137  bDrawLineHorizontal (buffer, X1, X2, Y2);
     138  bDrawLineVertical   (buffer, X1, Y1, Y2);
     139  bDrawLineVertical   (buffer, X2, Y1, Y2);
     140  return;
     141}
     142
     143void bDrawRectFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) {
    107144
    108145  int i;
     
    112149  if (y1 > y2) SWAP (y1, y2);
    113150
    114   X1 = MIN (MAX (ROUND (x1), 0), bBuffer[0].Nx - 1);
    115   X2 = MIN (MAX (ROUND (x2), 1), bBuffer[0].Nx - 1);
    116 
    117   Y1 = MIN (MAX (ROUND (y1), 0), bBuffer[0].Ny - 1);
    118   Y2 = MIN (MAX (ROUND (y2), 0), bBuffer[0].Ny - 1);
     151  X1 = MIN (MAX (ROUND (x1), 0), buffer[0].Nx - 1);
     152  X2 = MIN (MAX (ROUND (x2), 1), buffer[0].Nx - 1);
     153
     154  Y1 = MIN (MAX (ROUND (y1), 0), buffer[0].Ny - 1);
     155  Y2 = MIN (MAX (ROUND (y2), 0), buffer[0].Ny - 1);
    119156
    120157  for (i = Y1; i < Y2; i++) {
    121     bDrawLineHorizontal (X1, X2, i);
     158    bDrawLineHorizontal (buffer, X1, X2, i);
    122159  }
    123160  return;
     
    125162
    126163// identify the quadrant and draw the correct line
    127 void bDrawLine (double x1, double y1, double x2, double y2) {
     164void bDrawLine (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) {
    128165
    129166  int FlipDirect, FlipCoords;
     
    144181  FlipDirect = FlipCoords ? (y1 > y2) : (x1 > x2);
    145182
    146   if (!FlipDirect && !FlipCoords) bDrawLineWeight (X1, Y1, X2, Y2, FALSE);
    147   if ( FlipDirect && !FlipCoords) bDrawLineWeight (X2, Y2, X1, Y1, FALSE);
    148   if (!FlipDirect &&  FlipCoords) bDrawLineWeight (Y1, X1, Y2, X2, TRUE);
    149   if ( FlipDirect &&  FlipCoords) bDrawLineWeight (Y2, X2, Y1, X1, TRUE);
     183  if (!FlipDirect && !FlipCoords) bDrawLineWeight (buffer, X1, Y1, X2, Y2, FALSE);
     184  if ( FlipDirect && !FlipCoords) bDrawLineWeight (buffer, X2, Y2, X1, Y1, FALSE);
     185  if (!FlipDirect &&  FlipCoords) bDrawLineWeight (buffer, Y1, X1, Y2, X2, TRUE);
     186  if ( FlipDirect &&  FlipCoords) bDrawLineWeight (buffer, Y2, X2, Y1, X1, TRUE);
    150187
    151188  return;
     
    153190
    154191// draw a series of lines to give the line weight
    155 void bDrawLineWeight (int X1, int Y1, int X2, int Y2, int swapcoords) {
     192void bDrawLineWeight (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords) {
    156193
    157194  int dN, dNs, dNe;
    158195
    159   dNs = -0.5*(bWeight - 1);
     196  dNs = -0.5*(buffer->bWeight - 1);
    160197  /* 0, 0, 0, -1, -1, -2, -2 */
    161198
    162   dNe = +0.5*bWeight + 1;
     199  dNe = +0.5*buffer->bWeight + 1;
    163200  /* 1, 1, 2, 2, 2, 3, 3 */
    164201
    165202  for (dN = dNs; dN < dNe; dN++) {
    166     bDrawLineBresen (X1, Y1 + dN, X2, Y2 + dN, swapcoords);
     203    bDrawLineBresen (buffer, X1, Y1 + dN, X2, Y2 + dN, swapcoords);
    167204  }
    168205  return;
     
    171208// use the Bresenham line drawing technique
    172209// integer-only Bresenham line-draw version which is fast
    173 void bDrawLineBresen (int X1, int Y1, int X2, int Y2, int swapcoords) {
     210void bDrawLineBresen (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords) {
    174211
    175212  int X, Y, dX, dY;
     
    185222  e = 0;
    186223  for (X = X1, N = 0; X <= X2; X++, N++) {
    187     if (bType == 1) { DashOn = (N % 10) < 5; }
    188     if (bType == 2) { DashOn = (N % 6) < 3; }
     224    if (buffer->bType == 1) { DashOn = (N % 10) < 5; }
     225    if (buffer->bType == 2) { DashOn = (N % 6) < 3; }
    189226    if (swapcoords) {
    190       if (DashOn) bDrawPoint (Y,X);
     227      if (DashOn) bDrawPoint (buffer, Y,X);
    191228    } else {
    192       if (DashOn) bDrawPoint (X,Y);
     229      if (DashOn) bDrawPoint (buffer, X,Y);
    193230    }
    194231    e += dY;
     
    206243}
    207244
    208 void bDrawLineHorizontal (int X1, int X2, int Y) {
     245void bDrawLineHorizontal (bDrawBuffer *buffer, int X1, int X2, int Y) {
    209246 
    210247  int i;
    211248
    212249  for (i = X1; i < X2; i++) {
    213     bBuffer[0].pixels[Y][i] = bColor;
    214   }
    215   return;
    216 }
    217 
    218 void bDrawLineVertical (int X, int Y1, int Y2) {
     250    if (buffer[0].Nbyte == 1) {
     251      buffer[0].pixels[Y][i] = buffer->bColor;
     252    } else {
     253      buffer[0].pixels[Y][3*i+0] = buffer->bColor_R;
     254      buffer[0].pixels[Y][3*i+1] = buffer->bColor_G;
     255      buffer[0].pixels[Y][3*i+2] = buffer->bColor_B;
     256    }
     257  }
     258  return;
     259}
     260
     261void bDrawLineVertical (bDrawBuffer *buffer, int X, int Y1, int Y2) {
    219262 
    220263  int i;
    221264
    222265  for (i = Y1; i < Y2; i++) {
    223     bBuffer[0].pixels[i][X] = bColor;
    224   }
    225   return;
    226 }
    227 
    228 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3) {
    229 
    230   bDrawTriOpen (x1, y1, x2, y2, x3, y3);
    231   return;
    232 }
    233 
    234 void bDrawArc (double Xc, double Yc, double Xr, double Yr, double Ts, double Te) {
     266    if (buffer[0].Nbyte == 1) {
     267      buffer[0].pixels[i][X] = buffer->bColor;
     268    } else {
     269      buffer[0].pixels[i][3*X+0] = buffer->bColor_R;
     270      buffer[0].pixels[i][3*X+1] = buffer->bColor_G;
     271      buffer[0].pixels[i][3*X+2] = buffer->bColor_B;
     272    }
     273  }
     274  return;
     275}
     276
     277void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3) {
     278
     279  bDrawTriOpen (buffer, x1, y1, x2, y2, x3, y3);
     280  return;
     281}
     282
     283void bDrawArc (bDrawBuffer *buffer, double Xc, double Yc, double Xr, double Yr, double Ts, double Te) {
    235284
    236285  float t, dt;
     
    258307
    259308    /* we could use the value of MAX(dy/dt,dx/dt) to set dt */
    260     bDrawPoint (x,y);
     309    bDrawPoint (buffer, x,y);
    261310
    262311    dt = MAX (fabs(Xr * sin(t)), fabs(Yr * cos(t)));
     
    267316
    268317// draw a series of circles to give line weight
    269 void bDrawCircle (double xc, double yc, double radius) {
     318void bDrawCircle (bDrawBuffer *buffer, double xc, double yc, double radius) {
    270319
    271320  int dN, dNs, dNe;
    272321
    273   dNs = -0.5*(bWeight - 1);
     322  dNs = -0.5*(buffer->bWeight - 1);
    274323  /* 0, 0, 0, -1, -1, -2, -2 */
    275324
    276   dNe = +0.5*bWeight + 1;
     325  dNe = +0.5*buffer->bWeight + 1;
    277326  /* 1, 1, 2, 2, 2, 3, 3 */
    278327
    279328  for (dN = dNs; dN < dNe; dN++) {
    280     bDrawCircleSingle (xc, yc, radius + dN);
     329    bDrawCircleSingle (buffer, xc, yc, radius + dN);
    281330  }
    282331  return;
     
    284333
    285334// draw a pure circle 
    286 void bDrawCircleSingle (double xc, double yc, double radius) {
     335void bDrawCircleSingle (bDrawBuffer *buffer, double xc, double yc, double radius) {
    287336
    288337  int Xc, Yc, Radius;
     
    300349
    301350  while (x <= y) {
    302     bDrawPoint (Xc+x, Yc+y);
    303     bDrawPoint (Xc+x, Yc-y);
    304     bDrawPoint (Xc-x, Yc+y);
    305     bDrawPoint (Xc-x, Yc-y);
    306     bDrawPoint (Xc+y, Yc+x);
    307     bDrawPoint (Xc+y, Yc-x);
    308     bDrawPoint (Xc-y, Yc+x);
    309     bDrawPoint (Xc-y, Yc-x);
     351    bDrawPoint (buffer, Xc+x, Yc+y);
     352    bDrawPoint (buffer, Xc+x, Yc-y);
     353    bDrawPoint (buffer, Xc-x, Yc+y);
     354    bDrawPoint (buffer, Xc-x, Yc-y);
     355    bDrawPoint (buffer, Xc+y, Yc+x);
     356    bDrawPoint (buffer, Xc+y, Yc-x);
     357    bDrawPoint (buffer, Xc-y, Yc+x);
     358    bDrawPoint (buffer, Xc-y, Yc-x);
    310359
    311360    if (d < 0) {
     
    322371
    323372// draw a pure circle 
    324 void bDrawCircleFill (double xc, double yc, double radius) {
     373void bDrawCircleFill (bDrawBuffer *buffer, double xc, double yc, double radius) {
    325374
    326375  int Xc, Yc, Radius;
     
    338387
    339388  while (x <= y) {
    340     bDrawLineHorizontal (Xc-x, Xc+x, Yc+y);
    341     bDrawLineHorizontal (Xc-x, Xc+x, Yc-y);
    342     bDrawLineHorizontal (Xc-y, Xc+y, Yc+x);
    343     bDrawLineHorizontal (Xc-y, Xc+y, Yc-x);
     389    bDrawLineHorizontal (buffer, Xc-x, Xc+x, Yc+y);
     390    bDrawLineHorizontal (buffer, Xc-x, Xc+x, Yc-y);
     391    bDrawLineHorizontal (buffer, Xc-y, Xc+y, Yc+x);
     392    bDrawLineHorizontal (buffer, Xc-y, Xc+y, Yc-x);
    344393
    345394    if (d < 0) {
  • branches/eam_branches/ipp-20101103/Ohana/src/libkapa/src/bDrawRotFont.c

    r12332 r29814  
    66# define NEARINT(x) ((x < 0) ? ((int)(x - 0.5)) : ((int)(x + 0.5)))
    77 
    8 static bDrawColor black;
    9 static bDrawColor white;
    10 
    11 int bDrawRotText (int x, int y, char *string, int pos, double angle) {
     8// XXX need to pass the rot text color here
     9// static bDrawColor black;
     10// static bDrawColor white;
     11
     12int bDrawRotText (bDrawBuffer *buffer, int x, int y, char *string, int pos, double angle) {
    1213
    1314  unsigned char *bitmap;
     
    1920  RotFont *currentfont;
    2021
    21   white = KapaColorByName ("white");
    22   black = KapaColorByName ("black");
     22  // white = KapaColorByName ("white");
     23  // black = KapaColorByName ("black");
    2324
    2425  currentname = GetRotFont (&currentsize);
     
    111112    X = x + (int)(Xoff*cs - Yoff*sn) + (int)(currentscale*currentfont[N].ascent*sn);
    112113    Y = y + (int)(Xoff*sn + Yoff*cs) - (int)(currentscale*currentfont[N].ascent*cs);
    113     bDrawRotBitmap (X, Y, dx, dy, bitmap, TRUE, angle, currentscale);
     114    bDrawRotBitmap (buffer, X, Y, dx, dy, bitmap, TRUE, angle, currentscale);
    114115    Xoff += 1 + (int)(currentscale*dx + 0.5);
    115116  }
     
    118119}
    119120
    120 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale) {
     121int bDrawRotBitmap (bDrawBuffer *buffer, int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale) {
    121122
    122123  int ii, jj, byte_line, byte, bit, flag;
    123   bDrawColor color;
    124124  double i, j, cs, sn, rscale, tmp;
    125125  int X, Y, X0, X1, X2, Y0, Y1, Y2, x0, y0;
    126126
    127127  /* this mode option is nort actually used... */
    128   if (mode) {
    129     color = black;
    130   } else {
    131     color = white;
    132   }
     128  // if (mode) {
     129  //   color = black;
     130  // } else {
     131  //   color = white;
     132  // }
    133133   
    134134  byte_line = (int) ((dx + 7) / 8);
     
    148148  Y = YPROC (dx,0);
    149149# ifdef DRAWBOXES
    150   bDrawLine (x+X, y+Y, x+X1, y+Y1);
     150  bDrawLine (buffer, x+X, y+Y, x+X1, y+Y1);
    151151  Xt = X;
    152152  Yt = Y;
     
    160160  Y = YPROC (dx,dy);
    161161# ifdef DRAWBOXES
    162   bDrawLine (x+X, y+Y, x+Xt, y+Yt);
     162  bDrawLine (buffer, x+X, y+Y, x+Xt, y+Yt);
    163163  Xt = X;
    164164  Yt = Y;
     
    172172  Y = YPROC (0,dy);
    173173# ifdef DRAWBOXES
    174   bDrawLine (x+X, y+Y, x+Xt, y+Yt);
     174  bDrawLine (buffer, x+X, y+Y, x+Xt, y+Yt);
    175175  Xt = X;
    176176  Yt = Y;
     
    181181  X2 = MAX (X, X2);
    182182
    183   bDrawSetStyle (color, 0, 0);
     183  // bDrawSetStyle (color, 0, 0);
    184184  if (scale > 1) {
    185185    for (i = X1; i <= X2; i+=1) {
     
    191191        bit = ii % 8;
    192192        flag = 0x01 & (bitmap[byte] >> bit);
    193         if (flag) bDrawPointf (x + i, y + j);
     193        if (flag) bDrawPointf (buffer, x + i, y + j);
    194194      }
    195195    }
     
    203203        bit = ii % 8;
    204204        flag = 0x01 & (bitmap[byte] >> bit);
    205         if (flag) bDrawPointf (x + i, y + j);
     205        if (flag) bDrawPointf (buffer, x + i, y + j);
    206206      }
    207207    }
    208208  }
    209   bDrawSetStyle (black, 0, 0);
     209  // bDrawSetStyle (black, 0, 0);
    210210  return (TRUE);
    211211}
Note: See TracChangeset for help on using the changeset viewer.