Transparent Png on MDI Parent

Transparent Png on MDI Parent

Postby byron.hopp » Wed May 08, 2024 7:41 pm

I have a Png file, it is suppose to be transparent, when I display it in an image editor it shows a checkered gray background. How can I make this transparent using @ Say Image. On Resize I move it so it always is in the lower right hand corner of the window. But I get the checkered background, not so pretty.
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Transparent Png on MDI Parent

Postby karinha » Wed May 08, 2024 8:28 pm

ZIP in a small example and put megaupload for testing.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Transparent Png on MDI Parent

Postby Antonio Linares » Thu May 09, 2024 2:04 pm

Dear Byron,

Please post the code you are using to paint it
regards, saludos

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

Re: Transparent Png on MDI Parent

Postby nageswaragunupudi » Thu May 09, 2024 2:08 pm

If using MDI window:
Code: Select all  Expand view
DEFINE WINDOW oWnd MDI
oWnd:oWndClient:bPainted := { || oWnd:oWndClient:DrawImage( "..\bitmaps\pngs\2.png",,,,,,"RB" ) }
ACTIVATE WINDOW oWnd CENTERED


For normal window
Code: Select all  Expand view
DEFINE WINDOW oWnd MDI
oWnd:bPainted := { || oWnd:DrawImage( "..\bitmaps\pngs\2.png",,,,,,"RB" ) }
ACTIVATE WINDOW oWnd CENTERED
Regards

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

Re: Transparent Png on MDI Parent

Postby byron.hopp » Fri May 10, 2024 7:38 pm

Seems to depend on the bitmap, this code works for some bitmaps, I have also used @ 0,0 Bitmap...
...main program
@ 0,0 Image oLogo File Mcs_AppPath() + "Images\SqlServerLogo.bmp" Of oWnd:oWndClient No Border
ACTIVATE WINDOW oWnd VALID MCS_EXIT(oWnd,cPath,pPRG_ABRV) ON INIT OpenMast() On Resize SetLogo( oLogo,oWnd )
RETURN (NIL)

Function SetLogo( oLogo,oWnd )
Local nX,nY
oWnd:CoorsUpdate()
oWnd:oWndClient:CoorsUpdate()
oLogo:CoorsUpdate()
oLogo:Hide()
nX := oWnd:oWndClient:nWidth() - oLogo:nWidth()
nY := oWnd:oWndClient:nHeight() - oLogo:nHeight()
oLogo:Move( nY,nX,oLogo:nWidth(),oLogo:nHeight(),.t. )
oLogo:Show()
return NIL
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Transparent Png on MDI Parent

Postby karinha » Sat May 11, 2024 10:23 am

Code: Select all  Expand view

#include "FiveWin.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL oIco, oBar, oBmp, oLogo

   DEFINE ICON oIco FILE "..\icons\fax.ico"

   DEFINE WINDOW oWnd MDI FROM 1, 1 TO 22, 75 TITLE "Byron Logo" ;
      MENU  BuildMenu() COLOR "B/W" ICON oIco

   DEFINE BUTTONBAR oBar _3D SIZE 26, 27 OF oWnd

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\new.bmp" FLAT ;
      ACTION MsgInfo( "New" ) ;
      TOOLTIP "Creates a new document"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\open.bmp" FLAT ;
      ACTION MsgInfo( cGetFile( "*.*", "Select a document to open" ) ) ;
      TOOLTIP "Opens a document" WHEN .F.

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT ;
      ACTION MsgInfo( Time() ) TOOLTIP "Saves this document"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\printer.bmp" FLAT ;
      ACTION MsgInfo( "Prints this document" ) TOOLTIP "Print this document" GROUP

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\prop.bmp" FLAT ;
      ACTION PrinterSetup() TOOLTIP "Setup the printer"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\HelpInd.bmp" FLAT ;
      ACTION MsgInfo( Version() ) TOOLTIP "A multiple lines" + ;
      Chr( 13 ) + Chr( 10 ) + "tooltip!" GROUP

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Help.bmp" FLAT ;
      ACTION MsgInfo( "fivewin power!" ) TOOLTIP "fivewin power!"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT ;
      ACTION( oWnd:End() ) TOOLTIP "Exit this app" GROUP

   DEFINE MESSAGE OF oWnd ;
      PROMPT FWVERSION + " " + FWCOPYRIGHT ;
      NOINSET CENTERED KEYBOARD DATE CLOCK

   DEFINE BITMAP oBmp FILENAME "..\bitmaps\pngs\dvd.png"
   // DEFINE BITMAP oBmp FILENAME "..\bitmaps\sea.bmp"

   oWnd:bPainted = {| hDC | BmpTiled( hDC, oWnd, oBmp ) }

   @ 0, 0 Image oLogo FILE ".\Logo.jpg" Of oWnd:oWndClient No Border

   ACTIVATE WINDOW oWnd ;
      ON RESIZE SetLogo( oLogo, oWnd )

RETURN NIL

FUNCTION SetLogo( oLogo, oWnd )

   LOCAL nX, nY

   oWnd:CoorsUpdate()
   oWnd:oWndClient:CoorsUpdate()

   oLogo:CoorsUpdate()
   oLogo:Hide()

   nX := oWnd:oWndClient:nWidth() - oLogo:nWidth()
   nY := oWnd:oWndClient:nHeight() - oLogo:nHeight()

   oLogo:Move( nY, nX, oLogo:nWidth(), oLogo:nHeight(), .T. )
   oLogo:Show()

RETURN NIL

FUNCTION BuildMenu()

   LOCAL oMenu

   MENU oMenu
   MENUITEM "Information"
   MENU
   MENUITEM "&About..." ;
      ACTION MsgInfo( FWDESCRIPTION ) ;
      FILENAME "..\bitmaps\16x16\info.bmp"
   SEPARATOR
   MENUITEM "&End..."  ;
      ACTION( oWnd:End() ) ;
      FILENAME "..\bitmaps\16x16\exit.bmp"

   ENDMENU

   MENUITEM "&Clients"
   MENU
   MENUITEM "&New..." ;
      ACTION ( MsgStop( "New Clients" ), ;
      oWnd:Say( 5, 5, "New Clients...", "GR+/G" ) ) ;
      FILENAME "..\bitmaps\16x16\faces.bmp"

   MENUITEM "&Modify..."  ACTION MsgInfo( "Modif. Clients" ) ;
      FILENAME "..\bitmaps\edit.bmp"

   MENUITEM "&Delete..."  ACTION MsgAlert( "Del Clients" ) ;
      FILENAME "..\bitmaps\16x16\delete.bmp"

   SEPARATOR

   MENUITEM "&Browse..."  ACTION MsgInfo( "Browse Clients" ) ;
      FILENAME "..\bitmaps\16x16\browse.bmp"

   ENDMENU

   MENUITEM "&Utilities"
   MENU
   MENUITEM "&Calculator..." ACTION WinExec( "Calc" ) ;
      FILENAME "..\bitmaps\16x16\calc.bmp"

   MENUITEM "&Internet..." ;
      ACTION WinExec( "start iexplore www.fivetech.com", 0 ) ;
      FILENAME "..\bitmaps\16x16\explorer.bmp"
   ENDMENU

   ENDMENU

RETURN oMenu

STATIC FUNCTION BmpTiled( hDC, oWnd, oBmp )

   LOCAL nWidth := oWnd:nWidth(), nHeight := oWnd:nHeight()
   LOCAL nRow := 0, nCol := 0, n
   LOCAL nBmpWidth  := oBmp:nWidth(),  nBmpHeight := oBmp:nHeight()

   IF oBmp:hBitmap == 0
      RETURN NIL
   ENDIF

   WHILE nRow < nHeight
      nCol = 0
      WHILE nCol < nWidth
         PalBmpDraw( hDC, nRow, nCol, oBmp:hBitmap )
         nCol += nBmpWidth
      END
      nRow += nBmpHeight
   END

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Transparent Png on MDI Parent

Postby nageswaragunupudi » Mon May 13, 2024 4:59 am

I once again repeat please.
As I suggested above, the method oWnd:DrawImage(...) is the best suited for this purpose.
Please DO NOT create controls like BITMAP,IMAGE,XIMAGE etc.

Please test this example in samples folder:
I have used one Png to display at bottom-right and another at bottom-left.
Window can be resized.
When the window is resized to a very small size, even these pngs get resized correspondingly.
Also please note the transparent rendering.

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oBrush, oBar
   local cPng1  := "..\bitmaps\pngs\2.png"
   local cPng2  := "..\bitmaps\pngs\pan_setting.png"

   DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\beach.bmp"
   DEFINE WINDOW oWnd MDI BRUSH oBrush TITLE "TRANSP LOGOS"
   DEFINE BUTTONBAR oBar OF oWnd 2007
   SET MESSAGE OF oWnd TO "" 2007

   oWnd:oWndClient:bPainted := { || ;
      oWnd:oWndClient:DrawImage( cPng1, { .6,.7,, },,,,, "RB" ), ;
      oWnd:oWndClient:DrawImage( cPng2,{,,,.2},,,,,"LB" ) }

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE BRUSH oBrush

return nil


Image
Regards

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

Re: Transparent Png on MDI Parent

Postby byron.hopp » Mon May 13, 2024 5:06 pm

Mr. Rao, yes that did it. I had to convert my app to a newer version of FiveWin and once I got that going it was good. Thanks so much for taking the time to explain.
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Transparent Png on MDI Parent

Postby nageswaragunupudi » Mon May 13, 2024 6:37 pm

byron.hopp wrote:Mr. Rao, yes that did it. I had to convert my app to a newer version of FiveWin and once I got that going it was good. Thanks so much for taking the time to explain.


What is your FWH version?
Regards

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

Re: Transparent Png on MDI Parent

Postby byron.hopp » Mon May 13, 2024 6:42 pm

#define FWCOPYRIGHT "(c) FiveTech Software, 1993-2023"

#define FWVERSION "FWH 23.07"
#define FW_VersionNo 23070
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Transparent Png on MDI Parent

Postby nageswaragunupudi » Mon May 13, 2024 7:11 pm

My sample works perfectly with your version.
You need not update.
In fact my sample works with much older versions also ( though not very very old)

Works with all versions of FWH from 2018 onwards
Regards

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

Re: Transparent Png on MDI Parent

Postby byron.hopp » Mon May 13, 2024 7:20 pm

No the version I sent you is the new, the other was xHb, I don't think it had the Method DrawImage. I am good now, your version works great, and seems better than what I was doing before. Thanks,
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 35 guests

cron