Commit in reactos/apps/tests on MAIN
Makefile+1-11.45 -> 1.46
alphablend/.cvsignore+6added 1.1
          /alphablend.c+213added 1.1
          /lena.bmp[binary]added 1.1
          /lenaalpha.bmp[binary]added 1.1
          /makefile+22added 1.1
+242-1
5 added + 1 modified, total 6 files
Added test app for AlphaBlend()

reactos/apps/tests
Makefile 1.45 -> 1.46
diff -u -r1.45 -r1.46
--- Makefile	15 Feb 2004 21:57:34 -0000	1.45
+++ Makefile	17 Feb 2004 14:55:59 -0000	1.46
@@ -7,7 +7,7 @@
 include $(PATH_TO_TOP)/rules.mak
 
 # test_old tests
-TEST_APPS = accelerator alive apc args atomtest bench bitblt button \
+TEST_APPS = accelerator alive alphablend apc args atomtest bench bitblt button \
 button2 capclock carets combo consume copymove count dibtest dump_shared_data \
 edit enumwnd enumws event global_mem gradient hello mdi \
 hivetest icontest isotest lineclip linetest lpc \

reactos/apps/tests/alphablend
.cvsignore added at 1.1
diff -N .cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .cvsignore	17 Feb 2004 14:55:59 -0000	1.1
@@ -0,0 +1,6 @@
+*.o
+*.d
+*.exe
+*.coff
+*.sym
+*.map

