Display Alpha channel 32 bit BMP on ButtonBMP (Solved)

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

Display Alpha channel 32 bit BMP on ButtonBMP (Solved)

Post by anserkk »

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
Last edited by anserkk on Tue Jan 06, 2009 4:25 am, edited 1 time in total.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

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
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

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

Code: Select all

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

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
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

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)

Code: Select all

@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

Code: Select all

@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

Code: Select all

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

Anser
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

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
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

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
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

Thankyou Mr.Antonio,

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

Regards

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

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

Code: Select all

      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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

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
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

regards, saludos

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Post by anserkk »

Thankyou Mr.Antonio,

Regards

Anser
Post Reply