Page 1 of 1

A METRO image-background without FREEIMAGE ?

Posted: Sat Sep 07, 2019 3:32 pm
by ukoenig
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 :?:

Re: A METRO image-background without FREEIMAGE ?

Posted: Sat Sep 07, 2019 6:56 pm
by cnavarro
Uwe, try with this

Code: Select all


#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

 

Re: A METRO image-background without FREEIMAGE ?

Posted: Sat Sep 07, 2019 7:33 pm
by ukoenig
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 ) }


Image

regards
Uwe :D

Re: A METRO image-background without FREEIMAGE ?

Posted: Sat Sep 07, 2019 8:42 pm
by cnavarro
The following should be added to metropnel.ch:

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

or something similar

Re: A METRO image-background without FREEIMAGE ?

Posted: Mon Sep 09, 2019 4:19 am
by nageswaragunupudi
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: Select all

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: Select all

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.

Re: A METRO image-background without FREEIMAGE ?

Posted: Mon Sep 09, 2019 5:04 pm
by ukoenig
Thank You very much,

it works fine with the changes.

regards
Uwe :D