MCPcopy Create free account
hub / github.com/davisking/dlib / fill

Method fill

dlib/gui_core/gui_core_kernel_1.cpp:1554–1597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1552// ----------------------------------------------------------------------------------------
1553
1554 void canvas::
1555 fill (
1556 unsigned char red_,
1557 unsigned char green_,
1558 unsigned char blue_
1559 ) const
1560 {
1561 const unsigned long red = red_;
1562 const unsigned long green = green_;
1563 const unsigned long blue = blue_;
1564
1565 const LONG block1 = (blue<<24) | (red<<16) | (green<<8) | blue;
1566 const LONG block2 = (green<<24) | (blue<<16) | (red<<8) | green;
1567 const LONG block3 = (red<<24) | (green<<16) | (blue<<8) | red;
1568
1569 // remember that row_width is a multiple of 4 because windows
1570 // requires that all bitmaps have row widths that are multiples of 4.
1571 unsigned long size = row_width/4;
1572 for (unsigned long i = 0; i < height_; ++i)
1573 {
1574 unsigned long padding = size%3;
1575 LONG* start = reinterpret_cast<LONG*>(bits+row_width*i);
1576 LONG* end = reinterpret_cast<LONG*>(start) + size - padding;
1577 while (start != end)
1578 {
1579 *start = block1;
1580 ++start;
1581 *start = block2;
1582 ++start;
1583 *start = block3;
1584 ++start;
1585 }
1586 if (padding)
1587 {
1588 *start = block1;
1589 ++start;
1590 --padding;
1591 }
1592 if (padding)
1593 {
1594 *start = block2;
1595 }
1596 }
1597 }
1598
1599// ----------------------------------------------------------------------------------------
1600

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected