Display Alpha channel 32 bit BMP on ButtonBMP (Solved)

Display Alpha channel 32 bit BMP on ButtonBMP (Solved)

Postby anserkk » 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
Last edited by anserkk on Tue Jan 06, 2009 4:25 am, edited 1 time in total.
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby anserkk » Tue Dec 30, 2008 1: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
Code: Select all  Expand view  RUN
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
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby Antonio Linares » Tue Dec 30, 2008 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby anserkk » Fri Jan 02, 2009 7: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)

Code: Select all  Expand view  RUN
@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  Expand view  RUN
@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  Expand view  RUN
AnsTest              BITMAP  Images\AnsTest.Bmp
#ifdef __FLAT__
  1 24 "Images/WindowsXP.Manifest"
#endif


Regards

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby Antonio Linares » Fri Jan 02, 2009 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby anserkk » Fri Jan 02, 2009 9: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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby anserkk » 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


Code: Select all  Expand view  RUN
      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
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby Antonio Linares » Sat Jan 03, 2009 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby anserkk » Sat Jan 03, 2009 8: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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby Antonio Linares » Sat Jan 03, 2009 8:29 am

regards, saludos

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby Antonio Linares » Sat Jan 03, 2009 8:35 am

regards, saludos

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

Re: Display Alpha channel 32 bit BMP on ButtonBMP

Postby anserkk » Sat Jan 03, 2009 9:21 am

Thankyou Mr.Antonio,

Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests