Full AlphaBlend support for FWH !!!

Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Sun Mar 29, 2009 4:47 pm

After the success that we had implementing HasAlpha() (without having to use FreeImage.dll) for bitmaps:

viewtopic.php?f=3&t=15008&p=77857#p77857

We have been able to implement a new Method HasAlpha() for Class TImage too :-)

Now we have all that we need to have full AlphaBlend support in FiveWin :-)

Still we need to decide the best way to offer this functionality, as we don't want to force the use of FreeImage.dll unless the application wants to use other graphic formats different from bitmaps like PNGs, etc.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Sun Mar 29, 2009 5:09 pm

A little example:

test.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oImg

   LoadFreeImage()

   // DEFINE IMAGE oImg FILENAME "c:\fwh\bitmaps\arrow.bmp" // No alpha

   DEFINE IMAGE oImg FILENAME "c:\fwh\bitmaps\AlphaBmp\world.bmp" // with alpha

   MsgInfo( oImg:HasAlpha() )

   oImg:End()

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Sun Mar 29, 2009 5:10 pm

For those of you that want to test this new Class TImage Method HasAlpha(), we can publish the required changes here, if you want to :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Sun Mar 29, 2009 11:31 pm

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Full AlphaBlend support for FWH !!!

Postby lailton.webmaster » Sun Mar 29, 2009 11:36 pm

Congratulations very cool :)
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Full AlphaBlend support for FWH !!!

Postby nageswaragunupudi » Mon Mar 30, 2009 3:45 am

Mr Antonio

>
For those of you that want to test this new Class TImage Method HasAlpha(), we can publish the required changes here, if you want to
>

We shall be glad if you can post the changes to enable us to test / use the new method.

Can this method be included in TBitmap class also ?

Can we ask you for a sample source of how the above button bar and buttons are defined ? Can we use a buttonbar like the example with the changes for the TImage class ?

Thanks in advance
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Full AlphaBlend support for FWH !!!

Postby anserkk » Mon Mar 30, 2009 4:50 am

For those of you that want to test this new Class TImage Method HasAlpha(), we can publish the required changes here, if you want to


Dear Mr.Antonio,

It would be nice If you publish the requied changes, so that we can test. :D
This is going to be a very important improvement in the aesthetic segment of FiveWin applications.

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Mon Mar 30, 2009 10:19 am

These are the changes (diff file) from previous image.prg and modified image.prg:

diff.exe -c image_old.prg image_new.prg
Code: Select all  Expand view

*** 20,25 ****
--- 20,26 ----
  CLASS TImage FROM TBitmap
 
     DATA nProgress
+    DATA hDib
 
     CLASSDATA lRegistered AS LOGICAL
 
***************
*** 35,40 ****
--- 36,43 ----
     METHOD Progress( lProgress )
     
     METHOD LoadFromMemory( cBuffer )
+    
+    METHOD HasAlpha() INLINE FIISTRANSPARENT( ::hDib )
 
  ENDCLASS
 
***************
*** 79,85 ****
 
     if ! Empty( cBmpFile ) .and. File( cBmpFile )
        ::cBmpFile = cBmpFile
!       ::hBitmap = FILoadImg( AllTrim( cBmpFile ) )
     endif
 
     if ::hBitmap != 0
--- 82,88 ----
 
     if ! Empty( cBmpFile ) .and. File( cBmpFile )
        ::cBmpFile = cBmpFile
!       ::hBitmap = FILoadImg( AllTrim( cBmpFile ), Self )
     endif
 
     if ::hBitmap != 0
***************
*** 106,112 ****
        lChanged   = .t.
        cBmpFile   = nil
     elseif File( cBmpFile )
!       ::hBitmap = FILoadImg( AllTrim( cBmpFile ) )
        lChanged  := .t.
        cResName  := nil
     endif
--- 109,115 ----
        lChanged   = .t.
        cBmpFile   = nil
     elseif File( cBmpFile )
!       ::hBitmap = FILoadImg( AllTrim( cBmpFile ), Self )
        lChanged  := .t.
        cResName  := nil
     endif
***************
*** 183,193 ****
  #define CBM_INIT       4
  #define DIB_RGB_COLORS 0
 
! static function FILOADIMG( cFile )
 
     local nFormat, hDib, hInfoH, hInfo, hBits, hWnd, hDC, hBmp
 
     if Upper( cFileExt( cFile ) ) = "BMP"
        return ReadBitmap( 0, cFile )
     endif
 
--- 186,198 ----
  #define CBM_INIT       4
  #define DIB_RGB_COLORS 0
 
! static function FILOADIMG( cFile, oImage )
 
     local nFormat, hDib, hInfoH, hInfo, hBits, hWnd, hDC, hBmp
 
     if Upper( cFileExt( cFile ) ) = "BMP"
