Changeset 667
- Timestamp:
- May 16, 2011, 2:37:15 AM (11 years ago)
- Location:
- abuse/trunk/src/imlib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/fonts.cpp
r662 r667 19 19 #include "fonts.h" 20 20 21 texture_font::texture_font(image *letters, image *font_pattern)22 { fntpat=font_pattern;23 let=letters;24 tl=(let->Size().x+1)/32;25 th=(let->Size().y+1)/8;26 }27 28 void texture_font::put_char(image *screen, int x, int y, char ch)29 { if (fntpat)30 screen->PutPartMasked(fntpat, vec2i(x, y), let,31 vec2i(((int)ch%32)*tl,((int)ch/32)*th), vec2i(0,0), vec2i(tl,th));32 else screen->PutPart(let, vec2i(x, y), vec2i(((int)ch%32)*tl, ((int)ch/32)*th),33 vec2i(((int)ch%32)*tl+tl, ((int)ch/32)*th+th), 1);34 }35 36 void texture_font::put_string(image *screen, int x, int y, char const *st)37 { while (*st)38 { put_char(screen,x,y,*st);39 st++;40 x+=tl;41 }42 }43 44 45 21 void JCFont::put_string(image *screen, int x, int y, char const *st, int color) 46 22 { while (*st) … … 50 26 } 51 27 } 52 53 28 54 29 void JCFont::put_char(image *screen, int x, int y, char ch, int color) -
abuse/trunk/src/imlib/fonts.h
r555 r667 11 11 #ifndef __FONTS_HPP_ 12 12 #define __FONTS_HPP_ 13 13 14 #include "image.h" 14 15 #include "transimage.h" 15 16 17 18 class texture_font19 {20 int tl,th;21 image *let,*fntpat;22 public:23 texture_font(image *letters, image *font_pattern=NULL);24 void put_char(image *screen, int x, int y, char ch);25 void put_string(image *screen, int x, int y, char const *st);26 int height() { return th; }27 int length() { return tl; }28 int width() { return tl; }29 image *font_image() { return let; }30 image *font_patter() { return fntpat; }31 ~texture_font() { if (let) delete let; if (fntpat) delete fntpat; }32 } ;33 16 34 17 class JCFont -
abuse/trunk/src/imlib/image.cpp
r665 r667 371 371 372 372 im->Unlock(); 373 Unlock();374 }375 376 void image::PutPartMasked(image *im, vec2i pos, image *mask, vec2i mpos,377 vec2i aa, vec2i bb)378 {379 CHECK(aa < bb);380 381 if (m_special)382 {383 vec2i caa, cbb;384 m_special->GetClip(caa, cbb);385 386 if (!(pos < cbb && pos > aa - bb))387 return;388 389 aa += Max(caa - pos, vec2i(0));390 pos += Max(caa - pos, vec2i(0));391 bb = Min(bb, cbb - pos + aa);392 }393 else if (!(pos <= m_size && pos >= -aa))394 return;395 396 vec2i mask_size = mask->Size();397 398 if (!(pos < m_size && aa < im->m_size && mpos < mask_size && aa < bb))399 return;400 401 bb = Min(bb, im->m_size);402 403 vec2i span = bb - aa;404 span = Min(span, m_size - pos);405 AddDirty(pos.x, pos.y, pos.x + span.x, pos.y + span.y);406 407 Lock();408 mask->Lock();409 im->Lock();410 411 for (int j = 0; j < span.y; j++)412 {413 uint8_t *dst = scan_line(pos.y + j) + pos.x;414 uint8_t *src = im->scan_line(aa.y + j) + aa.x;415 uint8_t *pg3 = mask->scan_line(mpos.y) + mpos.x;416 417 if (++mpos.y >= mask_size.y) // wrap mask y around418 mpos.y = 0;419 420 for (int i = 0; i < span.x; i++, dst++, src++, pg3++)421 {422 if (mpos.x + i >= mask_size.x) // wrap mask x around423 pg3 -= mask_size.x;424 425 if (pg3[mpos.x + i]) // check to make sure not 0 before putting426 *dst = *src;427 }428 }429 430 im->Unlock();431 mask->Unlock();432 373 Unlock(); 433 374 } -
abuse/trunk/src/imlib/image.h
r665 r667 125 125 void PutPart(image *screen, vec2i pos, vec2i aa, vec2i bb, 126 126 int transparent = 0); 127 void PutPartMasked(image *screen, vec2i pos, image *mask, vec2i mpos,128 vec2i aa, vec2i bb);129 127 image *copy_part_dithered(int16_t x1, int16_t y1, int16_t x2, int16_t y2); 130 128 void Bar(vec2i p1, vec2i p2, uint8_t color);
Note: See TracChangeset
for help on using the changeset viewer.