Changeset 513


Ignore:
Timestamp:
Apr 20, 2011, 8:32:26 AM (7 years ago)
Author:
Sam Hocevar
Message:

imlib: some more vec2i transition for simplicity.

Location:
abuse/trunk/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/dev.cpp

    r512 r513  
    247247                            (the_game->first_view->cy2-the_game->first_view->cy1+1)/2;
    248248
    249   small_render=new image((the_game->first_view->cx2-the_game->first_view->cx1+1),
    250              (the_game->first_view->cy2-the_game->first_view->cy1+1),NULL,2);
     249  small_render=new image(vec2i(the_game->first_view->cx2-the_game->first_view->cx1+1, the_game->first_view->cy2-the_game->first_view->cy1+1),NULL,2);
    251250}
    252251
     
    30043003  {
    30053004    me->clear();
    3006     image *im=new image(the_game->ftile_width(),the_game->ftile_height());
     3005    image *im=new image(vec2i(the_game->ftile_width(),the_game->ftile_height()));
    30073006    int th=the_game->ftile_height()/scale,tw=the_game->ftile_width()/scale;
    30083007
  • abuse/trunk/src/devsel.cpp

    r512 r513  
    9292{
    9393  int yo=y,ya=pich(),xw=picw(),c=get_current(),xo;
    94   image im(xw,ya);
     94  image im(vec2i(xw, ya));
    9595  last_sel=newx;
    9696
  • abuse/trunk/src/endgame.cpp

    r512 r513  
    181181  fade_out(16);
    182182
    183   image blank(2,2); blank.clear();
     183  image blank(vec2i(2)); blank.clear();
    184184  wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
    185185
     
    424424{
    425425  fade_out(16);
    426   image blank(2,2); blank.clear();
     426  image blank(vec2i(2, 2)); blank.clear();
    427427  wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
    428428  screen->clear();
     
    480480{
    481481  fade_out(16);
    482   image blank(2,2); blank.clear();
     482  image blank(vec2i(2, 2)); blank.clear();
    483483  wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
    484484  screen->clear();
  • abuse/trunk/src/game.cpp

    r512 r513  
    12441244    // exit() will try to delete (through the desctructor of
    12451245    // image_list in image.cpp) the image on the stack -> boom.
    1246     image *blank = new image(2, 2);
     1246    image *blank = new image(vec2i(2, 2));
    12471247    blank->clear();
    12481248    wm->set_mouse_shape(blank->copy(), 0, 0); // hide mouse
  • abuse/trunk/src/imlib/fonts.cpp

    r512 r513  
    6565  th=(letters->Size().y+1)/8;
    6666
    67   image tmp(tl,th);
     67  image tmp(vec2i(tl,th));
    6868
    6969  int ch;
  • abuse/trunk/src/imlib/image.cpp

    r512 r513  
    8080
    8181
    82 image_descriptor::image_descriptor(int16_t length, int16_t height,
     82image_descriptor::image_descriptor(vec2i size,
    8383                   int keep_dirties, int static_memory)
    8484
    8585{ clipx1=0; clipy1=0;
    86   l=length; h=height;
     86  l=size.x; h=size.y;
    8787  clipx2=l-1; clipy2=h-1;
    8888  keep_dirt=keep_dirties;
     
    9090}
    9191
    92 void image::change_size(int16_t new_width, int16_t new_height, uint8_t *page)
    93 {
    94   delete_page();
    95   size = vec2i(new_width, new_height);
    96   make_page(new_width, new_height, page);
     92void image::SetSize(vec2i new_size, uint8_t *page)
     93{
     94    delete_page();
     95    m_size = new_size;
     96    make_page(new_size, page);
    9797}
    9898
    9999image::~image()
    100100{
    101     if(_locked)
     101    if(m_locked)
    102102    {
    103103        fprintf(stderr, "Error: image is locked upon deletion\n");
     
    121121uint8_t image::pixel(int16_t x, int16_t y)
    122122{
    123   CONDITION(x>=0 && x<size.x && y>=0 && y<size.y,
     123  CONDITION(x>=0 && x<m_size.x && y>=0 && y<m_size.y,
    124124     "image::pixel Bad pixel xy");
    125125  return (*(scan_line(y)+x));
     
    128128void image::putpixel(int16_t x, int16_t y, char color)
    129129{
    130   CONDITION(x>=0 && x<size.x && y>=0 && y<size.y,
     130  CONDITION(x>=0 && x<m_size.x && y>=0 && y<m_size.y,
    131131     "image::putpixel Bad pixel xy");
    132132  if (special)
     
    138138
    139139
    140 image::image(int16_t width, int16_t height, uint8_t *page_buffer, int16_t create_descriptor)
    141 {
    142   size = vec2i(width, height);
    143   if (create_descriptor || page_buffer)
    144   {
    145     if (create_descriptor==2)
    146       special=new image_descriptor(width, height, 1, (page_buffer!=NULL));
    147     else special=new image_descriptor(width, height, 0, (page_buffer!=NULL));
    148   } else special=NULL;
    149   make_page(width, height, page_buffer);
    150   image_list.add_end((linked_node *) this);
    151     _locked = false;
     140image::image(vec2i size, uint8_t *page_buffer, int create_descriptor)
     141{
     142    m_size = size;
     143    if (create_descriptor || page_buffer)
     144    {
     145        if (create_descriptor==2)
     146            special=new image_descriptor(size, 1, (page_buffer!=NULL));
     147        else
     148            special=new image_descriptor(size, 0, (page_buffer!=NULL));
     149    }
     150    else
     151        special = NULL;
     152    make_page(size, page_buffer);
     153    image_list.add_end((linked_node *)this);
     154    m_locked = false;
    152155}
    153156
    154157image::image(spec_entry *e, bFILE *fp)
    155158{
    156     int16_t i;
    157159    fp->seek(e->offset, 0);
    158     size.x = fp->read_uint16();
    159     size.y = fp->read_uint16();
     160    m_size.x = fp->read_uint16();
     161    m_size.y = fp->read_uint16();
    160162    special = NULL;
    161     make_page(size.x, size.y, NULL);
    162     for (i = 0; i < size.y; i++)
    163         fp->read(scan_line(i), size.x);
     163    make_page(m_size, NULL);
     164    for (int i = 0; i < m_size.y; i++)
     165        fp->read(scan_line(i), m_size.x);
    164166    image_list.add_end((linked_node *) this);
    165     _locked = false;
     167    m_locked = false;
    166168}
    167169
    168170image::image(bFILE *fp)
    169171{
    170     int16_t i;
    171     size.x = fp->read_uint16();
    172     size.y = fp->read_uint16();
     172    m_size.x = fp->read_uint16();
     173    m_size.y = fp->read_uint16();
    173174    special = NULL;
    174     make_page(size.x, size.y, NULL);
    175     for (i = 0; i < size.y; i++)
    176         fp->read(scan_line(i), size.x);
     175    make_page(m_size, NULL);
     176    for (int i = 0; i < m_size.y; i++)
     177        fp->read(scan_line(i), m_size.x);
    177178    image_list.add_end((linked_node *) this);
    178     _locked = false;
     179    m_locked = false;
    179180}
    180181
     
    183184    /* This is currently a no-op, because it's unneeded with SDL */
    184185
    185     if(_locked)
     186    if(m_locked)
    186187        fprintf(stderr, "Trying to lock a locked picture!\n");
    187     _locked = true;
     188    m_locked = true;
    188189}
    189190
     
    192193    /* This is currently a no-op, because it's unneeded with SDL */
    193194
    194     if(!_locked)
     195    if(!m_locked)
    195196        fprintf(stderr, "Trying to unlock an unlocked picture!\n");
    196     _locked = false;
     197    m_locked = false;
    197198}
    198199
     
    237238
    238239    lock();
    239     for(co = 0, i = size.y - 1; i >= 0; i--)
     240    for(co = 0, i = m_size.y - 1; i >= 0; i--)
    240241    {
    241242        c = scan_line(i);
    242         for(j = size.x - 1; j >= 0; j--, c++)
     243        for(j = m_size.x - 1; j >= 0; j--, c++)
    243244            if(*c != background) co++;
    244245    }
     
    262263    }
    263264    else
    264         for(i = size.y - 1; i >= 0; i--)
    265             memset(scan_line(i), color, size.x);
    266     add_dirty(0, 0, size.x - 1, size.y - 1);
     265        for(i = m_size.y - 1; i >= 0; i--)
     266            memset(scan_line(i), color, m_size.x);
     267    add_dirty(0, 0, m_size.x - 1, m_size.y - 1);
    267268    unlock();
    268269}
     
    270271image *image::copy()
    271272{
    272     image *im;
    273     uint8_t *c, *dat;
    274     int i;
    275 
    276273    lock();
    277     dat = (uint8_t *)malloc(size.x);
    278     im = new image(size.x, size.y);
     274    image *im = new image(m_size);
    279275    im->lock();
    280     for(i = size.y - 1; i >= 0; i--)
    281     {
    282         c = scan_line(i);
    283         memcpy(dat, c, size.x);
    284         c = im->scan_line(i);
    285         memcpy(c, dat, size.x);
    286     }
     276    for(int i = m_size.y - 1; i >= 0; i--)
     277        memcpy(im->scan_line(i), scan_line(i), m_size.x);
    287278    im->unlock();
    288279    unlock();
    289     free((char *)dat);
    290280    return im;
    291281}
     
    443433    if(screen->special)
    444434    {
    445         put_part(screen, x, y, 0, 0, size.x-1, size.y-1, transparent);
     435        put_part(screen, x, y, 0, 0, m_size.x-1, m_size.y-1, transparent);
    446436        return;
    447437    }
     
    449439    if(x < screen->Size().x && y < screen->Size().y)
    450440    {
    451         xl = size.x;
     441        xl = m_size.x;
    452442        if(x + xl > screen->Size().x) // clip to the border of the screen
    453443            xl = screen->Size().x - x;
    454         yl = size.y;
     444        yl = m_size.y;
    455445        if(y + yl > screen->Size().y)
    456446            yl = screen->Size().y - y;
     
    517507    return ;
    518508  screen->add_dirty(x1, y1, x2, y2);
    519   w=size.x;
     509  w=m_size.x;
    520510  if (align)
    521511  {
    522512    start=x1%w;
    523     starty=y1%size.y;
     513    starty=y1%m_size.y;
    524514  }
    525515  else
     
    533523    pg1=screen->scan_line(j);
    534524    pg2=scan_line(starty++);
    535     if (starty>=size.y) starty=0;
     525    if (starty>=m_size.y) starty=0;
    536526    i=x1;
    537527    xx=start;
     
    565555  if (x1<0) { x+=-x1; x1=0; }
    566556  if (y1<0) { y+=-y1; y1=0; }
    567   if (x2>=size.x) x2=size.x-1;
    568   if (y2>=size.y) y2=size.y-1;
     557  if (x2>=m_size.x) x2=m_size.x-1;
     558  if (y2>=m_size.y) y2=m_size.y-1;
    569559  if (x1>x2 || y1>y2) return ;      // return if it was adjusted so that nothing will be put
    570560
     
    628618  CHECK(x1<=x2 && y1<=y2);
    629619
    630   i=x1; x1=size.x-x2-1;  // reverse the x locations
    631   x2=size.x-i-1;
     620  i=x1; x1=m_size.x-x2-1;  // reverse the x locations
     621  x2=m_size.x-i-1;
    632622
    633623  if (x1<0)
     
    652642    return ;
    653643
    654   if (x<screen->Size().x && y<screen->Size().y && x1<size.x && y1<size.y &&
     644  if (x<screen->Size().x && y<screen->Size().y && x1<m_size.x && y1<m_size.y &&
    655645      x1<=x2 && y1<=y2)
    656646  {
    657     if (x2>=size.x)
    658       x2=size.x-1;
    659     if (y2>=size.y)
    660       y2=size.y-1;
     647    if (x2>=m_size.x)
     648      x2=m_size.x-1;
     649    if (y2>=m_size.y)
     650      y2=m_size.y-1;
    661651    xl=x2-x1+1;
    662652    if (x+xl>screen->Size().x)
     
    714704  ml=mask->Size().x;
    715705  mh=mask->Size().y;
    716   if (x<screen->Size().x && y<screen->Size().y && x1<size.x && y1<size.y &&
     706  if (x<screen->Size().x && y<screen->Size().y && x1<m_size.x && y1<m_size.y &&
    717707      maskx<ml && masky<mh && x1<=x2 && y1<=y2)
    718708  {
    719709
    720     if (x2>=size.x)
    721       x2=size.x-1;
    722     if (y2>=size.y)
    723       y2=size.y-1;
     710    if (x2>=m_size.x)
     711      x2=m_size.x-1;
     712    if (y2>=m_size.y)
     713      y2=m_size.y-1;
    724714    xl=x2-x1+1;
    725715    if (x+xl>screen->Size().x)
     
    761751  brv=0; bri=0;
    762752  lock();
    763   for (j=0; j<size.y; j++)
     753  for (j=0; j<m_size.y; j++)
    764754  {
    765755    p=scan_line(j);
    766     for (i=0; i<size.x; i++)
     756    for (i=0; i<m_size.x; i++)
    767757    { pal->get(p[i], r, g, b);
    768758      if ((int32_t)r*(int32_t)g*(int32_t)b>brv)
     
    782772  brv=(int32_t)258*(int32_t)258*(int32_t)258; bri=0;
    783773  lock();
    784   for (j=0; j<size.y; j++)
     774  for (j=0; j<m_size.y; j++)
    785775  {
    786776    p=scan_line(j);
    787     for (i=0; i<size.x; i++)
     777    for (i=0; i<m_size.x; i++)
    788778    { pal->get(p[i], r, g, b);
    789779      x=(int32_t)r*(int32_t)g*(int32_t)b;
     
    811801    // with no dirty rectangle keeping.
    812802    if(!special)
    813         special = new image_descriptor(size.x, size.y, 0);
     803        special = new image_descriptor(m_size.x, m_size.y, 0);
    814804
    815805    // set the image descriptor what the clip
     
    823813    special->get_clip(x1, y1, x2, y2);
    824814  else
    825   { x1=0; y1=0; x2=size.x-1; y2=size.y-1; }
     815  { x1=0; y1=0; x2=m_size.x-1; y2=m_size.y-1; }
    826816}
    827817
     
    10561046  { if (x1<0) x1=0;
    10571047    if (y1<0) y1=0;
    1058     if (x2>=size.x)  x2=size.x-1;
    1059     if (y2>=size.y) y2=size.y-1;
    1060   }
    1061   if (x2<0 || y2<0 || x1>=size.x || y1>=size.y || x2<x1 || y2<y1)
     1048    if (x2>=m_size.x)  x2=m_size.x-1;
     1049    if (y2>=m_size.y) y2=m_size.y-1;
     1050  }
     1051  if (x2<0 || y2<0 || x1>=m_size.x || y1>=m_size.y || x2<x1 || y2<y1)
    10621052    return ;
    10631053  lock();
     
    10811071  { if (x1<0) x1=0;
    10821072    if (y1<0) y1=0;
    1083     if (x2>=size.x)  x2=size.x-1;
    1084     if (y2>=size.y) y2=size.y-1;
    1085   }
    1086   if (x2<0 || y2<0 || x1>=size.x || y1>=size.y || x2<x1 || y2<y1)
     1073    if (x2>=m_size.x)  x2=m_size.x-1;
     1074    if (y2>=m_size.y) y2=m_size.y-1;
     1075  }
     1076  if (x2<0 || y2<0 || x1>=m_size.x || y1>=m_size.y || x2<x1 || y2<y1)
    10871077    return ;
    10881078
     
    10941084    for (x=x1; x<=x2; x++, s++)
    10951085      *s=(*s)^color;
    1096     sl+=size.x;
     1086    sl+=m_size.x;
    10971087  }
    10981088  unlock();
     
    11061096  int16_t x;
    11071097  uint8_t *sl, *ex, mask, bt, sh;
    1108   ex=(uint8_t *)malloc(size.x);
     1098  ex=(uint8_t *)malloc(m_size.x);
    11091099
    11101100  lock();
    11111101  sl=scan_line(line);
    1112   memcpy(ex, sl, size.x);
     1102  memcpy(ex, sl, m_size.x);
    11131103  unlock();
    11141104
     
    11171107  else                 {  mask=128+64+32+16; bt=2; }
    11181108
    1119   for (x=0; x<size.x; x++)
     1109  for (x=0; x<m_size.x; x++)
    11201110  { sh=((x%bt)<<(bitsperpixel-1));
    11211111    sl[x]=(ex[x/bt]&(mask>>sh))>>(bt-sh-1);
     
    11351125  uint8_t *sl;
    11361126  lock();
    1137   for (y=size.y-1; y>=0; y--)
     1127  for (y=m_size.y-1; y>=0; y--)
    11381128  {
    11391129    sl=scan_line(y);
    1140     for (i=0, j=y%4, x=size.x-1; x>=0; x--)
     1130    for (i=0, j=y%4, x=m_size.x-1; x>=0; x--)
    11411131    {
    11421132      if (pal->red(sl[x])>dt_matrix[j*4+i])
     
    11601150}
    11611151
    1162 void image::resize(int16_t new_width, int16_t new_height)
    1163 {
    1164   int old_width=size.x, old_height=size.y;
    1165   uint8_t *im=(uint8_t *)malloc(size.x*size.y);
    1166   lock();
    1167   memcpy(im, scan_line(0), size.x*size.y);
    1168 
    1169   delete_page();
    1170   make_page(new_width, new_height, NULL);
    1171   size = vec2i(new_width, new_height); // set the new height and width
    1172 
    1173   uint8_t *sl1, *sl2;
    1174   int16_t y, y2, x2;
    1175   double yc, xc, yd, xd;
    1176 
    1177 
    1178 
    1179   yc=(double)old_height/(double)new_height;
    1180   xc=(double)old_width/(double)new_width;
    1181   for (y2=0, yd=0; y2<new_height; yd+=yc, y2++)
    1182   {
    1183     y=(int)yd;
    1184     sl1=im+y*old_width;
    1185     sl2=scan_line(y2);
    1186     for (xd=0, x2=0; x2<new_width; xd+=xc, x2++)
    1187     { sl2[x2]=sl1[(int)xd]; }
    1188   }
    1189   free(im);
    1190   if (special) special->resize(new_width, new_height);
    1191   unlock();
     1152void image::Scale(vec2i new_size)
     1153{
     1154    vec2i old_size = m_size;
     1155    uint8_t *im = (uint8_t *)malloc(old_size.x * old_size.y);
     1156    lock();
     1157    memcpy(im, scan_line(0), old_size.x * old_size.y);
     1158
     1159    delete_page();
     1160    make_page(new_size, NULL);
     1161    m_size = new_size; // set the new height and width
     1162
     1163    uint8_t *sl1, *sl2;
     1164    int y, y2, x2;
     1165    double yc, xc, yd, xd;
     1166
     1167    yc = (double)old_size.y / (double)new_size.y;
     1168    xc = (double)old_size.x / (double)new_size.x;
     1169    for (y2 = 0, yd = 0; y2 < new_size.y; yd += yc, y2++)
     1170    {
     1171        y = (int)yd;
     1172        sl1 = im + y * old_size.x;
     1173        sl2 = scan_line(y2);
     1174        for (xd = 0, x2 = 0; x2 < new_size.x; xd += xc, x2++)
     1175            sl2[x2] = sl1[(int)xd];
     1176    }
     1177    free(im);
     1178    if (special)
     1179        special->resize(new_size.x, new_size.y);
     1180    unlock();
    11921181}
    11931182
     
    11951184{
    11961185  int16_t cx1, cy1, cx2, cy2;
    1197   CHECK(x1>=0 && y1>=0 && x1<x2 && y1<y2 && x2<size.x && y2<size.y);
     1186  CHECK(x1>=0 && y1>=0 && x1<x2 && y1<y2 && x2<m_size.x && y2<m_size.y);
    11981187  if (special)
    11991188  {
     
    12271216  d=smoothness*2+1;
    12281217  d=d*d;
    1229   im=new image(size.x, size.y);
    1230   for (i=0; i<size.x; i++)
    1231     for (j=0; j<size.y; j++)
     1218  im=new image(m_size);
     1219  for (i=0; i<m_size.x; i++)
     1220    for (j=0; j<m_size.y; j++)
    12321221    {
    12331222      for (t=0, k=-smoothness; k<=smoothness; k++)
    12341223    for (l=-smoothness; l<=smoothness; l++)
    1235       if (i+k>smoothness && i+k<size.x-smoothness && j+l<size.y-smoothness && j+l>smoothness)
     1224      if (i+k>smoothness && i+k<m_size.x-smoothness && j+l<m_size.y-smoothness && j+l>smoothness)
    12361225        t+=pixel(i+k, j+l);
    12371226      else t+=pixel(i, j);
     
    12901279        }
    12911280      }
    1292       if (y<size.y-1)
     1281      if (y<m_size.y-1)
    12931282      {
    12941283        above=scan_line(y+1);
     
    13111300          }
    13121301        }
    1313         if (y<size.y-1)
     1302        if (y<m_size.y-1)
    13141303        { below=scan_line(y+1);
    13151304          if (x>0 && below[x-1]!=fcolor && below[x]==fcolor)
     
    13191308        }
    13201309        x++;
    1321       } while (sl[x]==fcolor && x<size.x);
     1310      } while (sl[x]==fcolor && x<m_size.x);
    13221311      x--;
    13231312      if (y>0)
     
    13291318        }
    13301319      }
    1331       if (y<size.y-1)
     1320      if (y<m_size.y-1)
    13321321      {
    13331322        above=scan_line(y+1);
     
    13891378  CHECK(x2>=x1 && y2>=y1);
    13901379  if (x2<x1 || y2<y1) return NULL;
    1391   ret=new image((x2-x1+8)/8, (y2-y1+1));
     1380  ret=new image(vec2i((x2-x1+8)/8, (y2-y1+1)));
    13921381  if (!last_loaded())
    13931382    ret->clear();
     
    14241413void image::flip_x()
    14251414{
    1426   uint8_t *rev=(uint8_t *)malloc(size.x), *sl;
     1415  uint8_t *rev=(uint8_t *)malloc(m_size.x), *sl;
    14271416  CONDITION(rev, "memory allocation");
    14281417  int y, x, i;
     
    14301419  /* FIXME: Abuse Win32 uses RestoreSurface() here instead of locking */
    14311420  lock();
    1432   for (y=0; y<size.y; y++)
     1421  for (y=0; y<m_size.y; y++)
    14331422  { sl=scan_line(y);
    1434     for (i=0, x=size.x-1; x>=0; x--, i++)
     1423    for (i=0, x=m_size.x-1; x>=0; x--, i++)
    14351424      rev[i]=sl[x];
    1436     memcpy(sl, rev, size.x);
     1425    memcpy(sl, rev, m_size.x);
    14371426  }
    14381427  unlock();
     
    14421431void image::flip_y()
    14431432{
    1444   uint8_t *rev=(uint8_t *)malloc(size.x), *sl;
     1433  uint8_t *rev=(uint8_t *)malloc(m_size.x), *sl;
    14451434  CONDITION(rev, "memory allocation");
    14461435  int y;
     
    14481437  /* FIXME: Abuse Win32 uses RestoreSurface() here instead of locking */
    14491438  lock();
    1450   for (y=0; y<size.y/2; y++)
     1439  for (y=0; y<m_size.y/2; y++)
    14511440  { sl=scan_line(y);
    1452     memcpy(rev, sl, size.x);
    1453     memcpy(sl, scan_line(size.y-y-1), size.x);
    1454     memcpy(scan_line(size.y-y-1), rev, size.x);
     1441    memcpy(rev, sl, m_size.x);
     1442    memcpy(sl, scan_line(m_size.y-y-1), m_size.x);
     1443    memcpy(scan_line(m_size.y-y-1), rev, m_size.x);
    14551444  }
    14561445  unlock();
     
    14631452  int y, x;
    14641453  lock();
    1465   for (y=0; y<size.y; y++)
     1454  for (y=0; y<m_size.y; y++)
    14661455  {
    14671456    sl=scan_line(y);
    1468     for (x=size.x; x; x--, sl++)
     1457    for (x=m_size.x; x; x--, sl++)
    14691458      if (*sl)
    14701459        *sl=color;
  • abuse/trunk/src/imlib/image.h

    r512 r513  
    7575    void *extended_descriptor;
    7676
    77     image_descriptor(int16_t length, int16_t height,
    78                      int keep_dirties = 1, int static_memory = 0);
     77    image_descriptor(vec2i size, int keep_dirties = 1, int static_memory = 0);
    7978    int16_t bound_x1(int16_t x1)  { return x1 < clipx1 ? clipx1 : x1; }
    8079    int16_t bound_y1(int16_t y1)  { return y1 < clipy1 ? clipy1 : y1; }
     
    118117{
    119118private:
    120     uint8_t *data;
    121     vec2i size;
    122     void make_page(int16_t width, int16_t height, uint8_t *page_buffer);
     119    uint8_t *m_data;
     120    vec2i m_size;
     121
     122    void make_page(vec2i size, uint8_t *page_buffer);
    123123    void delete_page();
    124     bool _locked;
     124    bool m_locked;
    125125
    126126public:
     
    129129    image(spec_entry *e, bFILE *fp);
    130130    image(bFILE *fp);
    131     image(int16_t width, int16_t height,
    132           uint8_t *page_buffer = NULL, int16_t create_descriptor = 0);
     131    image(vec2i size, uint8_t *page_buffer = NULL, int create_descriptor = 0);
    133132    ~image();
    134133
     
    140139    uint8_t *scan_line(int16_t y)
    141140    {
    142         return data + y * size.x;
     141        return m_data + y * m_size.x;
    143142    }
    144143    uint8_t *next_line(int16_t lasty, uint8_t *last_scan)
    145144    {
    146         return last_scan + size.x;
     145        return last_scan + m_size.x;
    147146    }
    148147    int32_t total_pixels(uint8_t background=0);
     
    151150    void to_24bit(palette &pal);
    152151
    153     vec2i Size() const { return size; }
    154     int Pitch() const { return size.x; } // FIXME: for now, pitch == width
     152    vec2i Size() const { return m_size; }
    155153
    156154    void scroll(int16_t x1, int16_t y1, int16_t x2, int16_t y2,
     
    203201    }
    204202    void dither(palette *pal); // use a b&w palette!
    205     void resize(int16_t new_width, int16_t new_height);
    206     void change_size(int16_t new_width, int16_t new_height,
    207                      uint8_t *page = NULL);
     203    void Scale(vec2i size);
     204    void SetSize(vec2i size, uint8_t *page = NULL);
    208205    void flood_fill(int16_t x, int16_t y, uint8_t color);
    209206    image *create_smooth(int16_t smoothness = 1); // 0 no smoothness
  • abuse/trunk/src/imlib/jwindow.cpp

    r512 r513  
    223223void Jwindow::resize(int L, int H)
    224224{
    225   screen->change_size(L,H);
     225  screen->SetSize(vec2i(L,H));
    226226  l=L; h=H;
    227227}
     
    435435        if(h < top_border() + bottom_border())
    436436            h = top_border() + bottom_border();
    437     screen = new image(l, h, NULL, 2);
     437    screen = new image(vec2i(l, h), NULL, 2);
    438438    screen->clear(backg);
    439439    // Keep this from getting destroyed when image list is cleared
  • abuse/trunk/src/imlib/sprite.cpp

    r512 r513  
    3939  CHECK(Visual && Screen);
    4040  x=X; y=Y; visual=Visual; screen=Screen;
    41   save=new image(visual->Size().x,visual->Size().y);
     41  save = new image(visual->Size());
    4242  get_background();
    43 } ;
     43}
    4444
    4545sprite::~sprite()
     
    6464    delete visual;
    6565  visual=Visual;
    66   if (save->Size().x!=Visual->Size().x || save->Size().y!=Visual->Size().y)
     66  if (save->Size() != Visual->Size())
    6767  {
    6868    delete save;
    69     save=new image(visual->Size().x,visual->Size().y);
     69    save = new image(visual->Size());
    7070  }
    7171  get_background();
  • abuse/trunk/src/imlib/timage.cpp

    r512 r513  
    3838image *trans_image::make_image()
    3939{
    40   image *im=new image(w,h);
     40  image *im=new image(vec2i(w,h));
    4141
    4242  im->lock();
  • abuse/trunk/src/items.cpp

    r512 r513  
    252252    }
    253253  }
    254   micro_image=new image(AUTOTILE_WIDTH,AUTOTILE_HEIGHT);
     254  micro_image = new image(vec2i(AUTOTILE_WIDTH, AUTOTILE_HEIGHT));
    255255
    256256  for (l=0; l<AUTOTILE_WIDTH*AUTOTILE_HEIGHT; l++)
  • abuse/trunk/src/level.cpp

    r512 r513  
    16431643void level::write_thumb_nail(bFILE *fp, image *im)
    16441644{
    1645   image *i=new image(160,100+wm->font()->height()*2);
     1645  image *i = new image(vec2i(160, 100 + wm->font()->height() * 2));
    16461646  i->clear();
    16471647  scale_put(im,i,0,0,160,100);
  • abuse/trunk/src/loader2.cpp

    r512 r513  
    7575image *load_image(spec_entry *e, bFILE *fp)
    7676{
    77   image *im=new image(e,fp);
    78   if (scale_mult!=1 || scale_div!=1)
    79     im->resize(im->Size().x*scale_mult/scale_div,im->Size().y*scale_mult/scale_div);
    80   return im;
     77    image *im = new image(e, fp);
     78    if (scale_mult != 1 || scale_div != 1)
     79        im->Scale(im->Size() * scale_mult / scale_div);
     80    return im;
    8181}
    8282
    8383image *load_image(bFILE *fp)
    8484{
    85   image *im=new image(fp);
    86   if (scale_mult!=1 || scale_div!=1)
    87     im->resize(im->Size().x*scale_mult/scale_div,im->Size().y*scale_mult/scale_div);
    88 
    89   return im;
     85    image *im = new image(fp);
     86    if (scale_mult != 1 || scale_div != 1)
     87        im->Scale(im->Size() * scale_mult / scale_div);
     88    return im;
    9089}
    9190
     
    364363
    365364
    366   image *tmp_image=new image(192,104,fnt6x13);
     365  image *tmp_image = new image(vec2i(192, 104), fnt6x13);
    367366  big_font=new JCFont(tmp_image);
    368367  delete tmp_image;
  • abuse/trunk/src/loadgame.cpp

    r512 r513  
    191191        if (fail && show_all)
    192192        {
    193             thumb_nails[start_num]=new image(160,100);
     193            thumb_nails[start_num] = new image(vec2i(160, 100));
    194194            thumb_nails[start_num]->clear();
    195195            console_font->put_string(thumb_nails[start_num],0,0,symbol_str("no_saved"));
  • abuse/trunk/src/menu.cpp

    r512 r513  
    178178  int choice=0,done=0;
    179179  int bh=font->height()+3;
    180   image *save=new image(mw-2,bh);
     180  image *save = new image(vec2i(mw - 2,bh));
    181181  int color=128,cdir=50;
    182182
     
    394394  if (DEFINEDP(ss->GetValue()))
    395395  {
    396     image blank(2,2); blank.clear();
     396    image blank(vec2i(2, 2)); blank.clear();
    397397    wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
    398398
  • abuse/trunk/src/sdlport/mouse.cpp

    r512 r513  
    6363    f.set( 1, br );
    6464    f.set( 2, dr );
    65     im = new image( 8, 10, def_mouse );
     65    im = new image(vec2i(8, 10), def_mouse);
    6666    f.apply( im );
    67     sp = new sprite( Screen, im, 100, 100 );
     67    sp = new sprite(Screen, im, 100, 100);
    6868    mx = Screen->Size().x / 2;
    6969    my = Screen->Size().y / 2;
  • abuse/trunk/src/sdlport/video.cpp

    r512 r513  
    126126
    127127    // Create the screen image
    128     screen = new image(xres, yres, NULL, 2);
     128    screen = new image(vec2i(xres, yres), NULL, 2);
    129129    if(screen == NULL)
    130130    {
     
    392392// make_page()
    393393//
    394 void image::make_page(short width, short height, unsigned char *page_buffer)
    395 {
    396     if(page_buffer)
    397         data = page_buffer;
     394void image::make_page(vec2i size, uint8_t *page_buffer)
     395{
     396    if (page_buffer)
     397        m_data = page_buffer;
    398398    else
    399         data = (unsigned char *)malloc(width * height);
     399        m_data = (uint8_t *)malloc(size.x * size.y);
    400400}
    401401
     
    406406{
    407407    if(!special || !special->static_mem)
    408         free(data);
     408        free(m_data);
    409409}
    410410
  • abuse/trunk/src/ui/volumewindow.cpp

    r512 r513  
    4242    l = cache.img(bg)->Size().x;
    4343    h = cache.img(bg)->Size().y;
    44     screen = new image(l, h, NULL, 2);
     44    screen = new image(cache.img(bg)->Size(), NULL, 2);
    4545    redraw();
    4646}
  • abuse/trunk/src/view.cpp

    r512 r513  
    502502      if (small_render)
    503503      {
    504     small_render->resize(cx2-cx1+1,cy2-cy1+1);
     504        small_render->Scale(vec2i(cx2 - cx1 + 1, cy2 - cy1 + 1));
    505505      }
    506506
Note: See TracChangeset for help on using the changeset viewer.