| auteurs : ero-sennin, yarp, blondelle |
Pour utiliser l'assistant Photographie Windows il vous faut tout d'abord créer une connexion avec le WIA, ajouter les images à imprimer, et pour finir il ne suffit plus qu'à lancer l'assistant :
# include <utilcls.h> // <---- ne pas oublier d'inclure
void __fastcall TForm1:: Button1Click (TObject * Sender)
{
Variant vMSWIACommonDialog, vMSWIAVector;
vMSWIACommonDialog = Variant:: CreateObject (" WIA.CommonDialog " );
vMSWIAVector = Variant:: CreateObject (" WIA.Vector " );
vMSWIAVector.OleProcedure (" Add " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\imageJPEG.jpg " );
vMSWIAVector.OleProcedure (" Add " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\imageBMP.bmp " );
vMSWIACommonDialog.OleProcedure (" ShowPhotoPrintingWizard " , vMSWIAVector);
vMSWIACommonDialog = Unassigned;
vMSWIAVector = Unassigned;
}
|
|
| auteur : blondelle |
Pour redimensionner une image, il suffit d'utiliser le bon filtre :
# include <utilcls.h> // <---------ne pas oublier
Variant vMSWIAImageProcess, vMSWIAImageFile;
vMSWIAImageFile = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageProcess = Variant:: CreateObject (" WIA.ImageProcess " );
vMSWIAImageFile.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\imageOrigine.bmp " );
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Scale " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " MaximumWidth " , 90 );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " MaximumHeight " , 90 );
vMSWIAImageFile = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile);
vMSWIAImageFile.OleFunction (" SaveFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\imageFinale.jpg " );
|
|
lien : Comment lister les informations sur les filtres ?
|
| auteur : blondelle |
Pour combiner deux images, il faut charger les images à combiner, puis utiliser le filtre approprié :
# include <utilcls.h> // <---------ne pas oublier
Variant vMSWIAImageProcess, vMSWIAImageFile1, vMSWIAImageFile2;
vMSWIAImageFile1 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageFile2 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageProcess = Variant:: CreateObject (" WIA.ImageProcess " );
vMSWIAImageFile1.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\YourBmpHere.bmp " );
vMSWIAImageFile2.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\Photo\\Photo.jpg " );
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Stamp " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " ImageFile " , vMSWIAImageFile2);
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Left " , (vMSWIAImageFile1.OlePropertyGet (" Width " ) - vMSWIAImageFile2.OlePropertyGet (" Width " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Top " , (vMSWIAImageFile1.OlePropertyGet (" Height " ) - vMSWIAImageFile2.OlePropertyGet (" Height " )));
vMSWIAImageFile1 = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile1);
vMSWIAImageFile1.OleFunction (" SaveFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\fourmiz_ImageCombinee.JPG " );
|
|
lien : Comment lister les informations sur les filtres ?
|
| auteur : blondelle |
Pour fusionner deux images, il faut charger les images à fusionner, puis utiliser le filtre approprié :
# include <utilcls.h> // <---------ne pas oublier
Variant Largeur, Hauteur, vMSWIAVector, vMSWIAImageProcess, vMSWIAImageFile1, vMSWIAImageFile2, vMSWIAImageFile3;
long C;
vMSWIAImageFile1 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageFile2 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageProcess = Variant:: CreateObject (" WIA.ImageProcess " );
vMSWIAImageFile1.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\Grue_Atelier.jpg " );
vMSWIAImageFile2.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\Photo\\Photo.jpg " );
if (vMSWIAImageFile1.OlePropertyGet (" Width " ) > vMSWIAImageFile2.OlePropertyGet (" Width " ))
{
Largeur = vMSWIAImageFile1.OlePropertyGet (" Width " );
}
else
{
Largeur = vMSWIAImageFile2.OlePropertyGet (" Width " );
}
Hauteur = vMSWIAImageFile1.OlePropertyGet (" Height " ) + vMSWIAImageFile2.OlePropertyGet (" Height " );
C = 0x80000004 ;
vMSWIAVector = Variant:: CreateObject (" WIA.Vector " );
vMSWIAVector.OleProcedure (" Add " , C);
vMSWIAVector.OleProcedure (" Add " , C);
vMSWIAVector.OleProcedure (" Add " , C);
vMSWIAVector.OleProcedure (" Add " , C);
vMSWIAImageFile3 = vMSWIAVector.OlePropertyGet (" ImageFile " , 2 , 2 );
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Scale " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " MaximumWidth " , Largeur);
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " MaximumHeight " , Hauteur);
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " PreserveAspectRatio " , false );
vMSWIAImageFile3 = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile3);
for (int i = 1 ; i <= vMSWIAImageProcess.OlePropertyGet (" Filters " ).OlePropertyGet (" Count " ); i+ + )
{
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Remove " , i);
}
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Stamp " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " ImageFile " , vMSWIAImageFile1);
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Left " , 0 );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Top " , 0 );
vMSWIAImageFile3 = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile3);
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " ImageFile " , vMSWIAImageFile2);
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Left " , 0 );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Top " , vMSWIAImageFile1.OlePropertyGet (" Height " ));
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Convert " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 2 ).OlePropertyGet (" Properties " , " FormatID " ).OlePropertySet (" Value " , " {B96B3CAE-0728-11D3-9D7B-0000F81EF32E} " );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 2 ).OlePropertyGet (" Properties " , " Quality " ).OlePropertySet (" Value " , 90 );
vMSWIAImageFile3 = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile3);
vMSWIAImageFile3.OleFunction (" SaveFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\resultat_Fusion_Deux_images.jpg " );
|
|
lien : Comment lister les informations sur les filtres ?
|
| auteur : blondelle |
Pour couper ou rogner une image, il suffit d'utiliser le filtre approprié :
# include <utilcls.h> // <---------ne pas oublier
Variant vMSWIAImageProcess, vMSWIAImageFile;
vMSWIAImageFile = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageProcess = Variant:: CreateObject (" WIA.ImageProcess " );
vMSWIAImageFile.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\Grue_Atelier.jpg " );
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Crop " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Left " , 0 );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Top " , 0 );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Right " , (vMSWIAImageFile.OlePropertyGet (" Width " ) / 3 ));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Bottom " , (vMSWIAImageFile.OlePropertyGet (" Height " ) / 3 ));
vMSWIAImageFile = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile);
vMSWIAImageFile.OleFunction (" SaveFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\sauvegarde_Image_Coupee.JPG " );
|
|
lien : Comment lister les informations sur les filtres ?
|
| auteur : blondelle |
Pour créer une image multipages, il faut tout d'abord charger les différentes images utilisées pour l'image finale, puis il faut utiliser le filtre approprié :
# include <utilcls.h> // <---------ne pas oublier
Variant vMSWIAImageFile1, vMSWIAImageFile2, vMSWIAImageFile3, vMSWIAImageProcess;
vMSWIAImageFile1 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageFile2 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageFile3 = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageProcess = Variant:: CreateObject (" WIA.ImageProcess " );
vMSWIAImageFile1.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\Grue_Atelier.jpg " );
vMSWIAImageFile2.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\resultat_Fusion_Deux_images.JPG " );
vMSWIAImageFile3.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\fourmiz_ImageCombinee.JPG " );
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Frame " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , (vMSWIAImageProcess.OlePropertyGet (" Filters " ).OlePropertyGet (" Count " ))).OlePropertySet (" Properties " , " ImageFile " , vMSWIAImageFile2);
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Frame " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , (vMSWIAImageProcess.OlePropertyGet (" Filters " ).OlePropertyGet (" Count " ))).OlePropertySet (" Properties " , " ImageFile " , vMSWIAImageFile3);
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Convert " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , (vMSWIAImageProcess.OlePropertyGet (" Filters " ).OlePropertyGet (" Count " ))).OlePropertySet (" Properties " , " FormatID " , " {B96B3CB1-0728-11D3-9D7B-0000F81EF32E} " );
vMSWIAImageFile1 = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile1);
vMSWIAImageFile1.OleFunction (" SaveFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\monImageMultipage.tif " );
|
|
lien : Comment lister les informations sur les filtres ?
|
| auteur : blondelle |
Pour modifier les TAG d'une image il suffit de procéder de la manière suivante :
# include <utilcls.h> // <---------ne pas oublier
Variant vMSWIAVector, vMSWIAImageProcess, vMSWIAImageFile;
vMSWIAImageFile = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageProcess = Variant:: CreateObject (" WIA.ImageProcess " );
vMSWIAVector = Variant:: CreateObject (" WIA.Vector " );
vMSWIAImageFile.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\Grue_Atelier.jpg " );
vMSWIAImageProcess.OlePropertyGet (" Filters " ).OleProcedure (" Add " , (vMSWIAImageProcess.OlePropertyGet (" FilterInfos " , " Exif " ).OlePropertyGet (" FilterID " )));
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " ID " , 40091 );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Type " , 1101 );
vMSWIAVector.OleProcedure (" SetFromString " , " Test de TAG 'TITRE' : utilisation de WIA v2.0 " );
vMSWIAImageProcess.OlePropertyGet (" Filters " , 1 ).OlePropertySet (" Properties " , " Value " , vMSWIAVector);
vMSWIAImageFile = vMSWIAImageProcess.OleFunction (" Apply " , vMSWIAImageFile);
vMSWIAImageFile.OleFunction (" SaveFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\fourmiz_Test_EXIF.JPG " );
|
|
| auteur : blondelle |
Pour lister les propriétés d'une image il suffit de procéder de la manière suivante, ici on les charge dans un TMemo :
# include <utilcls.h> // <---------ne pas oublier
Variant vMSWIAImageFile;
String S;
vMSWIAImageFile = Variant:: CreateObject (" WIA.ImageFile " );
vMSWIAImageFile.OleFunction (" LoadFile " , " C:\\Documents and Settings\\toto\\Mes documents\\Mes images\\monImageMultipage.tif " );
for (int nb = 1 ; nb <= vMSWIAImageFile.OlePropertyGet (" Properties " ).OlePropertyGet (" Count " ); nb+ + )
{
S = vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Name " );
S = S + " ( " ;
S = S + vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" PropertyID " );
S = S + " ) = " ;
if (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" IsVector " ))
{
S = S + " - vector data not emitted - " ;
}
else if (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Type " ) = = 1006 )
{
S = S + (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Value " ).OlePropertyGet (" Numerator " ));
S = S + " / " ;
S = S + (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Value " ).OlePropertyGet (" Denominator " ));
}
else if (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Type " ) = = 1002 )
{
S = S + " " " " + (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Value " )) + " " " " ;
}
else
S = S + (vMSWIAImageFile.OlePropertyGet (" Properties " , nb).OlePropertyGet (" Value " ));
Memo1- > Lines- > Add (S);
}
|
|
Consultez les autres F.A.Q.
|
|