A METRO image-background without FREEIMAGE ?

Post Reply
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

A METRO image-background without FREEIMAGE ?

Post 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 :?:
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
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A METRO image-background without FREEIMAGE ?

Post 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

 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: A METRO image-background without FREEIMAGE ?

Post 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
Last edited by ukoenig on Sun Sep 08, 2019 8:33 am, edited 2 times 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
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A METRO image-background without FREEIMAGE ?

Post by cnavarro »

The following should be added to metropnel.ch:

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

or something similar
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: A METRO image-background without FREEIMAGE ?

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: A METRO image-background without FREEIMAGE ?

Post by ukoenig »

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.
Post Reply