strange error with png files

strange error with png files

Postby Silvio.Falconi » Wed Jan 13, 2016 5:56 pm

friends,

I tried a small prg to show a background file png and two button ( btnbmp) with png file into a Wnd
I have some problems as you can see

the btnbmp are not transparent


Image






Code: Select all  Expand view  RUN
#include "FiveWin.ch"

 Static c_path,c_path1,oBackground

function Main()

   local oWnd
   local oBtn[2]


    c_path := cFilePath(GetModuleFileName( GetInstance() ) )
    c_path1 := c_Path + "IMAGES\"

    DEFINE IMAGE oBackground FILENAME c_path1 + "
Back.png"

     DEFINE WINDOW oWnd FROM 10, 10 TO 48,110



@ 200, 450 BTNBMP oBtn[1] OF oWnd  ;
SIZE 80, 80 ;
PROMPT "
";
NOBORDER ;
FILE c_Path1 + "
Pay.png" ;
ACTION MsgInfo("
Pay")
oBtn[1]:lEllipse := .T.
oBtn[1]:lTransparent := .T.

@ 350, 520 BTNBMP oBtn[2] OF oWnd  ;
SIZE 120, 80 ;
PROMPT "
";
NOBORDER ;
FILE c_Path1 + "
Spin.png" ;
ACTION MsgInfo("
spin")
oBtn[2]:lTransparent := .T.


 ACTIVATE WINDOW oWnd ;
           ON PAINT ( ABPaint( hDC, 50, 10, oBackground:hBitmap, 255 ) )

//    another test ON PAINT   PaintTransparent( hDC, oBackground:hBitmap, 0, 0 )

//-----------------------------------------------------------------------------//

 function PaintTransparent( hDC, hBitmap, nRow, nCol )

   local hBmpOld := SelectObject( hDC, hBitmap )
   local nZeroZeroClr := GetPixel( hDC, 0, 0 )
   local nOldClr

   SelectObject( hDC, hBmpOld )
   nOldClr = SetBkColor( hDC, nRGB( 255, 255, 255 ) )
   TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ),;
             nZeroZeroClr, hDC, nRow, nCol, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
   SetBkColor( hDC, nOldClr )

   return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange error with png files

Postby ukoenig » Wed Jan 13, 2016 8:43 pm

Silvio,

Painting a Button on top of a image doesn't work ( the transparent area shows the window-brush )

The following solution works, merging 2 images for brush usage

Using PIXELFORMER

1. load and copy the needed image
2. create a new image with the window-size and wanted backgound-color
3. past the copied image
4. save the new merged image as new image
5. use it as a wnd-brush

DEFINE BRUSH oBrush1 FILENAME c_path1 + "Backgrd.png"
DEFINE WINDOW oWnd FROM 50, 50 TO 600, 800 TITLE "GDIPLUS-test" ;
STYLE WS_POPUP BRUSH oBrush1 PIXEL


Image

best regards
Uwe :D
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: strange error with png files

Postby Silvio.Falconi » Thu Jan 14, 2016 8:45 am

I cannot use a brush because I must insert the background on window on exactly position
I explain you I have a png where you can see a room as the picture I sent you and the reels must be on center ( see the e-mail)

I use

oWnd:bPainted := {|hDC| PalBmpDraw( hDC, 0, 0, oBackground:hBitmap,, oWnd:nWidth, oWnd:nHeight,, .T.) }

then I must make a configuration for the touch monitor I found

local nMINWidth := 1200
local nMINHeight := 900
local nMAXWidth := 1200//GETSYSMETRICS( 0 ) //risoluzione orizzontale
local nMAXHeight := 900//GETSYSMETRICS( 1 ) //risoluzione verticale


oWnd:aMinMaxInfo = { GETSYSMETRICS( 0 ), GETSYSMETRICS( 1 ),; // xMaxSize, yMaxSize
0, 0,; // xMaxPosition, yMaxPosition
nMINWidth, nMINHeight,; // xMinTrackSize, yMinTrackSize
nMAXWidth, nMAXHeight }

I cannot insert buttons ( png) on bottom
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 15 guests

cron