reactos/apps/tests/alphablend
alphablend.c added at 1.1
diff -N alphablend.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ alphablend.c	17 Feb 2004 14:55:59 -0000	1.1
@@ -0,0 +1,213 @@
+#include <windows.h>
+#include <string.h>
+
+#ifndef AC_SRC_ALPHA
+#define AC_SRC_ALPHA	(0x1)
+#endif
+
+HINSTANCE HInst;
+const char* WndClassName = "GMainWnd";
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, 
+   LPARAM LParam);
+   
+WINBOOL 
+STDCALL
+GdiAlphaBlend(HDC hdcDst,LONG DstX,LONG DstY,LONG DstCx,LONG DstCy,HDC hdcSrc,LONG SrcX,LONG SrcY,LONG SrcCx,LONG SrcCy,BLENDFUNCTION BlendFunction);
+
+
+int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance,
+    LPTSTR lpCmdLine, int nCmdShow)
+{
+   WNDCLASS wc;
+   MSG msg;
+
+   HInst = HInstance;
+
+   memset(&wc, 0, sizeof(WNDCLASS));
+    
+   wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
+   wc.lpfnWndProc = MainWndProc;
+   wc.hInstance = HInstance;
+   wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
+  /* wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1); */
+   wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
+   wc.lpszClassName = WndClassName;
+
+   if (RegisterClass(&wc))
+   {
+      HWND HWnd = 
+         CreateWindow(
+            WndClassName, TEXT("AlphaBlend Rendering Demo"),
+            WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | 
+            WS_VISIBLE | WS_CLIPSIBLINGS,
+            0, 0, 320, 430,
+            NULL, NULL, HInst, NULL
+            );
+                                 
+      if (HWnd)
+      {
+         ShowWindow(HWnd, nCmdShow);
+         UpdateWindow(HWnd);
+
+         while (GetMessage(&msg, NULL, 0, 0))
+         {
+             TranslateMessage(&msg);
+             DispatchMessage(&msg);
+         }      
+      }
+    }
+    return 0;
+}
+
+/* image related */
+BITMAP bmp;
+LPCSTR filename = TEXT("lena.bmp");
+HDC HMemDC = NULL, HMemDC2 = NULL;
+HBITMAP HOldBmp = NULL;
+PVOID pBmpBits = NULL;
+HBITMAP H32BppBitmap = NULL;
+BITMAPINFO bmpi;
+
+BOOL ConvertBitmapTo32Bpp(HDC hDC, BITMAP *bmp)
+{
+  ZeroMemory(&bmpi, sizeof(BITMAPINFO));
+  bmpi.bmiHeader.biSize = sizeof(BITMAPINFO);
+  bmpi.bmiHeader.biWidth = bmp->bmWidth;
+  bmpi.bmiHeader.biHeight = bmp->bmHeight;
+  bmpi.bmiHeader.biPlanes = 1;
+  bmpi.bmiHeader.biBitCount = 32;
+  bmpi.bmiHeader.biCompression = BI_RGB;
+  bmpi.bmiHeader.biSizeImage = 4 * bmpi.bmiHeader.biWidth * bmpi.bmiHeader.biHeight;
+  H32BppBitmap = CreateDIBSection(hDC, &bmpi, DIB_RGB_COLORS, &pBmpBits, 0, 0);
+  if(H32BppBitmap)
+  {
+    HBITMAP bmpalpha;
+    SelectObject(hDC, H32BppBitmap);
+    BitBlt(hDC, 0, 0, bmp->bmWidth, bmp->bmHeight, HMemDC, 0, 0, SRCCOPY);
+    
+    /* load and apply alpha channel */
+    bmpalpha = LoadImage(HInst, TEXT("lenaalpha.bmp"), IMAGE_BITMAP, 
+                            0, 0, LR_LOADFROMFILE);
+    if(bmpalpha)
+    {
+      COLORREF *col = pBmpBits;
+      int x, y;
+      HDC hdcTemp = CreateCompatibleDC(NULL);
+      if(!hdcTemp)
+      {
+        DeleteObject(bmpalpha);
+        return FALSE;
+      }
+      SelectObject(hdcTemp, bmpalpha);
+      
+      for(y = 0; y < bmp->bmHeight; y++)
+      {
+        for(x = 0; x < bmp->bmWidth; x++)
+        {
+          COLORREF Color = (COLORREF)GetRValue(GetPixel(hdcTemp, x, y)) << 24;
+          *col++ |= Color;
+        }
+      }
+      
+      DeleteObject(bmpalpha);
+      DeleteDC(hdcTemp);
+      return TRUE;
+    }
+    return FALSE;
+  }
+  return FALSE;
+}
+
+LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, 
+   LPARAM LParam)
+{
+   switch (Msg)
+   {
+      case WM_CREATE:
+      {         
+         /* create a memory DC */
+         HMemDC = CreateCompatibleDC(NULL);
+         if (HMemDC)
+         {
+            /* load a bitmap from file */
+            HBITMAP HBmp = 
+               /* static_cast<HBITMAP> */(
+                  LoadImage(HInst, filename, IMAGE_BITMAP, 
+                            0, 0, LR_LOADFROMFILE)
+                            );  
+            if (HBmp)
+            { 
+               /* extract dimensions of the bitmap */
+               GetObject(HBmp, sizeof(BITMAP), &bmp);
+
+               /* associate the bitmap with the memory DC */
+               /* HOldBmp = static_cast<HBITMAP> */
+		(SelectObject(HMemDC, HBmp)
+                  );
+                HMemDC2 = CreateCompatibleDC(NULL);
+                if(!ConvertBitmapTo32Bpp(HMemDC2, &bmp))
+                {
+                  PostQuitMessage(0);
+                  return 0;
+                }
+            }
+         }         
+      }
+      case WM_PAINT:
+      {
+         PAINTSTRUCT ps;
+         BLENDFUNCTION BlendFunc;
+         HDC Hdc = BeginPaint(HWnd, &ps);
+#if 0
+         try
+#endif
+         {
+            
+            BlendFunc.BlendOp = AC_SRC_OVER;
+            BlendFunc.BlendFlags = 0;
+            BlendFunc.SourceConstantAlpha = 128;
+            BlendFunc.AlphaFormat = 0;
+            
+            BitBlt(Hdc, 100, 90, 
+                   bmp.bmWidth, bmp.bmHeight,
+                   HMemDC2, 0, 0, 
+                   SRCCOPY); 
+            GdiAlphaBlend(Hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
+                          HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
+                          BlendFunc);
+            GdiAlphaBlend(Hdc, bmp.bmWidth - 15, 10, bmp.bmWidth / 2, bmp.bmHeight / 2,
+                          HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
+                          BlendFunc);
+            
+            BlendFunc.SourceConstantAlpha = 255;
+            BlendFunc.AlphaFormat = AC_SRC_ALPHA;
+            
+            GdiAlphaBlend(Hdc, 140, 200, bmp.bmWidth, bmp.bmHeight,
+                          HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
+                          BlendFunc);
+            GdiAlphaBlend(Hdc, 20, 210, (bmp.bmWidth / 3) * 2, (bmp.bmHeight / 3) * 2,
+                          HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
+                          BlendFunc);
+         }           
+#if 0
+         catch (...)
+         {
+            EndPaint(HWnd, &ps);
+         }
+#endif
+         EndPaint(HWnd, &ps);
+         break;
+      }
+      case WM_DESTROY:
+      {
+         /* clean up */
+         DeleteObject(SelectObject(HMemDC, HOldBmp));
+         DeleteDC(HMemDC);
+         DeleteDC(HMemDC2);
+
+         PostQuitMessage(0);
+         return 0;
+      }
+   }
+   return DefWindowProc(HWnd, Msg, WParam, LParam);
+}

reactos/apps/tests/alphablend
makefile added at 1.1
diff -N makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ makefile	17 Feb 2004 14:55:59 -0000	1.1
@@ -0,0 +1,22 @@
+
+PATH_TO_TOP = ../../..
+
+TARGET_NORC = yes
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = windows
+
+TARGET_NAME = alphablend
+
+TARGET_SDKLIBS = kernel32.a gdi32.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF
CVSspam 0.2.8