FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Display Alpha channel 32 bit BMP on ButtonBMP (Solved)
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Display Alpha channel 32 bit BMP on ButtonBMP (Solved)
Posted: Tue Dec 30, 2008 12:17 PM

Hi,

I understand that Borland Resource Compiler does not support Alpha channel BMP's, I have used "Pelles C" resource compiler to compile the .RC file without any error's.

Unfortunately the ButtonBMP is not displaying the image. (No errors).

I hope ButtonBMP support's 32bit Alpha BMP's.

Any hint?

Regards

Anser

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Tue Dec 30, 2008 12:49 PM

Anser,

CLASS TButtonBmp METHOD Paint() calls DrawMasked() to paint the bitmap.

If you change that call into ABPaint(), as used in FWH\samples\TestAB.prg then you may be able to use the Alpha channel :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Tue Dec 30, 2008 01:14 PM
Dear Mr.Antonio,

Anser,

CLASS TButtonBmp METHOD Paint() calls DrawMasked() to paint the bitmap.

If you change that call into ABPaint(), as used un FWH\samples\TestAB.prg then you may be able to use the Alpha channel


Does it mean that I have to change the code in ButtonB.prg ?

Or is there a way to do it without changing the source code of the Class TButtonBmp ?

TestAb.Prg
ACTIVATE WINDOW oWnd ;
      ON PAINT ABPaint( hDC, 10, 10, oBmp:hBitmap, 220 ) // 0-255 transparency level


Like we call ON PAINT while ACTIVATE WINDOW is there a way to call the ButtonBMP's paint method ?


Regards

Anser
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Tue Dec 30, 2008 01:53 PM

Anser,

> Does it mean that I have to change the code in ButtonB.prg ?

yes, thats what I meant

> Or is there a way to do it without changing the source code of the Class TButtonBmp ?

xharbour allows to replace a Class Method without modifying the class original source code.

Please make a search for OVERRIDE METHOD in these forums :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Fri Jan 02, 2009 07:56 AM
I am little bit confused regarding the display of Alpha Channel BMP on a BUTTONBMP control

The following code is dispalying Alpha Channel BMP (I have used the FileName)

@14.3,05 BUTTONBMP oBtnCancel PROMPT "Close" OF oDlg TEXTRIGHT BITMAP "Images/AnsTest.Bmp" ;
   SIZE 50,15 ACTION oDlg:End()


But if I use ResourceName instead of the file name then it will not display the AlphaChannel BMP

@14.3,05 BUTTONBMP oBtnCancel PROMPT "Close" OF oDlg TEXTRIGHT BITMAP "AnsTest" ;
   SIZE 50,15 ACTION oDlg:End()


I have not used ABPaint(). (I have not modified the original class) Any hint why filename is working and resource name is not working ?

My .RC
AnsTest              BITMAP  Images\AnsTest.Bmp
#ifdef __FLAT__
  1 24 "Images/WindowsXP.Manifest"
#endif


Regards

Anser
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Fri Jan 02, 2009 09:12 AM

Anser,

Try to export the bitmap from the resource file to an external file and check if the alpha channel remains active.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Fri Jan 02, 2009 09:56 AM

Dear Mr.Antonio,

I exported the BMP from my .RES file using the Resource Editor ResEdit.

When I checked the exported BMP file using Adobe PhotoShop CS3, I found that Alpha Channel exists in this BMP.

As I am not an expert in Graphic formats, I compared the properties of this particular BMP with some of the files contained in the folder \FWH\Bitmaps\AlphaBmp. It appears to be the same.

Regards

Anser

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Fri Jan 02, 2009 10:10 AM

Anser,

Then you may need to use ABPaint() as we have commented you.

When a bitmap is loaded from disk, we manage it with our own code. But when it is loaded from resources, we use Windows APIs own code. Thats where the difference may come from.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Fri Jan 02, 2009 10:12 AM

Thankyou Mr.Antonio,

I shall try as you suggested and shall let you know the result.

Regards

Anser

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Fri Jan 02, 2009 10:29 AM
Dear Mr.Antonio,

I tried replacing DrawMasked() with ABPaint() in the METHOD Paint() of TButtonBMP (ButtonB.Prg), unfortunately the picture is not getting displayed on ButtonBMP


      if ::lActive
       /*  DrawMasked( ::hDC, ::hBitmap, nTop + If( lPressed, 1, 0 ),;
                     nLeft + If( lPressed, 1, 0 ) )   */
         ABPaint( ::hDC,  nTop + If( lPressed, 1, 0 ), nLeft + If( lPressed, 1, 0 ) , ::hBitmap, 220 )
      else
         DrawGray( ::hDC, ::hBitmap, nTop + If( lPressed, 1, 0 ),;
                     nLeft + If( lPressed, 1, 0 ) )
      endif


This is the download link of the BMP file. I tried ImageShack but after uploading BMP will get converted to PNG
http://rapidshare.com/files/178967440/AnsTest.bmp.html

Regards

Anser
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Sat Jan 03, 2009 08:14 AM

Anser,

It seems as we are facing the same problem again. Your bitmap is loaded from resources, isn't it ?

Windows API seems not to be respecting the alpha channel when loading it from resources.

But our function DibRead() does respect it.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Sat Jan 03, 2009 08:23 AM
Your bitmap is loaded from resources, isn't it ?


Yes, Mr.Antonio

Windows API seems not to be respecting the alpha channel when loading it from resources.


So sad

Regards

Anser
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Sat Jan 03, 2009 08:29 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Sat Jan 03, 2009 08:35 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Display Alpha channel 32 bit BMP on ButtonBMP
Posted: Sat Jan 03, 2009 09:21 AM

Thankyou Mr.Antonio,

Regards

Anser