ReactOS  0.4.14-dev-583-g2a1ba2c
alphablend.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for alphablend.c:

Go to the source code of this file.

Classes

union  NICEPIXEL32
 

Macros

#define NDEBUG
 

Functions

static __inline UCHAR Clamp8 (ULONG val)
 
BOOLEAN DIB_XXBPP_AlphaBlend (SURFOBJ *Dest, SURFOBJ *Source, RECTL *DestRect, RECTL *SourceRect, CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation, BLENDOBJ *BlendObj)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file alphablend.c.

Function Documentation

◆ Clamp8()

static __inline UCHAR Clamp8 ( ULONG  val)
static

Definition at line 27 of file alphablend.c.

28 {
29  return (val > 255) ? 255 : (UCHAR)val;
30 }
GLuint GLfloat * val
Definition: glext.h:7180
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DIB_XXBPP_AlphaBlend().

◆ DIB_XXBPP_AlphaBlend()

BOOLEAN DIB_XXBPP_AlphaBlend ( SURFOBJ Dest,
SURFOBJ Source,
RECTL DestRect,
RECTL SourceRect,
CLIPOBJ ClipRegion,
XLATEOBJ ColorTranslation,
BLENDOBJ BlendObj 
)

Definition at line 33 of file alphablend.c.

36 {
37  INT DstX, DstY, SrcX, SrcY;
39  register NICEPIXEL32 DstPixel32;
40  register NICEPIXEL32 SrcPixel32;
41  UCHAR Alpha, SrcBpp = BitsPerFormat(Source->iBitmapFormat);
42  EXLATEOBJ* pexlo;
43  EXLATEOBJ exloSrcRGB, exloDstRGB, exloRGBSrc;
45 
46  DPRINT("DIB_16BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
47  SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
48  DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
49 
50  BlendFunc = BlendObj->BlendFunction;
52  {
53  DPRINT1("BlendOp != AC_SRC_OVER\n");
54  return FALSE;
55  }
56  if (BlendFunc.BlendFlags != 0)
57  {
58  DPRINT1("BlendFlags != 0\n");
59  return FALSE;
60  }
61  if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
62  {
63  DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
64  return FALSE;
65  }
66  if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
67  SrcBpp != 32)
68  {
69  DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
70  return FALSE;
71  }
72 
73  if (!ColorTranslation)
74  {
75  DPRINT1("ColorTranslation must not be NULL!\n");
76  return FALSE;
77  }
78 
79  pexlo = CONTAINING_RECORD(ColorTranslation, EXLATEOBJ, xlo);
80  EXLATEOBJ_vInitialize(&exloSrcRGB, pexlo->ppalSrc, &gpalRGB, 0, 0, 0);
81  EXLATEOBJ_vInitialize(&exloDstRGB, pexlo->ppalDst, &gpalRGB, 0, 0, 0);
82  EXLATEOBJ_vInitialize(&exloRGBSrc, &gpalRGB, pexlo->ppalSrc, 0, 0, 0);
83 
84  SrcY = SourceRect->top;
85  DstY = DestRect->top;
86  while ( DstY < DestRect->bottom )
87  {
88  SrcX = SourceRect->left;
89  DstX = DestRect->left;
90  while(DstX < DestRect->right)
91  {
92  SrcPixel32.ul = DIB_GetSource(Source, SrcX, SrcY, &exloSrcRGB.xlo);
93  SrcPixel32.col.red = (SrcPixel32.col.red * BlendFunc.SourceConstantAlpha) / 255;
94  SrcPixel32.col.green = (SrcPixel32.col.green * BlendFunc.SourceConstantAlpha) / 255;
95  SrcPixel32.col.blue = (SrcPixel32.col.blue * BlendFunc.SourceConstantAlpha) / 255;
96 
97  Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
98  (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha) / 255 :
100 
101  DstPixel32.ul = DIB_GetSource(Dest, DstX, DstY, &exloDstRGB.xlo);
102  DstPixel32.col.red = Clamp8((DstPixel32.col.red * (255 - Alpha)) / 255 + SrcPixel32.col.red) ;
103  DstPixel32.col.green = Clamp8((DstPixel32.col.green * (255 - Alpha)) / 255 + SrcPixel32.col.green) ;
104  DstPixel32.col.blue = Clamp8((DstPixel32.col.blue * (255 - Alpha)) / 255 + SrcPixel32.col.blue) ;
105  DstPixel32.ul = XLATEOBJ_iXlate(&exloRGBSrc.xlo, DstPixel32.ul);
106  pfnDibPutPixel(Dest, DstX, DstY, XLATEOBJ_iXlate(ColorTranslation, DstPixel32.ul));
107 
108  DstX++;
109  SrcX = SourceRect->left + ((DstX-DestRect->left)*(SourceRect->right - SourceRect->left))
110  /(DestRect->right-DestRect->left);
111  }
112  DstY++;
113  SrcY = SourceRect->top + ((DstY-DestRect->top)*(SourceRect->bottom - SourceRect->top))
114  /(DestRect->bottom-DestRect->top);
115  }
116 
117  EXLATEOBJ_vCleanup(&exloDstRGB);
118  EXLATEOBJ_vCleanup(&exloRGBSrc);
119  EXLATEOBJ_vCleanup(&exloSrcRGB);
120 
121  return TRUE;
122 }
#define TRUE
Definition: types.h:120
#define BitsPerFormat(Format)
Definition: surface.h:109
long bottom
Definition: polytest.cpp:53
ULONG iBitmapFormat
Definition: winddi.h:1215
#define AC_SRC_ALPHA
Definition: alphablend.c:9
int32_t INT
Definition: typedefs.h:56
BYTE BlendOp
Definition: wingdi.h:2758
XLATEOBJ xlo
Definition: xlateobj.h:21
long right
Definition: polytest.cpp:53
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
#define DIB_GetSource(SourceSurf, sx, sy, ColorTranslation)
Definition: dib.h:136
long top
Definition: polytest.cpp:53
PFN_DIB_PutPixel DIB_PutPixel
Definition: dib.h:45
void DPRINT(...)
Definition: polytest.cpp:61
GLint GLint bottom
Definition: glext.h:7726
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649
long left
Definition: polytest.cpp:53
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct NICEPIXEL32::@4102 col
BYTE SourceConstantAlpha
Definition: wingdi.h:2760
GLdouble GLdouble right
Definition: glext.h:10859
unsigned char UCHAR
Definition: xmlstorage.h:181
BYTE BlendFlags
Definition: wingdi.h:2759
#define AC_SRC_OVER
Definition: wingdi.h:1368
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
static __inline UCHAR Clamp8(ULONG val)
Definition: alphablend.c:27
#define DPRINT1
Definition: precomp.h:8
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
PALETTE gpalRGB
Definition: palette.c:20
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:664
PPALETTE ppalSrc
Definition: xlateobj.h:25
BYTE AlphaFormat
Definition: wingdi.h:2761
BLENDFUNCTION BlendFunc
Definition: general.c:32
ULONG ul
Definition: alphablend.c:16
BLENDFUNCTION BlendFunction
Definition: winddi.h:224
PPALETTE ppalDst
Definition: xlateobj.h:26
VOID(* PFN_DIB_PutPixel)(SURFOBJ *, LONG, LONG, ULONG)
Definition: dib.h:33