[ros-diffs] [gedmurphy] 24998: - implement 'blur' and 'sharpness' - implement 'contrast' allowing for separate adjustment of RGB colours - Decorate the contrast / blur function names to make GCC happy. These functions will be merged at a later stage - implement fading in and out of the floating windows. To activate, hover your cursor over one of the windows, then away again. Only works in Windows, ROS has missing translucency functionality at the moment.

gedmurphy at svn.reactos.org gedmurphy at svn.reactos.org
Thu Nov 30 20:02:15 CET 2006


Author: gedmurphy
Date: Thu Nov 30 22:02:14 2006
New Revision: 24998

URL: http://svn.reactos.org/svn/reactos?rev=24998&view=rev
Log:
- implement 'blur' and 'sharpness'
- implement 'contrast' allowing for separate adjustment of RGB colours
- Decorate the contrast / blur function names to make GCC happy. These functions will be merged at a later stage
- implement fading in and out of the floating windows. To activate, hover your cursor over one of the windows, then away again. Only works in Windows, ROS has missing translucency functionality at the moment.

Added:
    trunk/reactos/base/applications/imagesoft/contrast.c
Modified:
    trunk/reactos/base/applications/imagesoft/adjust.c
    trunk/reactos/base/applications/imagesoft/brightness.c
    trunk/reactos/base/applications/imagesoft/floatwindow.c
    trunk/reactos/base/applications/imagesoft/imageprop.h
    trunk/reactos/base/applications/imagesoft/imagesoft.rbuild
    trunk/reactos/base/applications/imagesoft/lang/en-US.rc
    trunk/reactos/base/applications/imagesoft/mainwnd.c
    trunk/reactos/base/applications/imagesoft/precomp.h
    trunk/reactos/base/applications/imagesoft/resource.h

Modified: trunk/reactos/base/applications/imagesoft/adjust.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/adjust.c?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/adjust.c (original)
+++ trunk/reactos/base/applications/imagesoft/adjust.c Thu Nov 30 22:02:14 2006
@@ -61,13 +61,13 @@
             g = GetGValue(Val);
             r = GetBValue(Val);
 
-            // get the average color value
-            Val = (r+g+b)/3;
-
-            // assign to RGB color            
+            /* get the average color value */
+            Val = (r + g + b) / 3;
+
+            /* assign to RGB color */
             Val = RGB(Val, Val, Val);
