Only an example to show how to display à JPEG image, simplied version of DirectFB's own tutorial.
Classical shebang to use Séléné as script interpretor. Obviously, the path has to be changed as per your own installation.
#!./Selene
Tell to Séléné we want to use DirectFB and pass some option to it :
Selene.UseDirectFB("--dfb:quiet,no-vt")
We want whole screen and then we get its primary surface.
Finally, clear it and get its size.
DirectFB.init( DirectFB.CooperativeConst('FULLSCREEN') )
srf = SelSurface.create { caps=SelSurface.CapabilityConst('PRIMARY') }
w,h = srf:GetSize()
srf:Clear(0,0,0,0)Load the image as ... an image provider and handle potential error (obviously, the path has to be changed as per the actual image location).
local img,err = SelImage.create("/root/trv/DirectFB-examples-1.2.0/data/wood_andi.jpg")
if not img then
error("Can't load image")
endCreate our primary surface, clear it and retreive its size
local srf = SelSurface.create {
caps=SelSurface.CapabilityConst('PRIMARY')
}
srf:Clear( 0,0,0,0 )
local w,h = srf:GetSize()
Render to the created surface.
img:RenderTo(
srf,
{ 20, 20, w-40, h-40 } -- Conform to surface size, w/ 20px margins
)
with :
We don't need the orignal image anymore, releasing it
img:destroy()
Normally, we have now to refresh the display, but it's implicit here and we have only to wait for user's input.
print "Hit 'enter' key to exit"
io.stdin:read'*l'
It's over : time to do usual cleaning. It's not mandatory as Séléné takes it on his own if not explicitly made.
srf:destroy()
The full source code is here.
The image can now be manipulated as other surface : drawing, blitting ... So it a very convenient way to create fancy GUI by working directly on the background image and then add dynamically objects handled by Séléné ... it's what I'm doing for my dashboards.
|
Visitez : Nos sorties Ski et rando |
Copyright Laurent Faillie
2001-2025
N'oubliez pas d'entrer le mot de passe pour voir aussi les photos perso. |
Contactez moi si vous souhaitez réutiliser ces photos et pour les obtenir avec une plus grande résolution. |
|
Visites durant les 7 derniers jours
|
Vous pouvez
laissez un commentaire
sur cette page.