FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Sun Jul 12, 2009 08:37 PM
Hello,

I tested all Options for Dialogs.
The Result : Say on Image- and Gradient-Background not transparent.
Maybe something has to be done different in FWH 9.06 ???

All possible Tests ( 40 ).
Group Dialog with Alpha-Blended BMP and Say tested.
Transparent SAY on Image still missing ?












Code (fw): Select all Collapse
// nArraypos = Browser-Test !!!!!!
...
DEFINE DIALOG oDlg5 RESOURCE "Test_Dlg" STYLE nSTYLE TRANSPARENT ;
TITLE  "Testing Dialog-Backgrounds" FONT oFont

REDEFINE SAY oSay1 prompt "This is a Transparent-Test" ID 210  of oDlg5 COLOR 128 PIXEL  transparent adjust
oSay1:SetFont(oProgFont2)

// Color
// -------
IF nArrayPos = 2 .or. nArrayPos = 7
   D_COLOR( oDlg5 )   
ENDIF

// ImageBrush
// ----------------
IF nArrayPos = 3 .or. nArrayPos = 8
   DB_IMAGE( oDlg5 ) 
ENDIF

// Style-Brush
IF nArrayPos = 4 .or. nArrayPos = 9
   D_BRUSH( oDlg5 ) 
ENDIF

REDEFINE BUTTONBMP oButton  ID 30 OF oDlg5 ;
ACTION oDlg5:End() ;
BITMAP "Quit" PROMPT "   Exit" TEXTRIGHT

ACTIVATE DIALOG oDlg5 CENTERED  ;
ON INIT ( DLG_BAR( oDlg5 ), IIF( nArrayPos = 1 .or. nArrayPos = 6, ;
   GradBrush( oDlg5, { { 0.90,11892819,16777215 },{ 0.90,16777215,11892819 } }, .T. ), NIL ) ) ;    
ON PAINT ( IIF( nArrayPos = 5 .or. nArrayPos = 10, DL_IMAGE( oDlg5, hDC ), NIL ), ;  // Image
            IIF( nArrayPos > 5, D_ALPHA( hDC ), NIL ) )

oProgFont1:End()
oProgFont2:End()

RETURN(  NIL )

//--------- IMAGE - LOGO ------------------------ 

STATIC FUNCTION DL_IMAGE( oDlg5, hDC ) 
LOCAL oImage1
LOCAL nWidth  := oDlg5:nWidth()
LOCAL nHeight := oDlg5:nHeight()

DEFINE IMAGE oImage1 FILE c_path + "\images\FANTASY7.jpg" 
PalBmpDraw( hDC, 0, 0, oImage1:hBitmap, , nWIDTH, nHEIGHT, , .T. ) 
oDlg5:ReleaseDC()

RETURN NIL

//--------- IMAGE - BRUSH ------------------------ 

STATIC FUNCTION DB_IMAGE( oDlg5 ) 
LOCAL oImage1

DEFINE BRUSH oImage1 FILE c_path + "\images\BLUSTONE.bmp"
SET BRUSH OF oDlg5 TO oImage1
RELEASE BRUSH oImage1

RETURN NIL

//-------- STYLE- BRUSH ------------------------- 

STATIC FUNCTION D_BRUSH( oDlg5 ) 
LOCAL oNewbrush

DEFINE BRUSH oNewBrush  STYLE "BRICKS"   
SET BRUSH OF oWnd TO oNewBrush
RELEASE BRUSH oNewbrush

RETURN NIL

// --------- GRADIENT  --------------------------------------

FUNCTION GradBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight

DEFAULT lDir := .T.

if Empty( oDlg:oBrush:hBitmap )
      nHeight := if(lDir,oDlg:nHeight,1)
      nWidth  := if(lDir,1,oDlg:nWidth)
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
endif

RETURN NIL

// --------- COLORS  --------------------------------------

STATIC FUNCTION D_COLOR( oDlg5 )
local oBrush1

DEFINE BRUSH oBrush1 COLOR 16228426   // Blue
SET BRUSH OF oDlg5 TO oBrush1
RELEASE BRUSH oBrush1

RETURN NIL

// --------- ALPHA-BMP  --------------------------------------

STATIC FUNCTION D_ALPHA( hDC )
LOCAL oBmp1 

DEFINE BITMAP oBmp1 FILENAME c_path + "\images\A_LOGO.BMP"
ABPaint( hDC, 30, 50, oBmp1:hBitmap, 220 )

RETURN NIL


Best 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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 07:12 AM
FWH 9.06. Transparent Text on Dialogs with Image as background is as simple as these few lines of code:
Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   local oDlg, oBrush, oFont

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-30
   DEFINE BRUSH oBrush FILE 'c:\fwh\bitmaps\olga1.jpg'

   DEFINE DIALOG oDlg SIZE 400,400 PIXEL FONT oFont BRUSH oBrush TRANSPARENT

   @ 20,20 SAY 'OLGA1.JPG' COLOR CLR_WHITE, CLR_BLACK ;
      SIZE 160,24 PIXEL OF oDlg TRANSPARENT CENTERED

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE BRUSH oBrush

return nil


Result:

Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 07:25 AM
Rao,

thank You for the Information but it is a tiled Brush and not a adjusted Image
like You also can see on Your screenshot ( maybe a Brush-define adjusted ? ).

DEFINE DIALOG oDlg SIZE 400,400 PIXEL FONT oFont BRUSH oBrush TRANSPARENT

Best 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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 07:27 AM

You can adjust the size. As done by xbrowse. From there we can find out how to do it.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 07:33 AM
ok. let me do it. after i finish some work on hand