-            CopyMemory(&pBits[Count], 
-                       &Val, 
+            CopyMemory(&pBits[Count],
+                       &Val,
                        4);
 
             Count+=4;
@@ -156,11 +156,11 @@
             b = 255 - GetRValue(Val);
             g = 255 - GetGValue(Val);
             r = 255 - GetBValue(Val);
-            
+
             Val = RGB(b, g, r);
 
-            CopyMemory(&pBits[Count], 
-                       &Val, 
+            CopyMemory(&pBits[Count],
+                       &Val,
                        4);
 
             Count+=4;
@@ -189,3 +189,337 @@
 
     return TRUE;
 }
+
+
+
+BOOL
+DisplayBlur(HWND hwnd,
+            HDC hdcMem,
+            HBITMAP hBitmap)
+{
+    BITMAPINFO bi;
+    BITMAP bitmap;
+    BOOL bRes;
+    DWORD Count = 0;
+    INT i, j;
+    PBYTE pBits, pBitsTemp;
+    RECT rc;
+
+    GetObject(hBitmap,
+              sizeof(BITMAP),
+              &bitmap);
+
+    /* Bitmap header */
+    bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
+    bi.bmiHeader.biWidth = bitmap.bmWidth;
+    bi.bmiHeader.biHeight = bitmap.bmHeight;
+    bi.bmiHeader.biPlanes = 1;
+    bi.bmiHeader.biBitCount = 32;
+    bi.bmiHeader.biCompression = BI_RGB;
+    bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
+    bi.bmiHeader.biClrUsed = 0;
+    bi.bmiHeader.biClrImportant = 0;
+
+    /* Buffer */
+    pBits = (PBYTE)HeapAlloc(ProcessHeap,
+                             0,
+                             bitmap.bmWidth * bitmap.bmHeight * 4);
+    pBitsTemp = (PBYTE)HeapAlloc(ProcessHeap,
+                                 0,
+                                 bitmap.bmWidth * bitmap.bmHeight * 4);
+    if (!pBits || !pBitsTemp)
+        return FALSE;
+
+    /* get the bits from the original bitmap */
+    bRes = GetDIBits(hdcMem,
+                     hBitmap,
+                     0,
+                     bitmap.bmHeight,
+                     pBits,
+                     &bi,
+                     DIB_RGB_COLORS);
+
+    for (i = 0; i < bitmap.bmHeight; i++)
+    {
+        for (j = 0; j < bitmap.bmWidth; j++)
+        {
+            LONG Val = 0;
+            INT b, g, r;
+            INT c1, c2, c3, c4, c5;
+
+            CopyMemory(&Val,
+                       &pBits[Count],
+                       4);
+
+            b = GetRValue(Val);
+            g = GetGValue(Val);
+            r = GetBValue(Val);
+
+            c1 = r;
+            /*  Red */
+            if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
+                (Count > (bitmap.bmWidth * 4lu)))
+            {
+                CopyMemory(&Val, &pBits[Count - (bitmap.bmWidth * 4)], 4);
+                c2 = GetBValue(Val);
+
+                CopyMemory(&Val, &pBits[Count + 4], 4);
+                c3 = GetBValue(Val);
+
+                CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4))], 4);
+                c4 = GetBValue(Val);
+
+                CopyMemory(&Val, &pBits[Count - 4], 4);
+                c5 = GetBValue(Val);
+
+                r = (c1 + c2 + c3 + c4 + c5) / 5;
+            }
+
+            /* Green */
+            c1 = g;
+            if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
+                (Count > (bitmap.bmWidth * 4lu)))
+            {
+                CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4lu))], 4);
+                c2 = GetGValue(Val);
+
+                CopyMemory(&Val, &pBits[Count + 4], 4);
+                c3 = GetGValue(Val);
+
+                CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4lu))], 4);
+                c4 = GetGValue(Val);
+
+                CopyMemory(&Val, &pBits[Count-4], 4);
+                c5 = GetGValue(Val);
+
+                g = (c1 + c2 + c3 + c4 + c5) / 5;
+            }
+
+            /* Blue */
+            c1 = b;
+            if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
+                (Count > (bitmap.bmWidth * 4lu)))
+            {
+                CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
+                c2 = GetRValue(Val);
+
+                CopyMemory(&Val, &pBits[Count + 4], 4);
+                c3 = GetRValue(Val);
+
+                CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
+                c4 = GetRValue(Val);
+
+               CopyMemory(&Val, &pBits[Count-4], 4);
+                c5 = GetRValue(Val);
+
+                b = (c1 + c2 + c3 + c4 + c5) / 5;
+            }
+
+            Val = RGB(b, g, r);
+
+            CopyMemory(&pBitsTemp[Count],
+                       &Val,
+                       4);
+
+            Count+=4;
+        }
+    }
+
+    /* Set the new pixel bits */
+    SetDIBits(hdcMem,
+              hBitmap,
+              0,
+              bRes,
+              pBitsTemp,
+              &bi,
+              DIB_RGB_COLORS);
+
+    HeapFree(ProcessHeap,
+             0,
+             pBits);
+    HeapFree(ProcessHeap,
+             0,
+             pBitsTemp);
+
+    GetClientRect(hwnd,
+                  &rc);
+
+    InvalidateRect(hwnd,
+                   &rc,
+                   FALSE);
+
+    return TRUE;
+}
+
+
+
+BOOL
+DisplaySharpness(HWND hwnd,
+                 HDC hdcMem,
+                 HBITMAP hBitmap)
+{
+    BITMAPINFO bi;
+    BITMAP bitmap;
+    BOOL bRes;
+    DWORD Count = 0;
+    INT i, j;
+    PBYTE pBits, pBitsTemp;
+    RECT rc;
+
+    GetObject(hBitmap,
+              sizeof(BITMAP),
+              &bitmap);
+
+    /* Bitmap header */
+    bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
+    bi.bmiHeader.biWidth = bitmap.bmWidth;
+    bi.bmiHeader.biHeight = bitmap.bmHeight;
+    bi.bmiHeader.biPlanes = 1;
+    bi.bmiHeader.biBitCount = 32;
+    bi.bmiHeader.biCompression = BI_RGB;
+    bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
+    bi.bmiHeader.biClrUsed = 0;
+    bi.bmiHeader.biClrImportant = 0;
+
+    /* Buffer */
+    pBits = (PBYTE)HeapAlloc(ProcessHeap,
+                             0,
+                             bitmap.bmWidth * bitmap.bmHeight * 4);
+    pBitsTemp = (PBYTE)HeapAlloc(ProcessHeap,
+                                 0,
+                                 bitmap.bmWidth * bitmap.bmHeight * 4);
+    if (!pBits || !pBitsTemp)
+        return FALSE;
+
+    /* get the bits from the original bitmap */
+    bRes = GetDIBits(hdcMem,
+                     hBitmap,
+                     0,
+                     bitmap.bmHeight,
+                     pBits,
+                     &bi,
+                     DIB_RGB_COLORS);
+
+    for (i = 0; i < bitmap.bmHeight; i++)
+    {
+        for (j = 0; j < bitmap.bmWidth; j++)
+        {
+            LONG Val = 0;
+            INT b, g, r;
+            INT c1, c2, c3, c4, c5;
+
+            CopyMemory(&Val,
+                       &pBits[Count],
+                       4);
+
+            b = GetRValue(Val);
+            g = GetGValue(Val);
+            r = GetBValue(Val);
+
+            c1 = r;
+            /* Red */
+            if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
+                (Count > (bitmap.bmWidth * 4lu)))
+            {
+                CopyMemory(&Val, &pBits[Count - (bitmap.bmWidth * 4l)], 4);
+                c2 = GetBValue(Val);
+
+                CopyMemory(&Val, &pBits[Count + 4], 4);
+                c3 = GetBValue(Val);
+
+                CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
+                c4 = GetBValue(Val);
+
+                CopyMemory(&Val, &pBits[Count - 4], 4);
+                c5 = GetBValue(Val);
+
+                r = (c1 * 5) - (c2 + c3 + c4 + c5);
+            }
+
+            /* Green */
+            c1 = g;
+            if ((Count < ((bitmap.bmHeight - 1)* bitmap.bmWidth * 4lu)) && 
+                (Count > (bitmap.bmWidth * 4lu)))
+            {
+                CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
+                c2 = GetGValue(Val);
+
+                CopyMemory(&Val, &pBits[Count + 4], 4);
+                c3 = GetGValue(Val);
+
+                CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
+                c4 = GetGValue(Val);
+
+                CopyMemory(&Val, &pBits[Count - 4], 4);
+                c5 = GetGValue(Val);
+
+                g = (c1 * 5) - (c2 + c3 + c4 + c5);
+            }
+
+            /* Blue */
+            c1 = b;
+            if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) && 
+                (Count > (bitmap.bmWidth * 4lu)))
+            {
+                CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
+                c2 = GetRValue(Val);
+
+                CopyMemory(&Val, &pBits[Count + 4], 4);
+                c3 = GetRValue(Val);
+
+                CopyMemory(&Val, &pBits[(Count+(bitmap.bmWidth * 4l))], 4);
+                c4 = GetRValue(Val);
+
+                CopyMemory(&Val, &pBits[Count - 4], 4);
+                c5 = GetRValue(Val);
+
+                b = (c1 * 5) - (c2 + c3 + c4 + c5);
+            }
+
+            /* Red */
+            if (r > 255) r = 255;
+            if (r < 0) r = 0;
+
+            /* Green */
+            if (g > 255) g = 255;
+            if (g < 0)g = 0;
+
+            /* Blue */
+            if (b > 255) b = 255;
+            if (b < 0) b = 0;
+
+            Val = RGB(b, g, r);
+
+            CopyMemory(&pBitsTemp[Count],
+                       &Val,
+                       4);
+
+            Count+=4;
+        }
+    }
+
+    /* Set the new pixel bits */
+    SetDIBits(hdcMem,
+              hBitmap,
+              0,
+              bRes,
+              pBitsTemp,
+              &bi,
+              DIB_RGB_COLORS);
+
+    HeapFree(ProcessHeap,
+             0,
+             pBits);
+    HeapFree(ProcessHeap,
+             0,
+             pBitsTemp);
+
+    GetClientRect(hwnd,
+                  &rc);
+
+    InvalidateRect(hwnd,
+                   &rc,
+                   FALSE);
+
+    return TRUE;
+}

Modified: trunk/reactos/base/applications/imagesoft/brightness.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/brightness.c?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/brightness.c (original)
+++ trunk/reactos/base/applications/imagesoft/brightness.c Thu Nov 30 22:02:14 2006
@@ -116,7 +116,7 @@
 
 
 static PIMAGEADJUST
-OnInitDialog(PIMAGEADJUST pImgAdj,
+Bri_OnInitDialog(PIMAGEADJUST pImgAdj,
              HWND hDlg,
              LPARAM lParam)
 {
@@ -188,7 +188,7 @@
 
 
 static VOID
-OnDrawItem(PIMAGEADJUST pImgAdj,
+Bri_OnDrawItem(PIMAGEADJUST pImgAdj,
            LPARAM lParam)
 {
     LPDRAWITEMSTRUCT lpDrawItem;
@@ -219,7 +219,7 @@
 
 
 static VOID
-OnTrackBar(PIMAGEADJUST pImgAdj,
+Bri_OnTrackBar(PIMAGEADJUST pImgAdj,
            HWND hDlg)
 {
     HDC hdcMem;
@@ -268,7 +268,7 @@
 
 
 static BOOL
-OnCommand(PIMAGEADJUST pImgAdj,
+Bri_OnCommand(PIMAGEADJUST pImgAdj,
           HWND hDlg,
           UINT uID)
 {
@@ -321,9 +321,9 @@
     {
         case WM_INITDIALOG:
         {
-            pImgAdj = OnInitDialog(pImgAdj,
-                                   hDlg,
-                                   lParam);
+            pImgAdj = Bri_OnInitDialog(pImgAdj,
+                                       hDlg,
+                                       lParam);
             if (!pImgAdj)
             {
                 EndDialog(hDlg, -1);
@@ -335,8 +335,8 @@
 
         case WM_DRAWITEM:
         {
-            OnDrawItem(pImgAdj,
-                       lParam);
+            Bri_OnDrawItem(pImgAdj,
+                           lParam);
             return TRUE;
         }
 
@@ -345,8 +345,8 @@
             if (LOWORD(wParam) == TB_THUMBTRACK ||
                 LOWORD(wParam) == TB_ENDTRACK)
             {
-                OnTrackBar(pImgAdj,
-                           hDlg);
+                Bri_OnTrackBar(pImgAdj,
+                               hDlg);
             }
 
             return TRUE;
@@ -354,9 +354,9 @@
 
         case WM_COMMAND:
         {
-            return OnCommand(pImgAdj,
-                             hDlg,
-                             LOWORD(wParam));
+            return Bri_OnCommand(pImgAdj,
+                                 hDlg,
+                                 LOWORD(wParam));
         }
 
         case WM_DESTROY:

Added: trunk/reactos/base/applications/imagesoft/contrast.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/contrast.c?rev=24998&view=auto
==============================================================================
--- trunk/reactos/base/applications/imagesoft/contrast.c (added)
+++ trunk/reactos/base/applications/imagesoft/contrast.c Thu Nov 30 22:02:14 2006
@@ -1,0 +1,380 @@
+#include "precomp.h"
+
+#define BASECOLOUR 100
+
+
+VOID
+AdjustContrast(HBITMAP hOrigBitmap,
+               HBITMAP hNewBitmap,
+               HWND hwnd,
+               HDC hdcMem,
+               INT RedVal,
+               INT GreenVal,
+               INT BlueVal)
+{
+    BITMAPINFO bi;
+    BITMAP bitmap;
+    BOOL bRes;
+    DWORD Count = 0;
+    INT i, j;
+    PBYTE pBits;
+    RECT rc;
+
+    GetObject(hNewBitmap,
+              sizeof(BITMAP),
+              &bitmap);
+
+    /* Bitmap header */
+    bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
+    bi.bmiHeader.biWidth = bitmap.bmWidth;
+    bi.bmiHeader.biHeight = bitmap.bmHeight;
+    bi.bmiHeader.biPlanes = 1;
+    bi.bmiHeader.biBitCount = 32;
+    bi.bmiHeader.biCompression = BI_RGB;
+    bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
+    bi.bmiHeader.biClrUsed = 0;
+    bi.bmiHeader.biClrImportant = 0;
+
+    /* Buffer */
+    pBits = (PBYTE)HeapAlloc(ProcessHeap,
+                             0,
+                             bitmap.bmWidth * bitmap.bmHeight * 4);
+    if (!pBits)
+        return;
+
+    /* get the bits from the original bitmap */
+    bRes = GetDIBits(hdcMem,
+                     hOrigBitmap,
+                     0,
+                     bitmap.bmHeight,
+                     pBits,
+                     &bi,
+                     DIB_RGB_COLORS);
+
+    for (i = 0; i < bitmap.bmHeight; i++)
+    {
+        for (j = 0; j < bitmap.bmWidth; j++)
+        {
+            DWORD Val = 0;
+            INT b, g, r;
+
+            CopyMemory(&Val,
+                       &pBits[Count],
+                       4);
+
+            /* Get pixels in reverse order */
+            b = GetRValue(Val);
+            g = GetGValue(Val);
+            r = GetBValue(Val);
+
+            r = ((r - 128) * RedVal) / 100 + 128;
+            g = ((g - 128) * GreenVal) / 100 + 128;
+            b = ((b - 128) * BlueVal) / 100 + 128;
+
+            /* Red */
+            if (r > 255) r = 255;
+            else if (r < 0) r = 0;
+
+            /* Green */
+            if (g > 255) g = 255;
+            else if (g < 0) g = 0;
+
+            /* Blue */
+            if (b > 255) b = 255;
+            else if (b < 0) b = 0;
+
+            /* Store in reverse order */
+            Val = RGB(b, g, r);
+            CopyMemory(&pBits[Count],
+                       &Val,
+                       4);
+
+            /* RGB color take 4 bytes.The high-order byte must be zero */
+            Count += 4;
+        }
+    }
+
+    /* Set the new pixel bits */
+    SetDIBits(hdcMem,
+              hNewBitmap,
+              0,
+              bRes,
+              pBits,
+              &bi,
+              DIB_RGB_COLORS);
+
+    HeapFree(ProcessHeap,
+             0,
+             pBits);
+
+    GetClientRect(hwnd,
+                  &rc);
+
+    InvalidateRect(hwnd,
+                   &rc,
+                   FALSE);
+}
+
+
+static PIMAGEADJUST
+Cont_OnInitDialog(PIMAGEADJUST pImgAdj,
+             HWND hDlg,
+             LPARAM lParam)
+{
+    pImgAdj = HeapAlloc(ProcessHeap,
+                        0,
+                        sizeof(IMAGEADJUST));
+    if (!pImgAdj)
+        return NULL;
+
+
+    pImgAdj->Info = (PMAIN_WND_INFO)lParam;
+    if (!pImgAdj->Info->ImageEditors)
+        goto fail;
+
+
+    pImgAdj->hPicPrev = GetDlgItem(hDlg, IDC_PICPREVIEW);
+    GetClientRect(pImgAdj->hPicPrev,
+                  &pImgAdj->ImageRect);
+
+    /* Make a static copy of the main image */
+    pImgAdj->hBitmap = CopyImage(pImgAdj->Info->ImageEditors->hBitmap,
+                                 IMAGE_BITMAP,
+                                 pImgAdj->ImageRect.right,
+                                 pImgAdj->ImageRect.bottom,
+                                 LR_CREATEDIBSECTION);
+    if (!pImgAdj->hBitmap)
+        goto fail;
+
+    /* Make a copy which will be updated */
+    pImgAdj->hPreviewBitmap = CopyImage(pImgAdj->Info->ImageEditors->hBitmap,
+                                        IMAGE_BITMAP,
+                                        pImgAdj->ImageRect.right,
+                                        pImgAdj->ImageRect.bottom,
+                                        LR_CREATEDIBSECTION);
+    if (!pImgAdj->hPreviewBitmap)
+        goto fail;
+
+
+    pImgAdj->RedVal = pImgAdj->BlueVal = pImgAdj->GreenVal = 100;
+
+    /* setup dialog */
+    SendDlgItemMessage(hDlg,
+                       IDC_BRI_FULL,
+                       BM_SETCHECK,
+                       BST_CHECKED,
+                       0);
+    SendDlgItemMessage(hDlg,
+                       IDC_BRI_TRACKBAR,
+                       TBM_SETRANGE,
+                       TRUE,
+                       (LPARAM)MAKELONG(0, 200));
+    SendDlgItemMessage(hDlg,
+                       IDC_BRI_TRACKBAR,
+                       TBM_SETPOS,
+                       TRUE,
+                       (LPARAM)BASECOLOUR);
+    SetDlgItemText(hDlg,
+                   IDC_BRI_EDIT,
+                   _T("100"));
+
+    return pImgAdj;
+
+fail:
+    HeapFree(ProcessHeap,
+             0,
+             pImgAdj);
+    return NULL;
+}
+
+
+static VOID
+Cont_OnDrawItem(PIMAGEADJUST pImgAdj,
+           LPARAM lParam)
+{
+    LPDRAWITEMSTRUCT lpDrawItem;
+    HDC hdcMem;
+
+    lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
+
+    hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
+
+    if(lpDrawItem->CtlID == IDC_PICPREVIEW)
+    {
+        SelectObject(hdcMem,
+                     pImgAdj->hPreviewBitmap);
+
+        BitBlt(lpDrawItem->hDC,
+               pImgAdj->ImageRect.left,
+               pImgAdj->ImageRect.top,
+               pImgAdj->ImageRect.right,
+               pImgAdj->ImageRect.bottom,
+               hdcMem,
+               0,
+               0,
+               SRCCOPY);
+
+        DeleteDC(hdcMem);
+    }
+}
+
+
+static VOID
+Cont_OnTrackBar(PIMAGEADJUST pImgAdj,
+           HWND hDlg)
+{
+    HDC hdcMem;
+    DWORD TrackPos;
+
+    TrackPos = (DWORD)SendDlgItemMessage(hDlg,
+                                         IDC_BRI_TRACKBAR,
+                                         TBM_GETPOS,
+                                         0,
+                                         0);
+
+    SetDlgItemInt(hDlg,
+                  IDC_BRI_EDIT,
+                  TrackPos,
+                  FALSE);
+
+    if (IsDlgButtonChecked(hDlg, IDC_BRI_FULL) == BST_CHECKED)
+    {
+        pImgAdj->RedVal = pImgAdj->GreenVal = pImgAdj->BlueVal = TrackPos - BASECOLOUR + 100;
+    }
+    else if (IsDlgButtonChecked(hDlg, IDC_BRI_RED) == BST_CHECKED)
+    {
+        pImgAdj->RedVal = TrackPos - BASECOLOUR + 100;
+    }
+    else if (IsDlgButtonChecked(hDlg, IDC_BRI_GREEN) == BST_CHECKED)
+    {
+        pImgAdj->GreenVal = TrackPos - BASECOLOUR + 100;
+    }
+    else if (IsDlgButtonChecked(hDlg, IDC_BRI_BLUE) == BST_CHECKED)
+    {
+        pImgAdj->BlueVal = TrackPos - BASECOLOUR + 100;
+    }
+
+    hdcMem = GetDC(pImgAdj->hPicPrev);
+
+    AdjustContrast(pImgAdj->hBitmap,
+                     pImgAdj->hPreviewBitmap,
+                     pImgAdj->hPicPrev,
+                     hdcMem,
+                     pImgAdj->RedVal,
+                     pImgAdj->GreenVal,
+                     pImgAdj->BlueVal);
+
+    ReleaseDC(pImgAdj->hPicPrev, hdcMem);
+}
+
+
+static BOOL
+Cont_OnCommand(PIMAGEADJUST pImgAdj,
+          HWND hDlg,
+          UINT uID)
+{
+    switch (uID)
+    {
+        case IDOK:
+        {
+            HDC hdcMem;
+
+            hdcMem = GetDC(pImgAdj->Info->ImageEditors->hSelf);
+
+            AdjustContrast(pImgAdj->Info->ImageEditors->hBitmap,
+                             pImgAdj->Info->ImageEditors->hBitmap,
+                             pImgAdj->Info->ImageEditors->hSelf,
+                             hdcMem,
+                             pImgAdj->RedVal,
+                             pImgAdj->GreenVal,
+                             pImgAdj->BlueVal);
+
+            ReleaseDC(pImgAdj->Info->ImageEditors->hSelf,
+                      hdcMem);
+
+            EndDialog(hDlg,
+                      uID);
+
+            return TRUE;
+        }
+
+        case IDCANCEL:
+        {
+            EndDialog(hDlg,
+                      uID);
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+
+INT_PTR CALLBACK
+ContrastProc(HWND hDlg,
+             UINT message,
+             WPARAM wParam,
+             LPARAM lParam)
+{
+    static PIMAGEADJUST pImgAdj = NULL;
+
+    switch (message)
+    {
+        case WM_INITDIALOG:
+        {
+            pImgAdj = Cont_OnInitDialog(pImgAdj,
+                                        hDlg,
+                                        lParam);
+            if (!pImgAdj)
+            {
+                EndDialog(hDlg, -1);
+                return FALSE;
+            }
+
+            return TRUE;
+        }
+
+        case WM_DRAWITEM:
+        {
+            Cont_OnDrawItem(pImgAdj,
+                            lParam);
+            return TRUE;
+        }
+
+        case WM_HSCROLL:
+        {
+            if (LOWORD(wParam) == TB_THUMBTRACK ||
+                LOWORD(wParam) == TB_ENDTRACK)
+            {
+                Cont_OnTrackBar(pImgAdj,
+                                hDlg);
+            }
+
+            return TRUE;
+        }
+
+        case WM_COMMAND:
+        {
+            return Cont_OnCommand(pImgAdj,
+                                  hDlg,
+                                  LOWORD(wParam));
+        }
+
+        case WM_DESTROY:
+        {
+            if (pImgAdj)
+            {
+                if (pImgAdj->hBitmap)
+                    DeleteObject(pImgAdj->hBitmap);
+                if (pImgAdj->hPreviewBitmap)
+                    DeleteObject(pImgAdj->hPreviewBitmap);
+
+                HeapFree(ProcessHeap,
+                         0,
+                         pImgAdj);
+            }
+        }
+    }
+
+    return FALSE;
+}

Modified: trunk/reactos/base/applications/imagesoft/floatwindow.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/floatwindow.c?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/floatwindow.c (original)
+++ trunk/reactos/base/applications/imagesoft/floatwindow.c Thu Nov 30 22:02:14 2006
@@ -1,8 +1,10 @@
-#include <precomp.h>
+#include "precomp.h"
 
 static const TCHAR szFloatWndClass[] = TEXT("ImageSoftFloatWndClass");
 
-#define ID_TIMER 1
+#define ID_TIMER1 1
+#define ID_TIMER2 2
+#define ID_TIMER3 3
 
 TBBUTTON ToolsButtons[] = {
 /*   iBitmap,            idCommand,      fsState,         fsStyle,                                     bReserved[2], dwData, iString */
@@ -338,6 +340,116 @@
     return FALSE;
 }
 
+
+static VOID
+DoTimer(PFLT_WND FltInfo,
+        UINT idTimer)
+{
+    switch (idTimer)
+    {
+        /* timer to check if cursor is in toolbar coords */
+        case ID_TIMER1:
+        {
+            POINT pt;
+
+            /* kill timer if toobar is not opaque */
+            if (FltInfo->bOpaque != TRUE)
+            {
+                KillTimer(FltInfo->hSelf,
+                          ID_TIMER1);
+                break;
+            }
+
+            if (GetCursorPos(&pt))
+            {
+                RECT rect;
+
+                if (GetWindowRect(FltInfo->hSelf,
+                                  &rect))
+                {
+                    if (!PtInRect(&rect,
+                                  pt))
+                    {
+                        KillTimer(FltInfo->hSelf,
+                                  ID_TIMER1);
+                        KillTimer(FltInfo->hSelf,
+                                  ID_TIMER2);
+
+                        /* timer to fade out toolbar */
+                        SetTimer(FltInfo->hSelf,
+                                 ID_TIMER3,
+                                 50,
+                                 NULL);
+                    }
+                }
+            }
+        }
+        break;
+
+        /* timer to fade in toolbar */
+        case ID_TIMER2:
+        {
+            SetLayeredWindowAttributes(FltInfo->hSelf,
+                                       0,
+                                       (255 * FltInfo->Transparancy) / 100,
+                                       LWA_ALPHA);
+
+            /* increment transparancy until it is opaque (100) */
+            FltInfo->Transparancy += 5;
+
+            if (FltInfo->Transparancy == 100)
+            {
+                SetWindowLongPtr(FltInfo->hSelf,
+                                 GWL_EXSTYLE,
+                                 GetWindowLongPtr(FltInfo->hSelf,
+                                                  GWL_EXSTYLE) & ~WS_EX_LAYERED);
+
+                FltInfo->bOpaque = TRUE;
+
+                KillTimer(FltInfo->hSelf,
+                          ID_TIMER2);
+            }
+        }
+        break;
+
+        case ID_TIMER3:
+        {
+            LONG Style;
+
+            Style = GetWindowLongPtr(FltInfo->hSelf,
+                                     GWL_EXSTYLE);
+
+            if (Style & ~WS_EX_LAYERED)
+            {
+                SetWindowLongPtr(FltInfo->hSelf,
+                                 GWL_EXSTYLE,
+                                 Style | WS_EX_LAYERED);
+            }
+
+            FltInfo->Transparancy -= 5;
+
+            if (FltInfo->Transparancy >= 60)
+            {
+                /* set the tranclucency to 60% */
+                SetLayeredWindowAttributes(FltInfo->hSelf,
+                                           0,
+                                           (255 * FltInfo->Transparancy) / 100,
+                                           LWA_ALPHA);
+
+                if (FltInfo->Transparancy == 60)
+                {
+                    FltInfo->bOpaque = FALSE;
+
+                    KillTimer(FltInfo->hSelf,
+                              ID_TIMER3);
+                }
+
+            }
+        }
+        break;
+    }
+}
+
 LRESULT CALLBACK
 FloatToolbarWndProc(HWND hwnd,
                     UINT Message,
@@ -363,6 +475,10 @@
             /*FIXME: read this from registry */
 //            FltInfo->bShow = TRUE;
 
+            SetWindowLongPtr(hwnd,
+                             GWLP_USERDATA,
+                             (LONG_PTR)FltInfo);
+
             FltInfo->bOpaque = FALSE;
 
             SetWindowLongPtr(hwnd,
@@ -371,53 +487,18 @@
                                               GWL_EXSTYLE) | WS_EX_LAYERED);
 
             /* set the tranclucency to 60% */
+            FltInfo->Transparancy = 60;
             SetLayeredWindowAttributes(hwnd,
                                        0,
-                                       (255 * 60) / 100,
+                                       (255 * FltInfo->Transparancy) / 100,
                                        LWA_ALPHA);
         }
         break;
 
         case WM_TIMER:
         {
-            POINT pt;
-
-            if (FltInfo->bOpaque != TRUE)
-            {
-                KillTimer(hwnd,
-                          ID_TIMER);
-                break;
-            }
-
-            if (GetCursorPos(&pt))
-            {
-                RECT rect;
-
-                if (GetWindowRect(hwnd,
-                                  &rect))
-                {
-                    if (! PtInRect(&rect,
-                                   pt))
-                    {
-                        KillTimer(hwnd,
-                                  ID_TIMER);
-
-                        FltInfo->bOpaque = FALSE;
-
-                        SetWindowLongPtr(hwnd,
-                                         GWL_EXSTYLE,
-                                         GetWindowLongPtr(hwnd,
-                                                          GWL_EXSTYLE) | WS_EX_LAYERED);
-
-                        /* set the tranclucency to 60% */
-                        SetLayeredWindowAttributes(hwnd,
-                                                   0,
-                                                   (255 * 60) / 100,
-                                                   LWA_ALPHA);
-
-                    }
-                }
-            }
+            DoTimer(FltInfo,
+                    wParam);
         }
         break;
 
@@ -426,10 +507,6 @@
         {
             if (FltInfo->bOpaque == FALSE)
             {
-                SetWindowLongPtr(hwnd,
-                                 GWL_EXSTYLE,
-                                 GetWindowLongPtr(hwnd,
-                                                  GWL_EXSTYLE) & ~WS_EX_LAYERED);
 
                 RedrawWindow(hwnd,
                              NULL,
@@ -437,10 +514,18 @@
                              RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
 
                 FltInfo->bOpaque = TRUE;
-                MessageBox(NULL, _T("in"), _T("Hit test"), MB_OK | MB_ICONEXCLAMATION);
+                //MessageBox(NULL, _T("in"), _T("Hit test"), MB_OK | MB_ICONEXCLAMATION);
+
+                /* timer to check if cursor is in toolbar coords */
                 SetTimer(hwnd,
-                         ID_TIMER,
+                         ID_TIMER1,
                          200,
+                         NULL);
+
+                /* timer to fade in the toolbars */
+                SetTimer(hwnd,
+                         ID_TIMER2,
+                         50,
                          NULL);
             }
         }
@@ -541,3 +626,4 @@
                     hInstance);
 }
 
+

Modified: trunk/reactos/base/applications/imagesoft/imageprop.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/imageprop.h?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imageprop.h (original)
+++ trunk/reactos/base/applications/imagesoft/imageprop.h Thu Nov 30 22:02:14 2006
@@ -22,6 +22,11 @@
                                 WPARAM wParam,
                                 LPARAM lParam);
 
+INT_PTR CALLBACK ContrastProc(HWND hDlg,
+                              UINT message,
+                              WPARAM wParam,
+                              LPARAM lParam);
+
 VOID AdjustBrightness(HBITMAP hOrigBitmap,
                       HBITMAP hNewBitmap,
                       HWND hwnd,
@@ -30,5 +35,15 @@
                       INT GreenVal,
                       INT BlueVal);
 
-BOOL DisplayBlackAndWhite(HWND hwnd, HDC hdcMem, HBITMAP hBitmap);
-BOOL DisplayInvertedColors(HWND hwnd, HDC hdcMem, HBITMAP hBitmap);
+BOOL DisplayBlackAndWhite(HWND hwnd,
+                          HDC hdcMem,
+                          HBITMAP hBitmap);
+BOOL DisplayInvertedColors(HWND hwnd,
+                           HDC hdcMem,
+                           HBITMAP hBitmap);
+BOOL DisplayBlur(HWND hwnd,
+                 HDC hdcMem,
+                 HBITMAP hBitmap);
+BOOL DisplaySharpness(HWND hwnd,
+                      HDC hdcMem,
+                      HBITMAP hBitmap);

Modified: trunk/reactos/base/applications/imagesoft/imagesoft.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/imagesoft.rbuild?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imagesoft.rbuild (original)
+++ trunk/reactos/base/applications/imagesoft/imagesoft.rbuild Thu Nov 30 22:02:14 2006
@@ -19,6 +19,7 @@
 			<file>about.c</file>
 			<file>adjust.c</file>
 			<file>brightness.c</file>
+			<file>contrast.c</file>
 			<file>custcombo.c</file>
 			<file>floatwindow.c</file>
 			<file>font.c</file>

Modified: trunk/reactos/base/applications/imagesoft/lang/en-US.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/lang/en-US.rc?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/lang/en-US.rc (original)
+++ trunk/reactos/base/applications/imagesoft/lang/en-US.rc Thu Nov 30 22:02:14 2006
@@ -50,14 +50,14 @@
     MENUITEM "Brightness...",       ID_BRIGHTNESS
     MENUITEM "Contrast...",         -1, GRAYED
     MENUITEM "Hue/Saturation...",   -1, GRAYED
-    POPUP "Color"
+    POPUP "Colour"
     BEGIN
       MENUITEM "Black and White"    ID_BLACKANDWHITE
-      MENUITEM "Invert Colors"      ID_INVERTCOLORS
+      MENUITEM "Invert Colours"     ID_INVERTCOLORS
     END
     MENUITEM SEPARATOR
-    MENUITEM "Blur",                -1, GRAYED
-    MENUITEM "Sharpen",             -1, GRAYED
+    MENUITEM "Blur",                ID_BLUR
+    MENUITEM "Sharpen",             ID_SHARPEN
     MENUITEM "Smooth Edges",        -1, GRAYED
     MENUITEM "Add Shadow",          -1, GRAYED
     MENUITEM SEPARATOR

Modified: trunk/reactos/base/applications/imagesoft/mainwnd.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/mainwnd.c?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/mainwnd.c (original)
+++ trunk/reactos/base/applications/imagesoft/mainwnd.c Thu Nov 30 22:02:14 2006
@@ -904,7 +904,15 @@
                            Info->hSelf,
                            BrightnessProc,
                            (LPARAM)Info);
-            break;
+        break;
+
+        case ID_CONTRAST:
+            DialogBoxParam(hInstance,
+                           MAKEINTRESOURCE(IDD_BRIGHTNESS),
+                           Info->hSelf,
+                           ContrastProc,
+                           (LPARAM)Info);
+        break;
 
         case ID_BLACKANDWHITE:
         {
@@ -925,7 +933,29 @@
                                       Info->ImageEditors->hDCMem,
                                       Info->ImageEditors->hBitmap);
             }
-        }        
+        }
+        break;
+
+        case ID_BLUR:
+        {
+            if (Info->ImageEditors)
+            {
+                DisplayBlur(Info->ImageEditors->hSelf,
+                            Info->ImageEditors->hDCMem,
+                            Info->ImageEditors->hBitmap);
+            }
+        }
+        break;
+
+        case ID_SHARPEN:
+        {
+            if (Info->ImageEditors)
+            {
+                DisplaySharpness(Info->ImageEditors->hSelf,
+                                 Info->ImageEditors->hDCMem,
+                                 Info->ImageEditors->hBitmap);
+            }
+        }
         break;
 
         case ID_EXIT:

Modified: trunk/reactos/base/applications/imagesoft/precomp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/precomp.h?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/precomp.h (original)
+++ trunk/reactos/base/applications/imagesoft/precomp.h Thu Nov 30 22:02:14 2006
@@ -49,6 +49,7 @@
     INT y;
     INT Width;
     INT Height;
+    INT Transparancy;
     BOOL bOpaque;
 } FLT_WND, *PFLT_WND;
 

Modified: trunk/reactos/base/applications/imagesoft/resource.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesoft/resource.h?rev=24998&r1=24997&r2=24998&view=diff
==============================================================================
--- trunk/reactos/base/applications/imagesoft/resource.h (original)
+++ trunk/reactos/base/applications/imagesoft/resource.h Thu Nov 30 22:02:14 2006
@@ -80,8 +80,11 @@
 
 /* Adjust */
 #define ID_BRIGHTNESS           2100
-#define ID_BLACKANDWHITE        2101
-#define ID_INVERTCOLORS         2102
+#define ID_CONTRAST             2101
+#define ID_BLACKANDWHITE        2102
+#define ID_INVERTCOLORS         2103
+#define ID_BLUR                 2104
+#define ID_SHARPEN              2105
 
 #define ID_ABOUT                2400
 




More information about the Ros-diffs mailing list