Logiciels - Impression avec Gambas - Imprimer une image -

Impression avec Gambas - Imprimer une image

( Temps de lecture estimé à Moins d'une minute)




IMPRIMER UNE IMAGE AVEC GAMBAS LINUX


Imprimer une image


(par taoteblues)


Créer un bouton pour l 'impression:


PUBLIC SUB Button_Click()


DIM img AS Image

Dim monimage As String


monimage = chemin du fichier image que je veux imprimer

img = Image.Load(monimage)


PrintImage(img)

CATCH

Message.Error( Classe: & Str(Error.class) & nCode: & error.code &

, = & error.text & nà: & error.where, OK )


END


Ajouter la fonction PrintImage()


PRIVATE SUB PrintImage(fichierimg AS Image)


DIM imageToPrint AS Image

DIM imageWidth AS Integer

DIM imageHeight AS Integer

DIM scaleIsotropic AS Float


INC Application.Busy


imageWidth = (fichierimg.Width * Printer.Resolution) / Desktop.Resolution

imageHeight = (fichierimg.Height * Printer.Resolution) / Desktop.Resolution



IF imageWidth > Printer.Width OR imageHeight > Printer.Height THEN

scaleIsotropic = Min(Printer.Width / imageWidth, Printer.Height / imageHeight)

imageWidth *= scaleIsotropic

imageHeight *= scaleIsotropic


END IF



imageToPrint = fichierimg.Stretch(imageWidth, imageHeight, TRUE)




Draw.Begin(Printer)

Draw.Image(imageToPrint, (Printer.Width - imageWidth) / 2, (Printer.Height - imageHeight) / 2)

Draw.End

DEC Application.Busy


END


L 'attente pour l 'impression peut être longue (1 à 2 minutes) en fonction de votre matériel et de la taille de l 'image.




);



Date de creation :
Redacteur : Rédigé par spheris
Classé dans : Logiciels