Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby ukoenig » Sun Jul 12, 2009 8: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 ?
Image

Image

Image

Image

Image

Image

Code: Select all  Expand view

// 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 :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

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » Mon Jul 13, 2009 7:12 am

FWH 9.06. Transparent Text on Dialogs with Image as background is as simple as these few lines of code:
Code: Select all  Expand view
#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:

Image
Last edited by nageswaragunupudi on Mon Jul 13, 2009 7:26 am, edited 1 time in total.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby ukoenig » Mon Jul 13, 2009 7: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 :lol:
Last edited by ukoenig on Mon Jul 13, 2009 7:28 am, edited 1 time in total.
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

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » Mon Jul 13, 2009 7: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
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » Mon Jul 13, 2009 7:33 am

ok. let me do it. after i finish some work on hand

Here is the code
Code: Select all  Expand view
#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
 



Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » Mon Jul 13, 2009 8:34 am

I added a new method to my personal copy of Brush.Prg
Code: Select all  Expand view
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: Select all  Expand view
#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
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby ukoenig » 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.

Image

Using :
ResizeBmp( oBrush:hBitmap, 750, 550 )
Reduces the Image-Quality
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

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby Enrico Maria Giordano » Mon Jul 13, 2009 12:17 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

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

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby Enrico Maria Giordano » Mon Jul 13, 2009 6:25 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » Tue Jul 14, 2009 3: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: Select all  Expand view
  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
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby nageswaragunupudi » Tue Jul 14, 2009 4:31 am

This is the same behavior with Font objects also.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

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

Re: Missing transp. SAY on Img. in Dialogs ( FWH 9.06 ) ?

Postby Antonio Linares » Tue Jul 14, 2009 6:02 am

Please run this test so you will understand how the counter works:
Code: Select all  Expand view

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 43 guests