@@ -1609,6 +1609,62 @@ void bbepEllipse(FASTEPDSTATE *pBBEP, int iCenterX, int iCenterY, int32_t iRadiu
1609
1609
}
1610
1610
}
1611
1611
} /* bbepEllipse() */
1612
+
1613
+ //
1614
+ // Invert a rectangle of pixels
1615
+ //
1616
+ void bbepInvertRect (FASTEPDSTATE *pBBEP, int x, int y, int w, int h)
1617
+ {
1618
+ int tx, ty;
1619
+ uint8_t u8 , u8Mask, *s;
1620
+ int iPitch;
1621
+
1622
+ if (pBBEP == NULL ) return ;
1623
+ if (x < 0 || y < 0 || w < 0 || h < 0 ||
1624
+ x >= pBBEP->width || y >= pBBEP->height || (x+w) > pBBEP->width || (y+h) > pBBEP->height ) {
1625
+ pBBEP->last_error = BBEP_ERROR_BAD_PARAMETER;
1626
+ return ; // invalid coordinates
1627
+ }
1628
+
1629
+ if (pBBEP->mode == BB_MODE_1BPP) {
1630
+ iPitch = pBBEP->width / 8 ;
1631
+ for (ty=y; ty<y+h; ty++) {
1632
+ s = pBBEP->pCurrent ;
1633
+ s += (ty * iPitch) + (x >> 3 );
1634
+ u8Mask = 0x80 >> (x & 7 );
1635
+ u8 = s[0 ]; // read current pixels
1636
+ for (tx=0 ; tx<w; tx++) {
1637
+ u8 ^= u8Mask;
1638
+ u8Mask >>= 1 ;
1639
+ if (u8Mask == 0 ) { // next byte
1640
+ *s++ = u8 ;
1641
+ u8 = s[0 ];
1642
+ u8Mask = 0x80 ;
1643
+ }
1644
+ } // for tx
1645
+ if (u8Mask != 0x80 ) { // write final partial byte
1646
+ s[0 ] = u8 ;
1647
+ }
1648
+ } // for ty
1649
+ } else { // 4-bpp
1650
+ iPitch = pBBEP->width / 2 ;
1651
+ for (ty = y; ty < y+h; ty++) {
1652
+ s = pBBEP->pCurrent ;
1653
+ s += (ty * iPitch) + (x >> 1 );
1654
+ u8Mask = 0xf0 >> ((x & 1 )*4 );
1655
+ u8 = s[0 ];
1656
+ for (tx=0 ; tx<w; tx++) {
1657
+ u8 ^= u8Mask;
1658
+ u8Mask = ~u8Mask;
1659
+ if (u8Mask == 0xf0 ) { // next byte
1660
+ *s++ = u8 ;
1661
+ u8 = s[0 ];
1662
+ }
1663
+ } // for tx
1664
+ } // for ty
1665
+ }
1666
+ } /* bbepInvertRect() */
1667
+
1612
1668
//
1613
1669
// Draw an outline or filled rectangle
1614
1670
//
0 commit comments