Ajout de la fonction pivoter
* Ajout de la fonction pivoter() * Ajout de Image::g_dupplicata() * Corrections diverses, au Makefile notamment
This commit is contained in:
parent
43550b265f
commit
2af24e2cc8
4
Makefile
4
Makefile
|
@ -23,10 +23,10 @@ $(EXEPATH)testing: $(OBJPATH)testing.o $(OBJPATH)image.o
|
|||
|
||||
# Dépendances
|
||||
## Fichiers executables
|
||||
$(OBJPATH)main.o: $(SRCPATH)main.cpp $(SRCPATH)image.h
|
||||
$(OBJPATH)main.o: $(SRCPATH)main.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
|
||||
$(CXX) -c $< -o $@ $(CXXFLAGS)
|
||||
|
||||
$(OBJPATH)testing.o: $(SRCPATH)testing.cpp $(SRCPATH)image.cpp
|
||||
$(OBJPATH)testing.o: $(SRCPATH)testing.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
|
||||
$(CXX) -c $< -o $@ $(CXXFLAGSDEBUG)
|
||||
## Bibliothèques
|
||||
$(OBJPATH)image.o: $(SRCPATH)image.cpp
|
||||
|
|
2
TODO.md
2
TODO.md
|
@ -41,7 +41,7 @@
|
|||
* Disque **D**
|
||||
* Géométrie **D**
|
||||
* Zoomer
|
||||
* Pivoter
|
||||
* Pivoter **C**
|
||||
* Retourner **D**
|
||||
* Redimensionner **A**
|
||||
* Conversion du mode **D**
|
||||
|
|
|
@ -16,7 +16,7 @@ void afficherImage(Image image) {
|
|||
fermerFenetre();
|
||||
}
|
||||
|
||||
ouvrirFenetre(dimensionX, dimensionY, "PILG - Test");
|
||||
ouvrirFenetre(dimensionX, dimensionY, "PILG");
|
||||
|
||||
for (x = 0; x < dimensionX; x++) {
|
||||
for (y = 0; y < dimensionY; y++) {
|
||||
|
|
|
@ -33,6 +33,7 @@ int Image::g_pixel(unsigned int x, unsigned int y, Pixel &pixel) const {
|
|||
pixel = m_tab[x][y];
|
||||
return 0;
|
||||
} else {
|
||||
pixel = g_pixelVide();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +61,16 @@ Pixel Image::g_pixelVide() const {
|
|||
pixel.g = 0;
|
||||
break;
|
||||
case PILG_RVB:
|
||||
pixel.r = 0;
|
||||
pixel.b = 0;
|
||||
pixel.v = 0;
|
||||
pixel.r = pixel.v = pixel.b = 0;
|
||||
break;
|
||||
}
|
||||
return pixel;
|
||||
}
|
||||
|
||||
Image Image::g_vide() const {
|
||||
return Image(m_dimensionX, m_dimensionY, m_maxComposante, m_typeComposantes);
|
||||
}
|
||||
|
||||
// Validateurs
|
||||
bool Image::v_pixel(Pixel pixel) const {
|
||||
if (pixel.typeComposantes == m_typeComposantes
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
int s_pixel(unsigned int x, unsigned int y, Pixel pixel);
|
||||
// Utilitaires
|
||||
Pixel g_pixelVide() const;
|
||||
Image g_vide() const;
|
||||
// Validateurs
|
||||
bool v_pixel(Pixel pixel) const;
|
||||
bool v_dimensions(unsigned int x, unsigned int y) const;
|
||||
|
|
|
@ -8,6 +8,8 @@ using namespace std;
|
|||
#include "traitementImage.cpp"
|
||||
#include "analyserCommande.cpp"
|
||||
|
||||
#define PI 3.14159265359
|
||||
|
||||
Image genererRoue(int dimX, int dimY, int maxComposante) {
|
||||
Image imageRoue(dimX, dimY, maxComposante, PILG_RVB);
|
||||
Pixel pointRoue = imageRoue.g_pixelVide();
|
||||
|
@ -102,7 +104,7 @@ int main(int argc, char *args[]) {
|
|||
freopen("CON", "w", stderr);
|
||||
#endif
|
||||
|
||||
cout << "PILG - Debug" << endl; // Message d'entrée et de test
|
||||
cout << "PILG - Test" << endl; // Message d'entrée et de test
|
||||
|
||||
// // Analyse de commandes
|
||||
// if (argc > 1) {
|
||||
|
@ -115,21 +117,17 @@ int main(int argc, char *args[]) {
|
|||
// boucleDeCommandes();
|
||||
// }
|
||||
|
||||
// // Afficher image par défaut
|
||||
// // Image image = genererRoue(200, 200, 255);
|
||||
// // Image image = genererDegrade(200, 200, 255);
|
||||
// Image image = genererBruit(200, 200);
|
||||
// Pixel couleurRectangle;
|
||||
#define DIMENSIONS 256
|
||||
|
||||
// couleurRectangle = image.g_pixelVide();
|
||||
// // couleurRectangle.b = 255;
|
||||
// // couleurRectangle.g = 255;
|
||||
// couleurRectangle.b = true;
|
||||
Image imageOriginale = genererRoue(DIMENSIONS, DIMENSIONS, 255);
|
||||
Image image = imageOriginale.g_vide();
|
||||
while(1) {
|
||||
for (float i = 0; i < 2 * PI; i += 0.1) {
|
||||
pivoter(imageOriginale, image, DIMENSIONS/2, DIMENSIONS/2, i);
|
||||
afficherImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
// rectangle(image, image, 5, 5, 10, 10, couleurRectangle);
|
||||
|
||||
// afficherImage(image);
|
||||
// attendreFenetre();
|
||||
|
||||
// // Neige en dégradé
|
||||
// for (int i; i < 300; i++) {
|
||||
|
@ -170,8 +168,7 @@ int main(int argc, char *args[]) {
|
|||
// }
|
||||
|
||||
// cout << "Éxecution du programme terminée. Vous pouvez quitter la fenêtre." << endl;
|
||||
// attendreFenetre();
|
||||
// fermerFenetre();
|
||||
fermerFenetre();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#include <math.h>
|
||||
|
||||
#define PI 3.14159265359
|
||||
|
||||
// Gestion de fichiers
|
||||
void creer(Image &sortie, unsigned int dimensionX, unsigned int dimensionY, unsigned int maxComposante, PILG_Comp typeComposantes) { // Créer une image de dimensions X et Y
|
||||
Image *nouvelle = new Image(dimensionX, dimensionY, maxComposante, typeComposantes);
|
||||
sortie = *nouvelle;
|
||||
sortie = *new Image(dimensionX, dimensionY, maxComposante, typeComposantes);
|
||||
}
|
||||
|
||||
void ouvrir(Image &sortie, string nomFichier) { // Ouvrir une image existante à partir du nom du fichier ***Geoffrey
|
||||
|
@ -147,8 +150,27 @@ void zoom(Image entree, Image &sortie) {
|
|||
|
||||
}
|
||||
|
||||
void pivoter(Image entree, Image &sortie) {
|
||||
|
||||
void pivoter(Image entree, Image &sortie, int x0, int y0, float angle) {
|
||||
sortie = entree.g_vide();
|
||||
float xF, yF, angleF, xI, yI, angleI, h;
|
||||
Pixel pixel = entree.g_pixelVide();
|
||||
for (xF = 0; xF < entree.g_dimensionX(); xF++) {
|
||||
for (yF = 0; yF < entree.g_dimensionY(); yF++) {
|
||||
if (xF == x0 && yF == y0) {
|
||||
xI = x0;
|
||||
yI = y0;
|
||||
} else {
|
||||
angleF = atan((yF-y0)/(xF-x0));
|
||||
angleF = (xF-x0<0 ? angleF + PI : (yF-y0 ? angleF + 2*PI: angleF));
|
||||
angleI = angleF - angle;
|
||||
h = sqrt(pow(xF-x0, 2)+pow(yF-y0, 2));
|
||||
xI = cos(angleI)*h+x0;
|
||||
yI = sin(angleI)*h+y0;
|
||||
}
|
||||
entree.g_pixel((int) xI, (int) yI, pixel);
|
||||
sortie.s_pixel((int) xF, (int) yF, pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void retourner(Image entree, Image &sortie, int rotation) {
|
||||
|
|
Reference in a new issue