+       nFormat = FIGETFILETYPE( cFile, 0 )
+       oImage:hDib = FILOAD( nFormat, cFile, 0 )
        return ReadBitmap( 0, cFile )
     endif
 
***************
*** 203,209 ****
     endif
 
     nFormat = FIGETFILETYPE( cFile, 0 )
!    hDib    = FILOAD( nFormat, cFile, 0 )
     hInfoH  = FIGETINFOHEADER( hDib )
     hInfo   = FIGETINFO( hDib )
     hBits   = FIGETBITS( hDib )
--- 208,214 ----
     endif
 
     nFormat = FIGETFILETYPE( cFile, 0 )
!    oImage:hDib = FILOAD( nFormat, cFile, 0 )
     hInfoH  = FIGETINFOHEADER( hDib )
     hInfo   = FIGETINFO( hDib )
     hBits   = FIGETBITS( hDib )
***************
*** 212,218 ****
     #ifdef __CLIPPER__
        hDC = GETDC32( hWnd )
     #else
!      hDC = GETDC( hWnd )
     #endif
 
     hBmp = CreateDiBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )
--- 217,223 ----
     #ifdef __CLIPPER__
        hDC = GETDC32( hWnd )
     #else
!       hDC = GETDC( hWnd )
     #endif
 
     hBmp = CreateDiBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )
***************
*** 381,396 ****
  DLL32 FUNCTION WOWHANDLE16( nHandle AS LONG, nHandleType AS LONG ) AS LONG ;
        PASCAL FROM "WOWHandle16" LIB "wow32.dll"
 
! DLL32 STATIC FUNCTION FI_OpenMemory( cData AS LPSTR, nSize AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_OpenMemory@8" LIB hLib
 
! DLL32 STATIC FUNCTION FI_LoadFromMemory( nFormat AS LONG, nStream AS LONG, nFlags AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_LoadFromMemory@12" LIB hLib
 
! DLL32 STATIC FUNCTION FI_CloseMemory( nStream AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_CloseMemory@4" LIB hLib
 
! DLL32 STATIC FUNCTION FI_GetFileTypeFromMemory( nStream AS LONG, nSize AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_GetFileTypeFromMemory@8" LIB hLib
!
  //----------------------------------------------------------------------------//
--- 386,401 ----
  DLL32 FUNCTION WOWHANDLE16( nHandle AS LONG, nHandleType AS LONG ) AS LONG ;
        PASCAL FROM "WOWHandle16" LIB "wow32.dll"
 
! DLL32 FUNCTION FI_OpenMemory( cData AS LPSTR, nSize AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_OpenMemory@8" LIB hLib
 
! DLL32 FUNCTION FI_LoadFromMemory( nFormat AS LONG, nStream AS LONG, nFlags AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_LoadFromMemory@12" LIB hLib
 
! DLL32 FUNCTION FI_CloseMemory( nStream AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_CloseMemory@4" LIB hLib
 
! DLL32 FUNCTION FI_GetFileTypeFromMemory( nStream AS LONG, nSize AS LONG ) AS LONG ;
        PASCAL FROM "_FreeImage_GetFileTypeFromMemory@8" LIB hLib
!      
  //----------------------------------------------------------------------------//
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Mon Mar 30, 2009 10:25 am

Rao,

> Can this method be included in TBitmap class also ?

Yes, very good idea. Thanks! :-)

METHOD HasAlpha() INLINE HasAlpha( ::hBitmap )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Full AlphaBlend support for FWH !!!

Postby Adolfo » Tue Mar 31, 2009 3:35 pm

Antonio

Donde esta el cambio en estas lineas

Code: Select all  Expand view
***************
*** 212,218 ****
     #ifdef __CLIPPER__
        hDC = GETDC32( hWnd )
     #else
!      hDC = GETDC( hWnd )
     #endif
 
     hBmp = CreateDiBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )
--- 217,223 ----
     #ifdef __CLIPPER__
        hDC = GETDC32( hWnd )
     #else
!       hDC = GETDC( hWnd )
     #endif
 
     hBmp = CreateDiBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )
***************


Estos cambios (en general ) permitirian el uso de los ALPHAen las clases TBITMAP, TIMAGE, ButtonBar, BtnBMP... estoy en lo correcto?

Saludos
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Full AlphaBlend support for FWH !!!

Postby Antonio Linares » Tue Mar 31, 2009 3:59 pm

Adolfo,

En esa sección, solo la línea que tiene una ! delante:

! hDC = GETDC( hWnd )

solo se le puso un espacio delante :-)

Esos cambios solo son para implementar el método HasAlpha() en la Clase TImage.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 84 guests