Special effects with Alpha-Blended Bitmaps

Special effects with Alpha-Blended Bitmaps

Postby ukoenig » Mon May 26, 2008 8:39 pm

Hello,

I want to use the Alpha-BMP's for special effects
I use it on dialog-infos
It is a combination of "normal" and Alpha-Bitmaps

Fire
Image

Glow
Image

Shadow
Image

I have to adjust the Alpha-Bitmap, but in the function
ABPaint is nothing to define bottom and right
only top and left.
How can i adjust a Alpha-Bitmap ( stretch ) ?

ABPaint( hDC, 2, 2, oBmp2:hBitmap, 255 )

Regards

Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Antonio Linares » Mon May 26, 2008 11:02 pm

Uwe,

ABPaint() automatically calculates the dimensions of the bitmap.
regards, saludos

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

Why Resizing Alpha-Blended-Bitmaps

Postby ukoenig » Tue May 27, 2008 8:36 am

The reason for resizing :
It works with different levels.

1. The resource with the dimension
Image

2. A normal BMP from resource resized and filled
with background and text
Image

3. Result from No. 2
Image

aRect := GETCLIENTRECT( oBmp:hWnd )
nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .T. )
oBmp:oBrush := TBrush():New( , nGRADIENT )
SetBkMode( oBmp:hDC, 0 )
FillRect( hDC, aRect, oBmp:oBrush:hBrush )

4. A constructed Alphablended BMP
has to be resized and calculated, to fit as background No. 3
Without resizing, a have to create allways a extra Alpha-BMP
with the dimension for No. 3

Image

5. The End-result
Image

Regards
Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Antonio Linares » Tue May 27, 2008 9:15 am

Uwe,

We can add more parameters to ABPaint() if you need them
regards, saludos

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

Alpha-BMP

Postby ukoenig » Tue May 27, 2008 9:42 am

Antonio, thank you very much

To have Bottom and Right as well,
like the other BMP's, i could design a frame.
Then there are still other things possible.

Just a underline

Image

Code: Select all  Expand view
FUNCTION ONPAINT(oDlg1,hDC,oBmp,nVColor, nBColor,nColor,cText, ;
                             oBFont,nPOSLEFT, nEND, nORIENT,cBRUSH, nPEN )
LOCAL hOldFont, oNewbrush, hBitmap, aRect, oBmp1, nTOP, nLEFT
LOCAL oBmp2, nCENTER

hOldFont := SelectObject( hDC, oBFont:hFont )

nTXTLG :=  GettextWidth( hDC, cText )

nBMPLONG  := oBmp:Super:nWidth()
nBMPHIGHT := oBmp:Super:nHeight()
nFONTHIGHT := e_oBfont1:nInpHeight * -1
IF nPOSLEFT = 0
   nLEFT := (nBMPLONG - nTXTLG) / 2
ELSE
        nLEFT := nPOSLEFT
ENDIF
nNEWHIGHT := nFONTHIGHT

nTOP := (nBMPHIGHT - nNEWHIGHT) / 2

aRect := GETCLIENTRECT( oBmp:hWnd )

nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .T. )  // .T.  Horizontal
oBmp:oBrush := TBrush():New( , nGRADIENT ) 

SetTextColor( hDC,nColor)
SetBkMode( oBmp:hDC, 0 )

FillRect( hDC, aRect, oBmp:oBrush:hBrush )

TextOut( hDC, nTOP, nLEFT, cText )
SelectObject( hDC, hOldFont )

// A simple border
// --------------------
IF nPEN > 0
   DRAWBOX( aRect, hDC, nColor, nBMPLONG, nBMPHIGHT, B_PEN )
ENDIF

// Alphablended underline-bmp
// -------------------------------------
DEFINE BITMAP oBmp2 FILENAME "Underline.bmp"

// We have to get the DC from the dialog.
// Then we have to paint the underline-bmp in relation to
// the < dialog-info-BMP-position >
// The position of the BMP-resource comes from
// TControl  oBmp:nTop  and  oBmp:nLeft
// now we can calculate the needed position for the
// underline-BMP



The needed dimensions from TControl :
The Top- and Left-position of a resource inside of a dialog

Image

Code: Select all  Expand view
nBlendTop := oBmp:nTop + nBMPHIGHT + 10
nBlendLeft := oBmp:nLeft - 10
// 10 = Distance between bottom of BMP and Top of Underline-BMP
// and left position of Underline-BMP
// we still have to adjust the length and hight of the underline
// for that we need a Right and Bottom for < ABPaint >

ABPaint( oDlg1:GetDC(), Left, Top, Right, Bottom, oBmp2:hBitmap, 255 )
// 0-255 transparency level

// The new Bottom and Right are needed for adjustment to Dialog-Info
//-------------------------------------------------------------------------------

RETURN NIL




Best Regards

Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], karinha, nageswaragunupudi and 97 guests