8 messages in org.openoffice.fr.progRe: [prog] redimensionner image JPG ...
FromSent OnAttachments
Rémi BSep 1, 2008 2:22 pm 
Bernard MarcellySep 2, 2008 5:39 am 
Rémi BSep 2, 2008 10:43 am 
Bernard MarcellySep 2, 2008 12:34 pm 
Rémi BSep 2, 2008 1:18 pm 
Didier Dorange-PattoretSep 2, 2008 1:35 pm 
Bernard MarcellySep 3, 2008 3:12 am 
Rémi BSep 4, 2008 1:46 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [prog] redimensionner image JPG par macroActions...
From:Bernard Marcelly (marc@club-internet.fr)
Date:Sep 2, 2008 5:39:09 am
List:org.openoffice.fr.prog

Bonjour, Réponses dans la demande...

Message de Rémi B date 2008-09-01 23:22 :

Comment faire pour récupérer les dimensions d'une image au format *.jpg par macro basic ?

Pour l'instant, j'arrive à obtenir quelque chose avec un code comme : oImage = ThisComponent.createInstance ("com.sun.star.drawing.GraphicObjectShape") ( ... )

Avec un fichier BMP, le script suivant fonctionne :

Sub resizeImageByWidth(uneImage As Object, largeur As Long) Dim leBitMap As Object, Proportion As Double Dim Taille1 As New com.sun.star.awt.Size LeBitmap = uneImage.GraphicObjectFillBitmap Taille1 = LeBitMap.Size ' taille en pixels ! Proportion = Taille1.Height / Taille1.Width Taille1.Width = largeur ' largeur en 1/100 de mm Taille1.Height = Taille1.Width * Proportion uneImage.Size = Taille1 End Sub

La routine resizeImageByWidth marche avec n'importe quel format de fichier bitmap (png, jpg, etc). Il suffit de lui transmettre ta variable oImage, comme l'explique le livre Programmation OpenOffice.org 2 page 565.

d'après l'API, GraphicObjectFillBitmap est DEPRECATED : http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/ GraphicObjectShape.html#GraphicObjectFillBitmap

Il faut lire tout ce qui est écrit à ce propos : Deprecated. Use graphic property instead! Il s'agit d'une propriété appelée Graphic, ajoutée avec la version 2.

Un petit coup de Xray sur cette propriété t'indique qu'elle renvoie un objet contenant: .SizePixel .Size100thMM Tous deux sont des structures com.sun.star.awt.Size

______ Bernard