1: /*
     2:  ============================================================================
     3:  xoblite™ -> an advanced "extended shell" for Microsoft® Windows® 11
     4:  Copyright © 2002-2026 Karl Henrik Henriksson [qwilk/@xoblite]
     5:  Copyright © 2001-2004 The Blackbox for Windows Development Team
     6:  http://xoblite.net/ + https://github.com/xoblite/
     7:  ============================================================================
     8: 
     9:   Blackbox for Windows is free software, released under the
    10:   GNU General Public License (GPL version 2 or later), with an extension
    11:   that allows linking of proprietary modules under a controlled interface.
    12:   What this means is that plugins etc. are allowed to be released
    13:   under any license the author wishes. Please note, however, that the
    14:   original Blackbox gradient math code used in Blackbox for Windows
    15:   is available under the BSD license.
    16: 
    17:   http://www.fsf.org/licenses/gpl.html
    18:   http://www.fsf.org/licenses/gpl-faq.html#LinkingOverControlledInterface
    19:   http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
    20: 
    21:   This program is distributed in the hope that it will be useful,
    22:   but WITHOUT ANY WARRANTY; without even the implied warranty of
    23:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    24:   GNU General Public License for more details.
    25: 
    26:   For additional license information, please read the included license.html.
    27: 
    28:  ============================================================================
    29: */
    30: 
    31: #ifndef __BIMAGE_H 
    32: #define __BIMAGE_H 
    33: 
    34: #include "..\API\BBApi.h" 
    35: 
    36: //===========================================================================
    37: 
    38: class BImage
    39: {
    40: public:
    41:     BImage();
    42:     ~BImage();
    43: 
    44:     void DrawBorder(HDC hdc, RECT rect, COLORREF borderColour, int borderWidth);
    45:     void DrawGradient(HDC hdc, RECT rect, int type, COLORREF color1, COLORREF color2, COLORREF color3, COLORREF color4, COLORREF color5, COLORREF color6, COLORREF color7, COLORREF color8, bool bInterlaced, int bevelStyle, int bevelPosition, int bevelWidth);
    46: 
    47:     void DrawGlyph(HDC hdc, RECT r, int glyph, COLORREF glyphColor);
    48: 
    49:     void AlphaRect(HDC hdc, RECT rect, unsigned char alpha);
    50:     void AlphaBorder(HDC hdc, RECT rect, unsigned char alpha, int borderWidth);
    51:     void AlphaCorner(HDC hdc, RECT rect, int corner, int borderWidth, unsigned char minAlpha, unsigned char maxAlpha);
    52:     void AlphaFromRGB(HDC hdc, RECT rect, unsigned char minAlpha, unsigned char maxAlpha, bool recolor, COLORREF color);
    53:     void AlphaMask(HDC destHdc, RECT destRect, HDC srcHdc, RECT srcRect, bool useSrcRGBAsAlpha);
    54:     void AlphaApply(HDC hdc, RECT rect); // AlphaApplyToRGB?
    55: 
    56:     void PrepareCorner(HDC hdc, RECT rect, int corner, int bevelStyle, int bevelPosition, int bevelWidth, int borderWidth);
    57: 
    58:     //====================
    59: 
    60: private:
    61: 
    62:     void CreateBuffer(HDC hdc, RECT rect, bool createTables);
    63:     void DestroyBuffer();
    64: 
    65:     bool CheckRemainder(int divider, int remainder, int i);
    66: 
    67:     void PaintGradient(int type, COLORREF colorFrom, COLORREF colorTo, int bevelStyle);
    68: 
    69:     void ApplyBevel(int bevelStyle, int bevelPosition, int bevelWidth);
    70:     void bevel1(bool sunken);
    71:     void bevel2(bool sunken);
    72:     void lightenpixel(unsigned int count);
    73:     void darkenpixel(unsigned int count);
    74: 
    75:     void ApplyInterlace(bool bInterlaced);
    76: 
    77:     void dgradient(void);
    78:     void hgradient(void);
    79:     void vgradient(void);
    80:     void pgradient(void);
    81:     void rgradient(void);
    82:     void egradient(void);
    83:     void pcgradient(void);
    84:     void cdgradient(void);
    85: 
    86:     //====================
    87: 
    88:     unsigned int width;
    89:     unsigned int height;
    90:     unsigned int xoffset;
    91:     unsigned int yoffset;
    92:     unsigned int padding;
    93: 
    94:     HDC buf;
    95:     HBITMAP bufbmp;
    96:     HBITMAP oldbuf;
    97:     HBRUSH solid_brush;
    98: 
    99:     RECT fillRect;
   100: 
   101:     PBYTE pixels;
   102: 
   103:     BYTE from_red;
   104:     BYTE from_green;
   105:     BYTE from_blue;
   106:     BYTE to_red;
   107:     BYTE to_green;
   108:     BYTE to_blue;
   109: 
   110:     unsigned char* red;
   111:     unsigned char* green;
   112:     unsigned char* blue;
   113:     unsigned int* xtable;
   114:     unsigned int* ytable;
   115: 
   116:     bool sunken;
   117: 
   118:     //====================
   119: 
   120:     BYTE r, g, b, rr ,gg ,bb;
   121:     int sr, sg, sb;
   122: };
   123: 
   124: //===========================================================================
   125: 
   126: static unsigned long bsqrt(unsigned long x);
   127: unsigned long getSqrt(unsigned int x);
   128: 
   129: //===========================================================================
   130: 
   131: #endif /* __BIMAGE_H */ 
   132: