Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Commit

Permalink
Fonctions trait(), retourner(), convRVB(), cercle(), disque(), redime…
Browse files Browse the repository at this point in the history
…nsionner

Les fonctions sont accessibles en mode testing mais leur commande n'est pas intégrée.
* Traitement d'image
	* Ajout de la fonction trait() (algorithme original), de retourner() et de convRVB()
	* Correction des fonctions cercle(), disque() et redimensionner()
* Utilitaires
	* Ajout d'un fichier de log (PILG-log.txt), pour éviter de surcharger la console, et fonctionner même en mode RELEASE
	* Déplacement de afficherImage() depuis analyserCommande.cpp
	* Ajout d'une constante ECHELLE à afficherImage() pour zoomer l'affichage
* Objet Image
	* Correction d'une inversion X/Y visible sur des images plus hautes que large
* Mise à jour de TODO.md
* Modification des règles de formattage (encore des lignes pour rien)
  • Loading branch information
GeoffreyFrogeye committed May 20, 2014
1 parent 077ef18 commit a618bda
Show file tree
Hide file tree
Showing 10 changed files with 454 additions and 201 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.sublime-*
PILG-log.txt
28 changes: 14 additions & 14 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
* Pixel **C**
* Image **C**
* Fonctions **D**
* Gestion de fichier **D**
* Gestion de fichier **A**
* Créer **C**
* Ouvrir **D**
* Enregistrer **D**
* Ouvrir **C**
* Enregistrer **C**
* Importer **A**
* Édition
* Copier tout
Expand All @@ -30,24 +30,24 @@
* Annuler
* Refaire
* Couleur **D**
* Teinte **A**
* Teinte **D**
* Saturation **D**
* Luminosité **A**
* Contraste **A**
* Dessin **D**
* Trait **A**
* Luminosité **D**
* Contraste
* Dessin **C**
* Trait **C**
* Rectangle **C**
* Cercle **A**
* Disque **A**
* Cercle **C**
* Disque **C**
* Géométrie **D**
* Zoomer
* Pivoter **C**
* Retourner **D**
* Redimensionner **A**
* Conversion du mode **D**
* Retourner **C**
* Redimensionner **C**
* Conversion du mode **C**
* Binaire **C**
* Niveaux de gris **C**
* Couleur **D**
* Couleur **C**
* Aide
* Documentation

Expand Down
21 changes: 13 additions & 8 deletions src/affichageFenetre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ SDL_Surface *fenetreImage;
void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel) {
int nbOctetsParPixel = surface->format->BytesPerPixel;
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;

switch (nbOctetsParPixel) {
case 1:
*p = pixel;
break;

case 2:
*(Uint16 *)p = pixel;
break;

case 3:
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
Expand All @@ -28,7 +31,9 @@ void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel) {
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}

break;

case 4:
*(Uint32 *)p = pixel;
break;
Expand All @@ -41,18 +46,14 @@ void setNomFenetre(std::string nom) { // Change le nom de la fenêtre

void pointFenetre(int x, int y, int r, int v, int b) {
// std::cout << "(" << x << ";" << y << ") = (" << r << ";" << v << ";" << b << ")" << std::endl; // DEBUG

Uint32 pixel;
Uint8 u_r, u_v, u_b, u_a;

u_r = (r > 255 ? 0xff : (Uint8) r);
u_v = (v > 255 ? 0xff : (Uint8) v);
u_b = (b > 255 ? 0xff : (Uint8) b);
u_a = 0xff;

pixel = SDL_MapRGBA(fenetreImage->format, u_r, u_v, u_b, u_a);
definirPixel(fenetreImage, x, y, pixel);

}

void afficherFenetre() {
Expand All @@ -70,7 +71,8 @@ void attendreFenetre() {

do {
SDL_WaitEvent(&evenement);
} while (evenement.type != SDL_QUIT && evenement.type != SDL_KEYDOWN); //|| evenement.type != SDL_KEYDOWN);
} while (evenement.type != SDL_QUIT &&
evenement.type != SDL_KEYDOWN); //|| evenement.type != SDL_KEYDOWN);
}

void fermerFenetre() {
Expand All @@ -81,12 +83,15 @@ void fermerFenetre() {
}


void ouvrirFenetre(int dimensionX, int dimensionY, std::string nom) { // Crée une fenêtre
void ouvrirFenetre(int dimensionX, int dimensionY,
std::string nom) { // Crée une fenêtre
SDL_Init(SDL_INIT_VIDEO);
fenetreDimensionX = dimensionX;
fenetreDimensionY = dimensionY;
fenetreEcran = SDL_SetVideoMode(fenetreDimensionX, fenetreDimensionY, 32, SDL_HWSURFACE);
fenetreImage = SDL_CreateRGBSurface(SDL_HWSURFACE, fenetreDimensionX, fenetreDimensionY, 32, 0, 0, 0, 0);
fenetreEcran = SDL_SetVideoMode(fenetreDimensionX, fenetreDimensionY, 32,
SDL_HWSURFACE);
fenetreImage = SDL_CreateRGBSurface(SDL_HWSURFACE, fenetreDimensionX,
fenetreDimensionY, 32, 0, 0, 0, 0);
SDL_FillRect(fenetreImage, NULL, SDL_MapRGB(fenetreEcran->format, 0, 0, 0));
setNomFenetre(nom);
SDL_LockSurface(fenetreImage);
Expand Down
Loading

0 comments on commit a618bda

Please sign in to comment.