Here is the code
Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   local oDlg, oBrush, oTmp, oFont

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-30
   DEFINE BRUSH oTmp FILE 'c:\fwh\bitmaps\olga1.jpg'

   oBrush   := TBrush():New( ,,,, ResizeBmp( oTmp:hBitmap, 400, 300 ) )
   oTmp:End()

   DEFINE DIALOG oDlg SIZE 400,300 PIXEL FONT oFont BRUSH oBrush

   @ 20,20 SAY 'OLGA1.JPG' COLOR CLR_WHITE, CLR_BLACK ;
      SIZE 180,24 PIXEL OF oDlg TRANSPARENT CENTERED

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE BRUSH oBrush

return nil



Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 08:34 AM
I added a new method to my personal copy of Brush.Prg
Code (fw): Select all Collapse
METHOD Resize( x, y ) CLASS TBrush

   local hBmp     := ResizeBmp( ::hBitmap, x, y )

   DeleteObject( ::hBitmap )
   DeleteObject( ::hBrush  )

   ::hBitmap      := hBmp
   ::hBrush       := CreatePatternBrush( ::hBitmap )

return Self

With this, the above code looks even simpler
Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   local oDlg, oBrush, oTmp, oFont

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-30
   DEFINE BRUSH oBrush FILE 'c:\fwh\bitmaps\olga1.jpg'

   oBrush   := oBrush:Resize( 400, 300 )

   DEFINE DIALOG oDlg SIZE 400,300 PIXEL FONT oFont BRUSH oBrush

   @ 20,20 SAY 'OLGA1.JPG' COLOR CLR_WHITE, CLR_BLACK ;
      SIZE 180,24 PIXEL OF oDlg TRANSPARENT CENTERED

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE BRUSH oBrush

return nil

Same result as above.
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 10:39 AM
Thank You very much,

In new FWH 9.06 ( I just tested )

* Enhancements: Class TBrush
a. Now any image file ( jpg, png, etc. ) can be used to create a Brush.
b. Brush can also be created from a bitmap handle by specifying the handle as the fifth parameter of TBrush():New() method. Command support for this is not provided.

It keeps the Image-quality.
Still Your Resize : METHOD Resize( x, y ) CLASS TBrush
I have to test.



Using :
ResizeBmp( oBrush:hBitmap, 750, 550 )
Reduces the Image-Quality


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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 11:47 AM
  1. Please do not use my method. I have not tested it well. it is just a prototype. We still need to take care of the ncount data and a few more issues are there.

  2. Issue of quality is the same whatever method you use for resizing. It is always a good idea to choose a larger image of similar proportions to start with.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 12:17 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
RELEASE BRUSH oBrush


As far as I know, you don't have to explicitly release the brush. Once you have assigned it to the DIALOG then the DIALOG itself become the owner of the brush and it is its responsibility to release it.

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 02:14 PM

Enrico,

It is needed to RELEASE it, as the brush uses a counter that gets incremented when assigned to a windows/dialog/control and when they are destroyed the counter is decreased, but only when the counter is zero then the GDI object gets releally deleted.

So for each DEFINE BRUSH ... it is a required a oBrush:End() or a RELEASE BRUSH oBrush

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Mon Jul 13, 2009 06:25 PM

Yes, but oBrush:End() is inside TWindow. Or am I wrong?

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Tue Jul 14, 2009 03:24 AM
This is really an important issue.
I like to bring to your notice, results of my quick test about the TBrush():nCount ( internal counter.). It does not appear to be working the way it was intended to.

This is my test code:
Code (fw): Select all Collapse
   DEFINE BRUSH oBrush STYLE CROSS
   AAdd( aCount, { 'After Creation', oBrush:nCount } )

   DEFINE DIALOG oDlg BRUSH oBrush
   AAdd( aCount, { 'After Define Dialog', oBrush:nCount } )

   ACTIVATE DIALOG oDlg CENTERED ON RIGHT CLICK ;
      AAdd( aCount, { 'Inside Dialog', oBrush:nCount } )

   AAdd( aCount, { 'After Dlg Exit', oBrush:nCount } )

   oBrush:End()
   AAdd( aCount, { 'After oBrush:End()', oBrush:nCount } )

   xbrowse( aCount )

Results :
After Creation 1
After Define Dialog 2
Inside Dialog 2
After Dlg Exit 2 // should have been 1
After oBrush:End() 1 // should have been 0

The intention of the design was that Window increments the count and decrements th e count while exiting. We have to release the Brush what we create ourselves to finally destroy it. But this is not working as intended.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Tue Jul 14, 2009 04:31 AM

This is the same behavior with Font objects also.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Tue Jul 14, 2009 05:57 AM

Enrico, Rao,

When we do:

DEFINE BRUSH oBrush // oBrush counter is 1

DEFINE WINDOW oWnd BRUSH oBrush // oBrush counter is 2

oWnd ends // oBrush counter is 1

oBrush:End() // counter decreases to zero and the GDI object is finally really deleted

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?
Posted: Tue Jul 14, 2009 06:02 AM
Please run this test so you will understand how the counter works:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd, oBrush

   DEFINE BRUSH oBrush COLOR CLR_BLUE

   MsgInfo( oBrush:nCount, "after creating the brush" )

   DEFINE WINDOW oWnd BRUSH oBrush

   MsgInfo( oBrush:nCount, "after asigning it to the window" )

   ACTIVATE WINDOW oWnd

   MsgInfo( oBrush:nCount, "after destroying the window" )

   oBrush:End()

   MsgInfo( oBrush:nCount, "after destrying the brush" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com