void RGBImg::OutlineBox( RGBx c, Box& b ) { b.ClipAgainst( Bounds() ); // draw top & bottom int x; RGBx* ptop = Ptr(b.XMin(),b.YMin()); RGBx* pbot = Ptr(b.XMin(),b.YMax()); for( x=b.XMin(); x<=b.XMax(); ++x ) { *ptop++ = c; *pbot++ = c; } // draw sides (note: already draw top & bottom pixels) RGBx* pleft = Ptr(b.XMin(),b.YMin()+1); RGBx* pright = Ptr(b.XMax(),b.YMin()+1); int y; for( y=b.YMin()+1; y<=b.YMax()-1; ++y ) { *pleft = c; pleft += W(); *pright = c; pright += W(); } }
void IndexedImg::FillBox( uint8_t c, Box& b ) { b.ClipAgainst( Bounds() ); int y; for( y=b.YMin(); y<=b.YMax(); ++y ) { int x; uint8_t* dest = Ptr(b.XMin(),y); for( x=b.XMin(); x<=b.XMax(); ++x ) { *dest++ = c; } } }
void RGBImg::FillBox( RGBx c, Box& b ) { b.ClipAgainst( Bounds() ); int y; for( y=b.YMin(); y<=b.YMax(); ++y ) { int x; RGBx* dest = Ptr(b.XMin(),y); for( x=b.XMin(); x<=b.XMax(); ++x ) { *dest++ = c; } } }
// clips a blit against the destination boundary. // assumes srcbox is already valid. // modifies srcbox and destbox appropriately. static void clip_blit( Box const& srcbounds, Box& srcbox, Box const& destbounds, Box& destbox, int zoom=1 ) { // srcbox has blit dimensions destbox.w = srcbox.w*zoom; destbox.h = srcbox.h*zoom; // clip destbox, then adjust srcbox to take into account any // modifications int destx = destbox.x; int desty = destbox.y; destbox.ClipAgainst( destbounds ); srcbox.x += (destbox.x - destx)/zoom; srcbox.y += (destbox.y - desty)/zoom; srcbox.w = destbox.w/zoom; srcbox.h = destbox.h/zoom; }