FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A METRO image-background without FREEIMAGE ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
A METRO image-background without FREEIMAGE ?
Posted: Sat Sep 07, 2019 03:32 PM
Hello,

for windows without FREEIMAGE I use

// window without FREEIMAGE
aImage := oWnd:ReadImage( cImage, , .t. )
oWnd:DrawImage( aImage, aRect, nil, 1 )


it doesn't work for a METRO-image-background

DEFINE METROPANEL oMetro OF oWnd TITLE "Stammdaten" ;
COLOR aVal[8], CLR_BLUE
aRect := GETCLIENTRECT( oMetro:hWnd )
aImage := oMetro:ReadImage( cImage, , .t. )
oMetro:DrawImage( aImage, aRect, nil, 1 )


a working solution
// metro image-background ( FREEIMAGE needed )

DEFINE IMAGE oImage FILENAME cImage
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) ) // 1 = stretch, 2 : fitoutside, 3:fitinside
oImage:End()
oMetro:SetBrush( oBrush )
RELEASE BRUSH oBrush


is it possible to define a metro-image-background without using FREEIMAGE ?

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: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A METRO image-background without FREEIMAGE ?
Posted: Sat Sep 07, 2019 06:56 PM
Uwe, try with this

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "metropnl.ch"

Function Main()

   local oWnd

   DEFINE WINDOW oWnd TITLE "MetroPanel"


   Metro()

   ACTIVATE WINDOW oWnd MAXIMIZED //ON INIT Metro( oWnd )

Return nil


Function Metro( oWnd )

   local oMetro
   DEFINE METROPANEL oMetro OF oWnd TITLE "Stammdaten" COLOR CLR_WHITE, CLR_BLUE
   oMetro:bPainted := { || oMetro:DrawImage( "D:\Fwh\FwhTeam\bitmaps\hires\earth.bmp", , nil, 1 ) }
   oMetro:Show()

Return oMetro
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A METRO image-background without FREEIMAGE ?
Posted: Sat Sep 07, 2019 07:33 PM
Christobal,

thank You that works.
I added the image-background-painting to the defined brushed title-text-section

// on top
DEFINE FONT oFontLarge NAME "Arial" SIZE 0, -60 BOLD ITALIC
aPalBmp := oWnd:ReadImage( c_Pfad1 + "Marble.bmp", nil, .t. )
pBrush := GDIP_IMAGEBRUSH( aPalBmp[ 1 ] )
--
--
oMetro:Show()
oMetro:bPainted := {|| oMetro:DrawImage( c_Pfad1 + "Sea.jpg", , nil, 1 ), ;
oMetro:SayText( "Stammdaten", { 30, 150, 120, 650 }, "L", oFontLarge, pBrush ) }




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: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A METRO image-background without FREEIMAGE ?
Posted: Sat Sep 07, 2019 08:42 PM

The following should be added to metropnel.ch:

xcommand ACTIVATE METROPANEL <oMtr> => <oMtr>:Show()

or something similar

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: A METRO image-background without FREEIMAGE ?
Posted: Mon Sep 09, 2019 04:19 AM
ukoenig wrote:Hello,

for windows without FREEIMAGE I use

// window without FREEIMAGE
aImage := oWnd:ReadImage( cImage, , .t. )
oWnd:DrawImage( aImage, aRect, nil, 1 )


it doesn't work for a METRO-image-background

DEFINE METROPANEL oMetro OF oWnd TITLE "Stammdaten" ;
COLOR aVal[8], CLR_BLUE
aRect := GETCLIENTRECT( oMetro:hWnd )
aImage := oMetro:ReadImage( cImage, , .t. )
oMetro:DrawImage( aImage, aRect, nil, 1 )


a working solution
// metro image-background ( FREEIMAGE needed )

DEFINE IMAGE oImage FILENAME cImage
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) ) // 1 = stretch, 2 : fitoutside, 3:fitinside
oImage:End()
oMetro:SetBrush( oBrush )
RELEASE BRUSH oBrush


is it possible to define a metro-image-background without using FREEIMAGE ?

regards
Uwe :-)


Except the TImage() class, no other class requires freeimage.dll.
Your approach to create the resizable brush is round about.

You will get the correct results if you keep you code simple.

Use this one line code, which does everything for you
Code (fw): Select all Collapse
DEFINE BRUSH oBrush FILE <anyimagesource> RESIZE

Use RESIZE clause while creating the brush. This will automatically resize to fit the window (or panel).
It will keep resizing when the window is resized.
Avoid doing resize yourself in your application program
Code (fw): Select all Collapse
oMetro:SetBrush( oBrush )

While creating brush, you can use any image source, viz bmp,jpg,png,tiff, etc file on the disk, or resource, or from memory or from the web
Freeimage.dll is not required.
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A METRO image-background without FREEIMAGE ?
Posted: Mon Sep 09, 2019 05:04 PM

Thank You very much,

it works fine with the changes.

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.

Continue the discussion