FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC AlphaBlend in Windows Mobile / WinCE
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
AlphaBlend in Windows Mobile / WinCE
Posted: Sat Apr 11, 2009 09:47 AM
We have found that some versions of Windows Mobile support AlphaBlend().

In order to check if your Windows Mobile or Windows CE supports it, please build and run the following test. A zero means it is not supported

test.prg
Code (fw): Select all Collapse
#include "FWCE.ch"

function Main()

   MsgInfo( Test() )

return nil

#pragma BEGINDUMP


#include <hbapi.h>
#include <windows.h>

LPWSTR AnsiToWide( char * );

HMODULE GetProcAddressW( HMODULE, LPWSTR );

HB_FUNC( TEST )
{
  LPWSTR pW1 = AnsiToWide( "coredll.dll" );
  LPWSTR pW2 = AnsiToWide( "AlphaBlend" );
  HMODULE hDll = LoadLibrary( pW1 );

  hb_retnl( ( LONG ) GetProcAddressW( hDll, pW2 ) );

  hb_xfree( pW1 );
  hb_xfree( pW2 );
  FreeLibrary( hDll );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Sat Apr 11, 2009 01:47 PM
Finally we got AlphaBlend support no matter if it is not supported by Windows Mobile or WinCE ! :-)

FWPPC has FWH ABPaint() too :-)

TestAB.prg
Code (fw): Select all Collapse
#include "FWCE.ch"

function Main()

   local oWnd, oBmp, oBmp2

   DEFINE BITMAP oBmp FILENAME CurDir() + "\Trash.bmp"

   DEFINE BITMAP oBmp2 FILENAME CurDir() + "\paper2.bmp"
   
   DEFINE WINDOW oWnd
   
   ACTIVATE WINDOW oWnd ;
      ON PAINT ( DrawBitmap( hDC, oBmp2:hBitmap, 0, 0 ), ABPaint( hDC, 10, 10, oBmp:hBitmap, 255 ) )

return nil

In Windows Mobile:

In Windows CE:
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Sun Apr 19, 2009 08:54 PM

Hello Antonio,
which version of FWPPC has ABPaint?
Best regards,
Otto
error LNK2001: unresolved external symbol HB_FUN_ABPAINT

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Tue Apr 21, 2009 07:39 AM

Otto,

We plan to publish a new FWPPC build that will include it :-)

In the meantime, we may provide you the required modules for you to test it :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Fri Aug 28, 2009 12:19 AM

Antonio ,
I runned your functio to chech if my smathphone have alpphablend system.
the msginfo return a number:66410360.
If you my smarthphone support alpha blend system?
I think it depend if on our system is loaded microsoft compact framework or not.
On wm 5.0 (on another smarthphone Htc TNT I) there is a net cf 1.0 and the ceck function return 0.
On my smathphone (htc tnt II ) there is now net cf 3.5 and the chech return the number 66410360.

Best Regards, Saludos



Falconi Silvio
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Fri Aug 28, 2009 07:53 AM

Silvio,

FWPPC ABPaint() function runs on all Windows versions :-)

It is a self contained C function, no need for Windows to support it.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Fri Aug 28, 2009 06:36 PM
Hello Antonio:
Antonio Linares wrote:It is a self contained C function, no need for Windows to support it.


Would you please to send me the required files to test it ?, thanks in advance.

Best regards

Manuel Mercado
my email: manuelmercado @ prodigy.net.mx
manuelmercado at prodigy dot net dot mx
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Sun Aug 30, 2009 07:09 AM

Antonio,
My fwppc not have ABPaint() function!
It is the same of fwh?

Best Regards, Saludos



Falconi Silvio
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Sun Aug 30, 2009 07:44 AM
This is the source code for ABPaint() for FWPPC:
Code (fw): Select all Collapse
BOOL AlphaBlendU( HDC dcDest, int x, int y, int cx, int cy,
                             HDC dcSrc, int sx, int sy, int scx, int scy, int alpha )
{
    BITMAPINFOHEADER BMI;
    BYTE * pSrcBits;
    HBITMAP hbmSrc;
    BYTE * pDestBits;
    HBITMAP hbmDest;
    HDC dc;
    HBITMAP dcOld;
    int j, i;

    // Fill in the header info.
    BMI.biSize = sizeof(BITMAPINFOHEADER);
    BMI.biWidth = cx;
    BMI.biHeight = cy;
    BMI.biPlanes = 1;
    BMI.biBitCount = 32;
    BMI.biCompression = BI_RGB;   // No compression
    BMI.biSizeImage = 0;
    BMI.biXPelsPerMeter = 0;
    BMI.biYPelsPerMeter = 0;
    BMI.biClrUsed = 0;           // Always use the whole palette.
    BMI.biClrImportant = 0;

    // Create DIB section in shared memory
    hbmSrc = CreateDIBSection (dcSrc, (BITMAPINFO *)&BMI,
        DIB_RGB_COLORS, (void **)&pSrcBits, 0, 0l);

    // Create DIB section in shared memory
    hbmDest = CreateDIBSection (dcDest, (BITMAPINFO *)&BMI,
        DIB_RGB_COLORS, (void **)&pDestBits, 0, 0l);

    // Copy our source and destination bitmaps onto our DIBSections,
    // so we can get access to their bits using the BYTE *'s we
    // passed into CreateDIBSection
    dc = CreateCompatibleDC(NULL);

    dcOld = (HBITMAP) SelectObject(dc, hbmSrc);

    if (!StretchBlt(dc, 0, 0, cx, cy, dcSrc, sx, sy,
                        scx, scy, SRCCOPY))
        return FALSE;

    SelectObject( dc, hbmDest );

    if(  !StretchBlt( dc, 0, 0, cx, cy, dcDest, x, y, cx, cy, SRCCOPY ) )
       return FALSE;

    SelectObject( dc, dcOld );
    DeleteDC( dc );

    for( j = 0; j < cy; ++j )
    {
       LPBYTE pbDestRGB = (LPBYTE)&((DWORD*)pDestBits)[j * cx];
       LPBYTE pbSrcRGB = (LPBYTE)&((DWORD*)pSrcBits)[j * cx];

       unsigned char a1, a2;

       for( i = 0; i < cx; ++i )
       {
          a1 = pbSrcRGB[ 3 ];

          if( a1 != 0 )
          {
             a1 = alpha * ( ( a1 * 100 ) / 255 ) / 100;
             a2 = 255 - a1;

             pbSrcRGB[ 0 ] = ( ( pbDestRGB[ 0 ] * a2 ) + ( pbSrcRGB[ 0 ] * a1 ) ) >> 8;
             pbSrcRGB[ 1 ] = ( ( pbDestRGB[ 1 ] * a2 ) + ( pbSrcRGB[ 1 ] * a1 ) ) >> 8;
             pbSrcRGB[ 2 ] = ( ( pbDestRGB[ 2 ] * a2 ) + ( pbSrcRGB[ 2 ] * a1 ) ) >> 8;
          }
          else
          {
             pbSrcRGB[ 0 ] = pbDestRGB[ 0 ];
             pbSrcRGB[ 1 ] = pbDestRGB[ 1 ];
             pbSrcRGB[ 2 ] = pbDestRGB[ 2 ];
          }
          pbSrcRGB += 4;
          pbDestRGB += 4;
       }
    }

    dc = CreateCompatibleDC( NULL );

    dcOld = (HBITMAP) SelectObject(dc, hbmSrc);

    if (!BitBlt(dcDest, x, y, cx, cy, dc, 0, 0, SRCCOPY))
        return FALSE;

    DeleteDC(dc);
    DeleteObject(hbmSrc);
    DeleteObject(hbmDest);

    return TRUE;
}

HB_FUNC( ABPAINT )
{
   HDC hDC = ( HDC ) hb_parnl( 1 );
   HDC hDCComp = CreateCompatibleDC( hDC );
   BITMAP bm;
   HGDIOBJ hOldBmp = SelectObject( hDCComp, ( HBITMAP ) hb_parnl( 4 ) );

   GetObject( ( HBITMAP ) hb_parnl( 4 ), sizeof( BITMAP ), ( LPSTR ) &bm );
   AlphaBlendU( hDC, hb_parnl( 2 ), hb_parnl( 3 ), bm.bmWidth, bm.bmHeight, hDCComp,
                0, 0, bm.bmWidth, bm.bmHeight, hb_parnl( 5 ) );

   SelectObject( hDCComp, hOldBmp );
   DeleteDC( hDCComp );
}

Example:
Code (fw): Select all Collapse
ABPaint( hDC, 10, 10, hBitmap, 200 )

screenshot using ABPaint() with FWPPC in Windows Mobile:
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Sun Aug 30, 2009 11:03 AM

thanks Antonio.
Isee your sample picture...how you made these buttons?

Best Regards, Saludos



Falconi Silvio
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: AlphaBlend in Windows Mobile / WinCE
Posted: Sun Aug 30, 2009 12:16 PM

Silvio,

A graphics designer did them using photoshop

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion