Compare commits

..

7 commits

Author SHA1 Message Date
Geoffrey Frogeye 07d6db0aeb Mise à jour
* Suit le commit 386ff0b51b
2014-05-20 22:19:19 +02:00
Geoffrey Frogeye fdffe7cba0 Mise à jour
* Suit le commit 1f5f2f9c91
* Nouveau screen
2014-05-15 14:04:12 +02:00
Geoffrey Frogeye f2499449e3 Mise à jour
* Suit le commit 43550b265f
* Corrections mineures du générateur
2014-05-08 19:59:47 +02:00
Geoffrey Frogeye f50a017a06 Mise à jour
* Suit le commit 2e5cbafa3c
2014-05-05 21:30:43 +02:00
Geoffrey Frogeye 8a0fb4739e Mise à jour
* Aligné avec le commit f237beee15
* Ajout du graphique de fonctionnement du programme
* Ajout de "- PILG" dans le titre
2014-05-03 20:04:27 +02:00
Geoffrey Frogeye ace45137f9 Mise à jour
* Un peu de design
* Suit le commit 22bcfb2b2f
2014-04-28 15:07:47 +02:00
Geoffrey Frogeye 166f0e9819 Ajout d'un site web
Pour la présentation du 5/05/14
* Générateur
	* En nodejs
	* Se base sur les fichiers .md de la branche master sur GitHub
	* Sépare À propos et Compilation dans README.md
* Conforme GitHub Pages
2014-04-26 20:39:24 +02:00
34 changed files with 679 additions and 2213 deletions

15
.gitattributes vendored
View file

@ -12,16 +12,11 @@
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
# Personalisé
*.pbm binary
*.pgm binary
*.ppm binary

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
*.sublime-*
PILG-log.txt
generator/nodes_modules/*

View file

@ -1,8 +0,0 @@
language: cpp
compiler: gcc
before_install:
- sudo apt-get update
- sudo apt-get install -y libsdl1.2-dev
script: make
after_install:
- make testing

44
Avancement.html Normal file
View file

@ -0,0 +1,44 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Avancement - PILG</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/contenu.css" />
<link rel="stylesheet" href="css/miseEnPage.css" />
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<nav>
<ul>
<li><a href="index.html">À propos</a></li>
<li><a href="Compilation.html">Compilation</a></li>
<li><a href="Avancement.html">Avancement</a></li>
<li><a href="https://github.com/GeoffreyFrogeye/PILG">Code source</a></li>
</ul>
</nav>
<section>
<header>
<h1>Projet ISN de Lucas et de Geoffrey</h1>
<p>Un éditeur d'image en ligne de commandes</p>
</header>
<article>
<h1>Avancement</h1>
<h3>Légende</h3>
<ul><li><span class="todoEl todo_D">D</span> Définition réalisée</li><li><span class="todoEl todo_A">A</span> Algorithme réalisé</li><li><span class="todoEl todo_C">C</span> Code réalisé</li></ul>
<h3>Liste générale</h3>
<p><em>Ordre donné à titre indicatif</em></p>
<ul><li>Fonction principale <span class="todoEl todo_C">C</span></li><li>Fonction d&#39;analyse de commande <span class="todoEl todo_C">C</span><ul><li>Analyse de la commande <span class="todoEl todo_C">C</span></li><li>Analyse des arguments <span class="todoEl todo_C">C</span></li><li>Execution des fonctions <span class="todoEl todo_C">C</span></li></ul></li><li>Objets <span class="todoEl todo_C">C</span><ul><li>Fenêtre <span class="todoEl todo_C">C</span></li><li>Pixel <span class="todoEl todo_C">C</span></li><li>Image <span class="todoEl todo_C">C</span></li></ul></li><li>Fonctions <span class="todoEl todo_D">D</span><ul><li>Gestion de fichier <span class="todoEl todo_A">A</span><ul><li>Créer <span class="todoEl todo_C">C</span></li><li>Ouvrir <span class="todoEl todo_C">C</span></li><li>Enregistrer <span class="todoEl todo_C">C</span></li><li>Importer <span class="todoEl todo_A">A</span></li></ul></li><li>Édition<ul><li>Copier tout</li><li>Couper tout</li><li>Coller tout</li><li>Annuler</li><li>Refaire</li></ul></li><li>Couleur <span class="todoEl todo_D">D</span><ul><li>Teinte <span class="todoEl todo_D">D</span></li><li>Saturation <span class="todoEl todo_D">D</span></li><li>Luminosité <span class="todoEl todo_D">D</span></li><li>Contraste</li></ul></li><li>Dessin <span class="todoEl todo_C">C</span><ul><li>Trait <span class="todoEl todo_C">C</span></li><li>Rectangle <span class="todoEl todo_C">C</span></li><li>Cercle <span class="todoEl todo_C">C</span></li><li>Disque <span class="todoEl todo_C">C</span></li></ul></li><li>Géométrie <span class="todoEl todo_D">D</span><ul><li>Zoomer</li><li>Pivoter <span class="todoEl todo_C">C</span></li><li>Retourner <span class="todoEl todo_C">C</span></li><li>Redimensionner <span class="todoEl todo_C">C</span></li></ul></li><li>Conversion du mode <span class="todoEl todo_C">C</span><ul><li>Binaire <span class="todoEl todo_C">C</span></li><li>Niveaux de gris <span class="todoEl todo_C">C</span></li><li>Couleur <span class="todoEl todo_C">C</span></li></ul></li><li>Aide</li></ul></li><li>Documentation</li></ul>
<img src="chart.png" alt="Fonctionnement du programme" />
</article>
</section>
<footer>
<hr/>
Copyright 2014 Lucas et Geoffrey
</footer>
</body>
</html>

49
Compilation.html Normal file
View file

@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Compilation - PILG</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/contenu.css" />
<link rel="stylesheet" href="css/miseEnPage.css" />
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<nav>
<ul>
<li><a href="index.html">À propos</a></li>
<li><a href="Compilation.html">Compilation</a></li>
<li><a href="Avancement.html">Avancement</a></li>
<li><a href="https://github.com/GeoffreyFrogeye/PILG">Code source</a></li>
</ul>
</nav>
<section>
<header>
<h1>Projet ISN de Lucas et de Geoffrey</h1>
<p>Un éditeur d'image en ligne de commandes</p>
</header>
<article>
<h1>Compilation</h1>
<p>Il n&#39;existe pas de fichier binaire à télécharger pour le moment, le seul moyen d&#39;avoir un aperçu du programme est de le compiler.</p>
<p>Téléchargement : <code>git clone https://github.com/GeoffreyFrogeye/PILG.git</code></p>
<h2>Windows</h2>
<ol><li>Télécharger et installer <a href="http://www.mingw.org/">MinGW</a></li><li>Inclure <strong>MinGW</strong> dans la variable d&#39;environnement <code>%PATH%</code> : <code>set path=%path%;C:\MinGW\bin</code></li><li>Télécharger la <a href="http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz">bibliothèque de développement SDL 1.2.15</a>, copier le contenu des dossier <em>lib</em> et <em>include</em> de l&#39;archive téléchargée dans le dossier de <strong>MinGW</strong></li><li>Télécharger la <a href="http://www.libsdl.org/release/SDL-1.2.15-win32.zip">bibliothèque dexécution de SDL 1.2.15</a> et placer <em>SDL.dll</em> dans le dossier <em>bin</em></li><li>Compiler : <code>mingw32-make -f Makefile.win</code></li></ol>
<p>Lexécutable se trouvera dans le dossier <em>bin</em></p>
<h2>Debian / Linux</h2>
<ol><li>Installer le nécessaire à la compilation ainsi que la <strong>bibliothèque de développement SDL 1.2</strong> : <code>sudo apt-get install build-essential libsdl1.2-dev</code></li><li>Compiler : <code>make</code></li></ol>
<p>Lexécutable se trouvera dans le dossier <em>bin</em></p>
</article>
</section>
<footer>
<hr/>
Copyright 2014 Lucas et Geoffrey
</footer>
</body>
</html>

View file

@ -1 +0,0 @@
*Copyright 2014 Lucas et Geoffrey*

View file

@ -1,37 +0,0 @@
# Variables
## Pour make
.PHONY: clean, mrproper
## Compilation
CXX = g++
CXXFLAGS = -lSDL -lSDLmain
CXXFLAGSDEBUG = -lSDL -lSDLmain -DDEBUG
## Chemins
EXEPATH = bin/
OBJPATH = obj/
SRCPATH = src/
# Programmes possibles
main: $(EXEPATH)main
testing: $(EXEPATH)testing
# Éxecutables
$(EXEPATH)main: $(OBJPATH)main.o $(OBJPATH)image.o
$(CXX) $^ -o $@ $(CXXFLAGS)
$(EXEPATH)testing: $(OBJPATH)testing.o $(OBJPATH)image.o
$(CXX) $^ -o $@ $(CXXFLAGSDEBUG)
# Dépendances
## Fichiers executables
$(OBJPATH)main.o: $(SRCPATH)main.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)utilitaires.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS)
$(OBJPATH)testing.o: $(SRCPATH)testing.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)utilitaires.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
$(CXX) -c $< -o $@ $(CXXFLAGSDEBUG)
## Bibliothèques
$(OBJPATH)image.o: $(SRCPATH)image.cpp
$(CXX) -c $< -o $@
# Meta
clean:
rm -rf $(OBJPATH)*.o

View file

@ -1,37 +0,0 @@
# Variables
## Pour make
.PHONY: clean, mrproper
## Compilation
CXX = g++
CXXFLAGS = -lmingw32 -lSDLmain -lSDL -static-libgcc -static-libstdc++
CXXFLAGSDEBUG = -lmingw32 -lSDLmain -lSDL -static-libgcc -static-libstdc++ -DDEBUG
## Chemins
EXEPATH = bin/
OBJPATH = obj/
SRCPATH = src/
# Programmes possibles
main: $(EXEPATH)main
testing: $(EXEPATH)testing
# Éxecutables
$(EXEPATH)main: $(OBJPATH)main.o $(OBJPATH)image.o
$(CXX) $^ -o $@ $(CXXFLAGS)
$(EXEPATH)testing: $(OBJPATH)testing.o $(OBJPATH)image.o
$(CXX) $^ -o $@ $(CXXFLAGSDEBU2)
# Dépendances
## Fichiers executables
$(OBJPATH)main.o: $(SRCPATH)main.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)utilitaires.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS)
$(OBJPATH)testing.o: $(SRCPATH)testing.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)utilitaires.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
$(CXX) -c $< -o $@ $(CXXFLAGSDEBUG)
## Bibliothèques
$(OBJPATH)image.o: $(SRCPATH)image.cpp
$(CXX) -c $< -o $@
# Meta
clean:
rm -rf $(OBJPATH)*.o

View file

@ -1,41 +0,0 @@
#Projet d'ISN de Lucas et Geoffrey
##À propos
###Le dépôt
Ce dépôt a été crée pour faciliter le développement du projet. Son caractère public n'est que lié aux nécessité de GitHub. Si vous ne savez pas de quel projet il s'agit, vous perdez votre temps ici. L'absence de licence (du moins jusqu'aux épreuves) vous interdit de distribuer ou de réutiliser le code, qui de toute façon ne vous aurait pas été utile.
###Le projet
Ceci est la création de Lucas et de Geoffrey pour l'option Informatique et Sciences du Numérique qui sera présenté lors du Baccalauréat 2013/2014.
Nos noms complets et le nom du lycée sont masqués pour des raisons d'intimité. Les personnes devant nous reconnaître nous reconnaîtront.
###Le programme
Ce programme est un éditeur basique d'images [PBM/PGM/PPM](http://fr.wikipedia.org/wiki/Portable_pixmap) sexécutant en ligne de commande.
*Version :* v1.0.1
*Status :* [![Build Status](https://travis-ci.org/GeoffreyFrogeye/PILG.svg?branch=master)](https://travis-ci.org/GeoffreyFrogeye/PILG)
##Compilation
Il n'existe pas de fichier binaire à télécharger pour le moment, le seul moyen d'avoir un aperçu du programme est de le compiler.
Téléchargement : ```git clone https://github.com/GeoffreyFrogeye/PILG.git```
###Windows
1. Télécharger et installer [MinGW](http://www.mingw.org/)
2. Inclure **MinGW** dans la variable d'environnement ```%PATH%``` : ```set path=%path%;C:\MinGW\bin```
3. Télécharger la [bibliothèque de développement SDL 1.2.15](http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz), copier le contenu des dossier *lib* et *include* de l'archive téléchargée dans le dossier de **MinGW**
4. Télécharger la [bibliothèque dexécution de SDL 1.2.15](http://www.libsdl.org/release/SDL-1.2.15-win32.zip) et placer *SDL.dll* dans le dossier *bin*
5. Compiler : ```mingw32-make -f Makefile.win```
Lexécutable se trouvera dans le dossier *bin*
###Debian / Linux
1. Installer le nécessaire à la compilation ainsi que la **bibliothèque de développement SDL 1.2** : ```sudo apt-get install build-essential libsdl1.2-dev```
2. Compiler : ```make```
Lexécutable se trouvera dans le dossier *bin*
----------
*Copyright 2014 Lucas et Geoffrey*

55
TODO.md
View file

@ -1,55 +0,0 @@
réaliser
###Légende
* **D** Définition réalisée
* **A** Algorithme réalisé
* **C** Code réalisé
###Liste générale
*Ordre donné à titre indicatif*
* Fonction principale **C**
* Fonction d'analyse de commande **C**
* Analyse de la commande **C**
* Analyse des arguments **C**
* Execution des fonctions **C**
* Objets **C**
* Fenêtre **C**
* Pixel **C**
* Image **C**
* Fonctions **D**
* Gestion de fichier **A**
* Créer **C**
* Ouvrir **C**
* Enregistrer **C**
* Importer **A**
* Édition
* Copier tout
* Couper tout
* Coller tout
* Annuler
* Refaire
* Couleur **D**
* Teinte **C**
* Saturation **C**
* Luminosité **C**
* Contraste
* Dessin **C**
* Trait **C**
* Rectangle **C**
* Cercle **C**
* Disque **C**
* Géométrie **D**
* Zoomer
* Pivoter **C**
* Retourner **C**
* Redimensionner **C**
* Conversion du mode **C**
* Binaire **C**
* Niveaux de gris **C**
* Couleur **C**
* Documentation
----------
*Copyright 2014 Lucas et Geoffrey*

3
bin/.gitignore vendored
View file

@ -1,3 +0,0 @@
# Pour forcer l'ajout de ce dossier dans le dépôt
*
!.gitignore

BIN
chart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

322
css/contenu.css Normal file
View file

@ -0,0 +1,322 @@
/* Style CSS pour Markdown depuis https://github.com/jasonm23/markdown-css-themes */
body {
font-family: Helvetica, arial, sans-serif;
font-size: large;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
margin-top: 0 !important; }
body > *:last-child {
margin-bottom: 0 !important; }
a {
color: #4183C4; }
a.absent {
color: #cc0000; }
a.anchor {
display: block;
padding-left: 30px;
margin-left: -30px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
bottom: 0; }
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
cursor: text;
position: relative; }
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
text-decoration: none; }
h1 tt, h1 code {
font-size: inherit; }
h2 tt, h2 code {
font-size: inherit; }
h3 tt, h3 code {
font-size: inherit; }
h4 tt, h4 code {
font-size: inherit; }
h5 tt, h5 code {
font-size: inherit; }
h6 tt, h6 code {
font-size: inherit; }
h1 {
font-size: 28px;
color: black; }
h2 {
font-size: 24px;
border-bottom: 1px solid #cccccc;
color: black; }
h3 {
font-size: 18px; }
h4 {
font-size: 16px; }
h5 {
font-size: 14px; }
h6 {
color: #777777;
font-size: 14px; }
p, blockquote, ul, ol, dl, li, table, pre {
margin: 15px 0; }
hr {
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAYAAACtBE5DAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OENDRjNBN0E2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OENDRjNBN0I2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4Q0NGM0E3ODY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4Q0NGM0E3OTY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC) repeat-x 0 0;
border: 0 none;
color: #999;
height: 4px;
padding: 0;
}
body > h2:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child {
margin-top: 0;
padding-top: 0; }
body > h1:first-child + h2 {
margin-top: 0;
padding-top: 0; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
margin-top: 0;
padding-top: 0; }
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0; }
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
margin-top: 0; }
li p.first {
display: inline-block; }
li {
margin: 0; }
ul, ol {
padding-left: 30px; }
ul :first-child, ol :first-child {
margin-top: 0; }
dl {
padding: 0; }
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px; }
dl dt:first-child {
padding: 0; }
dl dt > :first-child {
margin-top: 0; }
dl dt > :last-child {
margin-bottom: 0; }
dl dd {
margin: 0 0 15px;
padding: 0 15px; }
dl dd > :first-child {
margin-top: 0; }
dl dd > :last-child {
margin-bottom: 0; }
blockquote {
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
table {
padding: 0;border-collapse: collapse; }
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
table tr:nth-child(2n) {
background-color: #f8f8f8; }
table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr th :first-child, table tr td :first-child {
margin-top: 0; }
table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
img {
max-width: 100%; }
span.frame {
display: block;
overflow: hidden; }
span.frame > span {
border: 1px solid #dddddd;
display: block;
float: left;
overflow: hidden;
margin: 13px 0 0;
padding: 7px;
width: auto; }
span.frame span img {
display: block;
float: left; }
span.frame span span {
clear: both;
color: #333333;
display: block;
padding: 5px 0 0; }
span.align-center {
display: block;
overflow: hidden;
clear: both; }
span.align-center > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: center; }
span.align-center span img {
margin: 0 auto;
text-align: center; }
span.align-right {
display: block;
overflow: hidden;
clear: both; }
span.align-right > span {
display: block;
overflow: hidden;
margin: 13px 0 0;
text-align: right; }
span.align-right span img {
margin: 0;
text-align: right; }
span.float-left {
display: block;
margin-right: 13px;
overflow: hidden;
float: left; }
span.float-left span {
margin: 13px 0 0; }
span.float-right {
display: block;
margin-left: 13px;
overflow: hidden;
float: right; }
span.float-right > span {
display: block;
overflow: hidden;
margin: 13px auto 0;
text-align: right; }
code, tt {
margin: 0 2px;
padding: 0 5px;
white-space: nowrap;
border: 1px solid #ccc;
background-color: #f8f8f8;
border-radius: 3px; }
pre code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent; }
.highlight pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px; }
pre code, pre tt {
background-color: transparent;
border: none; }
sup {
font-size: 0.83em;
vertical-align: super;
line-height: 0;
}
* {
-webkit-print-color-adjust: exact;
}
@media screen and (min-width: 914px) {
body {
width: 854px;
margin:0 auto;
}
}
@media print {
table, pre {
page-break-inside: avoid;
}
pre {
word-wrap: break-word;
}
}
/* Theme personalisé */
.todoEl {
display: inline-block;
color: white;
font-weight: bold;
padding: 0px 1px 0px 1px;
margin: 1px;
background-color: black;
border-radius: 3px;
}
.todo_D {
background-color: #95336a;
}
.todo_A {
background-color: #326189;
}
.todo_C {
background-color: #5d7e31;
}

67
css/miseEnPage.css Normal file
View file

@ -0,0 +1,67 @@
body {
background-color: #ddd;
}
section {
margin-top: 50px;
}
section header, section article {
background-color: white;
border-radius: 5px;
padding: 10px;
margin: 10px;
}
header h1 {
font-size: xx-large;
}
nav {
background-color: #333;
text-align: center;
position: fixed;
left: 0;
top: 0;
width: 100%;
z-index: 10000;
}
nav ul {
margin: 5px 0 5px 0;
}
nav li {
display: inline-block;
font-size: larger;
}
nav a {
position: relative;
display: inline-block;
color: #fff;
text-decoration: none;
border-radius: 8px;
padding: 5px;
transition: background-color .2s ease-in-out;
}
nav ul li:before {
content: '•';
color: #aaa;
margin: 0 5px 0 5px;
display: inline-block;
}
nav ul li:first-child:before {
content : '';
}
nav a:hover {
background: #222;
}
nav a:active {
background: #444;
}

114
generator/generator.js Executable file
View file

@ -0,0 +1,114 @@
#!/usr/bin/js
/*jslint node: true, forin: true, indent: 4 */
"use strict";
// Dépendances
var https = require('https'),
fs = require('fs'),
markdown = require('markdown').markdown;
// Variables
var liste = [];
// Fonctions
function recupererFichier(nomFichier, retour) {
var contenu = '';
console.log('Téléchargement de ' + nomFichier);
https.get('https://raw.githubusercontent.com/GeoffreyFrogeye/PILG/master/' + nomFichier, function (res) {
console.log('Réponse pour ' + nomFichier + ' obtenue (' + res.statusCode + ')');
res.on('data', function (morceau) {
contenu += morceau;
}).on('end', function () {
console.log('Fichier ' + nomFichier + ' téléchargé');
retour(contenu);
});
}).on('error', function (e) {
console.error('Impossible de récupérer le fichier ' + nomFichier + ' car ' + e.message);
});
}
function genererPages(liste) {
var nav = '',
element;
for (element in liste) {
if (liste[element].titre === 'À propos') {
liste[element].titreCourt = 'index';
} else {
liste[element].titreCourt = liste[element].titre
.replace(/À/, 'A')
.replace(/ /, '_')
.replace(/\W/g, '');
}
if (!liste[element].lien) {
liste[element].lien = liste[element].titreCourt + '.html';
}
nav += '<li><a href="' + liste[element].lien + '">' + liste[element].titre + '</a></li>\n';
}
fs.readFile('model.html', function (err, contenuModele) {
if (!err) {
liste.forEach(function (element) {
var contenuHTML;
if (element.contenu) {
contenuHTML = contenuModele
.toString('utf-8')
.replace(/%%TITRE%%/g, element.titre)
.replace(/%%NAV%%/, nav)
.replace(/%%CONTENU%%/, element.contenu)
.replace(/%%LICENSE%%/, 'Copyright 2014 Lucas et Geoffrey');
fs.writeFile('../' + element.titreCourt + '.html', contenuHTML, function (err) {
if (!err) {
console.log('Écrit ' + element.titreCourt + '.html');
} else {
console.error('Impossible d\'écrire' + element.titreCourt + '.html', err);
}
});
}
});
} else {
console.error('Impossible d\'ouvrir le fichier modèle');
}
});
}
// Execution
function executer() {
recupererFichier('README.md', function (contenu) {
var decoupe = contenu
.toString('utf-8')
.replace(/##Compilation\n/, '%%SPLIT%%')
.replace(/Nos noms complets et le nom du lycée sont masqués pour des raisons d'intimité\. Les personnes devant nous reconnaître nous reconnaîtront\./g, '')
.replace(/##Le dépôt[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\'\,\(\)\n]+?##/g, '#')
.replace(/#(#+)/g, '$1')
.replace(/^#[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\']+\n/g, '')
.replace(/\n#[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\']+\n/g, '')
.replace(/-+\n\*Copyright[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\']+\*/g, '')
.split('%%SPLIT%%');
liste.push({
titre: 'À propos',
contenu: markdown.toHTML(decoupe[0]) + '\n<img src="screen.png" alt="Capture d\'écran du code" />'
}, {
titre: 'Compilation',
contenu: markdown.toHTML(decoupe[1])
});
recupererFichier('TODO.md', function (contenu) {
liste.push({
titre: "Avancement",
contenu: markdown.toHTML(contenu
.toString('utf-8')
.replace(/^#[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\']+\n/g, '')
.replace(/\n#[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\']+\n/g, '')
.replace(/-+\n\*Copyright[ \wæâ€êÿûîœôäßëðüïö©éÉèÈçÇàÀ\.\-\']+\*/g, ''))
.replace(/<strong>([DAC])<\/strong>/g, '<span class="todoEl todo_$1">$1</span>') + '\n<img src="chart.png" alt="Fonctionnement du programme" />'
}, {
titre: 'Code source',
lien: 'https://github.com/GeoffreyFrogeye/PILG'
});
genererPages(liste);
});
});
}
executer();

31
generator/model.html Normal file
View file

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>%%TITRE%% - PILG</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/contenu.css" />
<link rel="stylesheet" href="css/miseEnPage.css" />
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<nav>
<ul>
%%NAV%%
</ul>
</nav>
<section>
<header>
<h1>Projet ISN de Lucas et de Geoffrey</h1>
<p>Un éditeur d'image en ligne de commandes</p>
</header>
<article>
<h1>%%TITRE%%</h1>
%%CONTENU%%
</article>
</section>
<footer>
<hr/>
%%LICENSE%%
</footer>
</body>
</html>

46
index.html Normal file
View file

@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<head>
<title>À propos - PILG</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/contenu.css" />
<link rel="stylesheet" href="css/miseEnPage.css" />
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<nav>
<ul>
<li><a href="index.html">À propos</a></li>
<li><a href="Compilation.html">Compilation</a></li>
<li><a href="Avancement.html">Avancement</a></li>
<li><a href="https://github.com/GeoffreyFrogeye/PILG">Code source</a></li>
</ul>
</nav>
<section>
<header>
<h1>Projet ISN de Lucas et de Geoffrey</h1>
<p>Un éditeur d'image en ligne de commandes</p>
</header>
<article>
<h1>À propos</h1>
<h2>Le projet</h2>
<p>Ceci est la création de Lucas et de Geoffrey pour l&#39;option Informatique et Sciences du Numérique qui sera présenté lors du Baccalauréat 2013/2014.</p>
<h2>Le programme</h2>
<p>Ce programme est un éditeur basique d&#39;images <a href="http://fr.wikipedia.org/wiki/Portable_pixmap">PBM/PGM/PPM</a> sexécutant en ligne de commande.</p>
<p><em>Version :</em> Alpha</p>
<p><em>Status :</em> <a href="https://travis-ci.org/GeoffreyFrogeye/PILG"><img alt="Build Status" src="https://travis-ci.org/GeoffreyFrogeye/PILG.svg?branch=master"/></a></p>
<img src="screen.png" alt="Capture d'écran du code" />
</article>
</section>
<footer>
<hr/>
Copyright 2014 Lucas et Geoffrey
</footer>
</body>
</html>

3
obj/.gitignore vendored
View file

@ -1,3 +0,0 @@
# Pour forcer l'ajout de ce dossier dans le dépôt
*
!.gitignore

BIN
screen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -1,109 +0,0 @@
#include <SDL/SDL.h>
#include <string>
int fenetreDimensionX; // Stocke les dimensions X de la fenêtre
int fenetreDimensionY; // Stocke les dimensions Y de la fenêtre
int ecranX = 1024;
int ecranY = 1080;
bool fenetreOuverte = false;
SDL_Surface *fenetreEcran;
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;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
} else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}
void s_nomFenetre(std::string nom) { // Change le nom de la fenêtre
SDL_WM_SetCaption(nom.c_str(), NULL);
}
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() {
SDL_Rect position;
position.x = 0;
position.y = 0;
SDL_UnlockSurface(fenetreImage);
SDL_BlitSurface(fenetreImage, NULL, fenetreEcran, &position);
SDL_Flip(fenetreEcran);
SDL_LockSurface(fenetreImage);
}
void attendreFenetre() {
SDL_Event evenement;
do {
SDL_WaitEvent(&evenement);
} while (evenement.type != SDL_QUIT &&
evenement.type != SDL_KEYDOWN); //|| evenement.type != SDL_KEYDOWN);
}
void fermerFenetre() {
SDL_UnlockSurface(fenetreImage);
SDL_FreeSurface(fenetreImage);
SDL_Quit();
fenetreOuverte = false;
}
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);
SDL_FillRect(fenetreImage, NULL, SDL_MapRGB(fenetreEcran->format, 0, 0, 0));
s_nomFenetre(nom);
SDL_LockSurface(fenetreImage);
fenetreOuverte = true;
}
void actualiserDimensionsEcran() {
SDL_Init(SDL_INIT_VIDEO);
const SDL_VideoInfo *info = SDL_GetVideoInfo();
ecranX = info->current_w;
ecranY = info->current_h;
SDL_Quit();
}

View file

@ -1,570 +0,0 @@
#include <vector>
#include <string>
#include <iostream>
void decoupeCommande(string commande, vector< string > &decoupe) {
// Boucle de découpage
string elementCourrant = "";
bool dansLeVide = false;
bool echape = false;
bool vaEchapper = false;
bool entreSimplesGuillemets = false;
bool entreDoublesGuillemets = false;
for (int i = 0; i < commande.length(); i++) {
echape = false;
if (vaEchapper) {
vaEchapper = false;
echape = true;
}
if (commande[i] == ' ' && !(echape || entreSimplesGuillemets ||
entreDoublesGuillemets)) {
if (!dansLeVide) {
decoupe.push_back(elementCourrant);
elementCourrant = "";
dansLeVide = true;
}
} else if (commande[i] == '\\' && !echape) {
vaEchapper = true;
} else if (commande[i] == '\'' && !(echape || entreDoublesGuillemets)) {
if (entreSimplesGuillemets) {
entreSimplesGuillemets = false;
decoupe.push_back(elementCourrant);
elementCourrant = "";
dansLeVide = true;
} else {
entreSimplesGuillemets = true;
}
} else if (commande[i] == '"' && !(echape || entreSimplesGuillemets)) {
if (entreDoublesGuillemets) {
entreDoublesGuillemets = false;
decoupe.push_back(elementCourrant);
elementCourrant = "";
dansLeVide = true;
} else {
entreDoublesGuillemets = true;
}
} else {
elementCourrant += commande[i];
dansLeVide = false;
}
}
if (!dansLeVide) {
decoupe.push_back(elementCourrant);
}
}
typedef struct Commande {
string fonction;
int x1, x2, y1, y2;
float v1;
bool b1;
string t1;
string fichier, entree, sortie;
Pixel couleur;
PILG_Comp composante;
vector< string > argumentsPresents;
} Commande;
int analyserDecoupe(Commande &commande, vector< string > decoupe,
Image const &image) {
// for (int i = 0; i < decoupe.size(); i++) { // DEBUG
// cout << "Argument " << i << " = " << decoupe[i] << endl;
// }
commande.couleur = image.g_pixelVide();
commande.fonction = decoupe[0];
// // Analyse des arguments
for (int i = 1; i < decoupe.size(); i++) {
if (decoupe[i].at(0) == '-') {
/* */ if (decoupe[i] == "-x1" || decoupe[i] == "-x0" || decoupe[i] == "-x") {
commande.argumentsPresents.push_back("x1");
i++;
if (chaineVersEntier(decoupe[i], commande.x1)) {
return 3;
}
} else if (decoupe[i] == "-y1" || decoupe[i] == "-y0" || decoupe[i] == "-y") {
commande.argumentsPresents.push_back("y1");
i++;
if (chaineVersEntier(decoupe[i], commande.y1)) {
return 3;
}
} else if (decoupe[i] == "-x2" || decoupe[i] == "-X") {
commande.argumentsPresents.push_back("x2");
i++;
if (chaineVersEntier(decoupe[i], commande.x2)) {
return 3;
}
} else if (decoupe[i] == "-y2" || decoupe[i] == "-Y") {
commande.argumentsPresents.push_back("y2");
i++;
if (chaineVersEntier(decoupe[i], commande.y2)) {
return 3;
}
} else if (decoupe[i] == "-v1" || decoupe[i] == "-v" || decoupe[i] == "-a"
|| decoupe[i] == "-r") {
commande.argumentsPresents.push_back("v1");
i++;
if (chaineVersFlottant(decoupe[i], commande.v1)) {
return 3;
}
} else if (decoupe[i] == "-b1" || decoupe[i] == "-b") {
commande.argumentsPresents.push_back("b1");
i++;
if (decoupe[i] == "1" || decoupe[i] == "vrai" || decoupe[i] == "oui") {
commande.b1 = true;
} else if (decoupe[i] == "0" || decoupe[i] == "faux" || decoupe[i] == "non") {
commande.b1 = false;
} else {
return 8;
}
} else if (decoupe[i] == "-t1" || decoupe[i] == "-t") {
commande.argumentsPresents.push_back("t1");
i++;
commande.t1 = decoupe[i];
} else if (decoupe[i] == "-f1" || decoupe[i] == "-f") {
commande.argumentsPresents.push_back("fichier");
i++;
commande.fichier = decoupe[i];
} else if (decoupe[i] == "-e") {
commande.argumentsPresents.push_back("entree");
i++;
commande.entree = decoupe[i];
} else if (decoupe[i] == "-s") {
commande.argumentsPresents.push_back("sortie");
i++;
commande.sortie = decoupe[i];
} else if (decoupe[i] == "-p") {
commande.argumentsPresents.push_back("composante");
i++;
/* */ if (decoupe[i] == "0" || decoupe[i] == "BIN") {
commande.composante = PILG_BIN;
} else if (decoupe[i] == "1" || decoupe[i] == "NIV") {
commande.composante = PILG_NIV;
} else if (decoupe[i] == "2" || decoupe[i] == "RVB") {
commande.composante = PILG_RVB;
} else {
return 10;
}
} else if (decoupe[i] == "-c") {
commande.argumentsPresents.push_back("couleur");
i++;
commande.couleur = image.g_pixelVide();
switch (image.g_typeComposantes()) {
case PILG_BIN:
if (decoupe[i] == "b" || decoupe[i] == "1") {
commande.couleur.n = true;
} else if (decoupe[i] == "n" || decoupe[i] == "0") {
commande.couleur.n = false;
} else {
return 4;
}
break;
case PILG_NIV:
int g;
if (!chaineVersEntier(decoupe[i], g)) {
return 3;
}
if (g > image.g_maxComposante()) {
return 5;
}
commande.couleur.g = g;
break;
case PILG_RVB:
int composante = 0;
string chaineCourante = "";
int entierCourant = 0;
for (int iS = 0; iS <= decoupe[i].length(); iS++) {
if (decoupe[i][iS] == ':' || iS == decoupe[i].length()) {
if (chaineVersEntier(chaineCourante, entierCourant)) {
return 3;
}
if (entierCourant > image.g_maxComposante()) {
return 5;
}
switch (composante) {
case 0:
commande.couleur.r = entierCourant;
break;
case 1:
commande.couleur.v = entierCourant;
break;
case 2:
commande.couleur.b = entierCourant;
break;
default:
return 6;
}
chaineCourante = "";
entierCourant = 0;
composante++;
} else {
chaineCourante += decoupe[i][iS];
}
}
if (composante != 3) {
return 6;
}
break;
}
if (!image.v_pixel(commande.couleur)) {
return 7;
}
} else {
cout << decoupe[i] << endl;
return 2;
}
} else {
return 1;
}
}
journal << endl;
return 0;
}
bool argumentPresent(Commande commande, string argumentVoulu) {
for (int i = 0; i < commande.argumentsPresents.size(); i++) {
if (commande.argumentsPresents[i] == argumentVoulu) {
return true;
}
}
return false;
}
int executerCommande(Commande commande, Image &image) {
if (argumentPresent(commande, "entree")) {
if (ouvrir(image, commande.entree)) {
return 4;
}
}
/* */ if (commande.fonction == "creer") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "y1")
&& argumentPresent(commande, "v1") && argumentPresent(commande, "composante")) {
if (creer(image, commande.x1, commande.y1, commande.v1, commande.composante)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "ouvrir") {
if (argumentPresent(commande, "fichier")) {
if (ouvrir(image, commande.fichier)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "sauver") {
if (argumentPresent(commande, "fichier")) {
if (!argumentPresent(commande, "b1")) {
commande.b1 = false;
}
if (!argumentPresent(commande, "t1")) {
commande.t1 = "Fichier généré par PILG";
}
if (sauver(image, commande.fichier, commande.b1, commande.t1)) {
return 3;
}
} else {
return 2;
}
// } else if (commande.fonction == "importer") {
// if (argumentPresent(commande, "fichier")) {
// if (!argumentPresent(commande, "x1")) {
// commande.x1 = 0;
// }
// if (!argumentPresent(commande, "y1")) {
// commande.y1 = 0;
// }
// if (importer(image, image, commande.fichier,)) {
// return 3;
// }
// } else {
// return 2;
// }
} else if (commande.fonction == "teinte") {
if (image.g_typeComposantes() == PILG_RVB) {
if (argumentPresent(commande, "v1")) {
if (teinte(image, image, commande.v1)) {
return 3;
}
} else {
return 2;
}
} else {
return 11;
}
} else if (commande.fonction == "saturation") {
if (image.g_typeComposantes() == PILG_RVB) {
if (argumentPresent(commande, "v1")) {
if (saturation(image, image, commande.v1)) {
return 3;
}
} else {
return 2;
}
} else {
return 11;
}
} else if (commande.fonction == "luminosite") {
if (image.g_typeComposantes() == PILG_RVB) {
if (argumentPresent(commande, "v1")) {
if (luminosite(image, image, commande.v1)) {
return 3;
}
} else {
return 2;
}
} else {
return 11;
}
// } else if (commande.fonction == "contraste") {
// if (argumentPresent(commande, "v1")) {
// if (contraste(image, image, commande.v1)) {
// return 3;
// }
// } else {
// return 2;
// }
} else if (commande.fonction == "trait") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "x2")
&& argumentPresent(commande, "y1") && argumentPresent(commande, "y2")
&& argumentPresent(commande, "couleur")) {
if (trait(image, image, commande.x1, commande.y1, commande.x2, commande.y2,
commande.couleur)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "rectangle") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "x2")
&& argumentPresent(commande, "y1") && argumentPresent(commande, "y2")
&& argumentPresent(commande, "couleur")) {
if (rectangle(image, image, commande.x1, commande.y1, commande.x2, commande.y2,
commande.couleur)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "cercle") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "y1")
&& argumentPresent(commande, "v1") && argumentPresent(commande, "couleur")) {
if (cercle(image, image, commande.x1, commande.y1, commande.v1,
commande.couleur)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "disque") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "y1")
&& argumentPresent(commande, "v1") && argumentPresent(commande, "couleur")) {
if (disque(image, image, commande.x1, commande.y1, commande.v1,
commande.couleur)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "pivoter") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "y1")
&& argumentPresent(commande, "v1")) {
if (pivoter(image, image, commande.x1, commande.y1, commande.v1)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "retourner") {
if (argumentPresent(commande, "v1")) {
if (retourner(image, image, commande.v1)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "redimensionner") {
if (argumentPresent(commande, "x1") && argumentPresent(commande, "x2")
&& argumentPresent(commande, "y1") && argumentPresent(commande, "y2")) {
if (redimensionner(image, image, commande.x1, commande.y1, commande.x2,
commande.y2)) {
return 3;
}
} else {
return 2;
}
} else if (commande.fonction == "convBIN") {
if (convBIN(image, image)) {
return 3;
}
} else if (commande.fonction == "convNIV") {
if (convNIV(image, image)) {
return 3;
}
} else if (commande.fonction == "convRVB") {
if (convRVB(image, image)) {
return 3;
}
} else {
return 1;
}
if (argumentPresent(commande, "sortie")) {
if (sauver(image, commande.sortie, false, "Fichier généré par PILG")) {
return 4;
}
}
return 0;
}
int procederCommande(vector< string > decoupe, Image &image) {
journal << "Commande : ";
for (int i = 0; i < decoupe.size(); i++) {
journal << "«" << decoupe[i] << "» ";
}
Commande commande;
int code;
code = analyserDecoupe(commande, decoupe, image);
switch (code) {
case 0:
code = executerCommande(commande, image);
switch (code) {
case 0:
journal << "Succès" << endl;
break;
case 1:
messageErreur("Fonction inconnue");
break;
case 2:
messageErreur("Arguments manquants");
break;
case 3:
messageErreur("Erreur dans l'execution de la commande");
break;
case 4:
messageErreur("Impossible d'ouvrir l'entrée");
default:
messageErreur("Impossible d'éxecuter la fonction");
break;
}
return code;
case 1:
messageErreur("Un argument a été attendu et autre chose a été donné");
break;
case 2:
messageErreur("Argument inconnu");
break;
case 3:
messageErreur("Un nombre a été attendu et n'a pas été donné");
break;
case 4:
messageErreur("La couleur d'une image binaire doit être blanc (1) ou noir (0)");
break;
case 5:
messageErreur("La valeur d'une composante de couleur donnée est superieure au maximum de composante de l'image");
break;
case 6:
messageErreur("La couleur d'une image RVB possède trois composantes");
break;
case 7:
messageErreur("La couleur donnée n'est pas valide, la raison en est inconnue");
break;
case 8:
messageErreur("Un booléen (vrai/faux) a été attendu mais n'a pas été donné");
break;
case 9:
messageErreur("Une chaine de caractères a été attendue mais n'a pas été donnée");
break;
case 10:
messageErreur("La composante donnée n'est pas valide");
break;
case 11:
messageErreur("Il est nécessaire d'avoir une image en mode RVB pour executer cette commande");
break;
default:
messageErreur("Impossible d'analyser la commande");
break;
}
return code;
}
void boucleDeCommandes(Image image) { // REPL
bool continuer = true;
string commandeTexte;
while (continuer) {
cout << "$ ";
getline(cin, commandeTexte);
if (commandeTexte == "quitter") {
continuer = false;
} else {
vector< string > decoupe;
decoupeCommande(commandeTexte, decoupe);
procederCommande(decoupe, image);
afficherImage(image);
}
}
}

View file

@ -1,113 +0,0 @@
#include "image.h"
Image::Image(int dimensionX, int dimensionY, int maxComposante,
PILG_Comp typeComposantes): m_dimensionX(dimensionX), m_dimensionY(dimensionY),
m_maxComposante(maxComposante), m_typeComposantes(typeComposantes) {
Pixel pixelVide = g_pixelVide();
for (int xT = 0; xT < dimensionX; xT++) {
std::vector< Pixel > colonne;
for (int yT = 0; yT < dimensionY; yT++) {
colonne.push_back(pixelVide);
}
m_tab.push_back(colonne);
}
}
// Getters
int Image::g_dimensionX() const {
return m_dimensionX;
}
int Image::g_dimensionY() const {
return m_dimensionY;
}
PILG_Comp Image::g_typeComposantes() const {
return m_typeComposantes;
}
int Image::g_maxComposante() const {
return m_maxComposante;
}
int Image::g_pixel(int x, int y, Pixel &pixel) const {
if (v_dimensions(x, y)) {
pixel = m_tab[x][y];
return 0;
} else {
pixel = g_pixelVide();
return 1;
}
}
// Setters
int Image::s_pixel(int x, int y, Pixel pixel) {
if (v_dimensions(x, y) && v_pixel(pixel)) {
m_tab[x][y] = pixel;
return 0;
} else {
return 1;
}
}
// Utilitaires
Pixel Image::g_pixelVide() const {
Pixel pixel;
pixel.typeComposantes = m_typeComposantes;
pixel.maxComposante = m_maxComposante;
switch (pixel.typeComposantes) {
case PILG_BIN:
pixel.b = false;
break;
case PILG_NIV:
pixel.g = 0;
break;
case PILG_RVB:
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
&& pixel.maxComposante == m_maxComposante) {
switch (pixel.typeComposantes) {
case PILG_BIN:
return true;
break;
case PILG_NIV:
return (pixel.g <= pixel.maxComposante);
break;
case PILG_RVB:
return (pixel.r <= pixel.maxComposante
&& pixel.v <= pixel.maxComposante
&& pixel.b <= pixel.maxComposante);
break;
default:
return false;
break;
}
} else {
return false;
}
}
bool Image::v_dimensions(int x, int y) const {
return (x >= 0 && x < m_dimensionX && y >= 0 && y < m_dimensionY);
}

View file

@ -1,41 +0,0 @@
#include <vector>
typedef enum {PILG_BIN, PILG_NIV, PILG_RVB} PILG_Comp;
typedef struct {
PILG_Comp typeComposantes;
int maxComposante;
int r;
int v;
int b;
int g;
bool n;
} Pixel;
class Image {
public:
Image(int dimensionX, int dimensionY, int maxComposante,
PILG_Comp typeComposantes);
// Getters
int g_dimensionX() const;
int g_dimensionY() const;
PILG_Comp g_typeComposantes() const;
int g_maxComposante() const;
int g_pixel(int x, int y, Pixel &pixel) const;
// Setters
int s_pixel(int x, int y, Pixel pixel);
// Utilitaires
Pixel g_pixelVide() const;
Image g_vide() const;
// Validateurs
bool v_pixel(Pixel pixel) const;
bool v_dimensions(int x, int y) const;
private:
// Variables
int m_dimensionX;
int m_dimensionY;
PILG_Comp m_typeComposantes;
int m_maxComposante; // Maximum de composante (sauf binaire)
std::vector< std::vector< Pixel > > m_tab;
};

View file

@ -1,38 +0,0 @@
#include <iostream>
using namespace std;
#include "affichageFenetre.cpp"
#include "image.h"
#include "utilitaires.cpp"
#include "traitementImage.cpp"
#include "analyserCommande.cpp"
int main(int argc, char *args[]) {
#if defined(WIN32) // Permet de refaire fonctionner cout et cerr sous Windows après démarrage de SDL
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);
#endif
presentation();
cout << endl;
Image image = imageDefaut();
int code;
if (argc > 1) { // Si la commande a été entrée avec des arguments
vector< string > decoupe;
for (int i = 1; i < argc; i++) {
decoupe.push_back(args[i]);
}
code = procederCommande(decoupe, image);
} else {
actualiserDimensionsEcran();
afficherImage(image);
boucleDeCommandes(image);
code = 0;
}
journal.close();
return code;
}

View file

@ -1,229 +0,0 @@
#include <iostream>
#include <string>
using namespace std;
#include "affichageFenetre.cpp"
#include "image.h"
#include "utilitaires.cpp"
#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();
int x, y, step;
float substep, lum;
for (x = 0; x < dimX; x++) {
for (y = 0; y < dimY; y++) {
step = (x * 6.0) / dimX;
substep = (x - step * (dimX / 6.0)) / (dimX / 6.0) * maxComposante;
lum = 1 - ((float) y) / dimY;
switch (step) {
case 0:
pointRoue.r = maxComposante;
pointRoue.v = substep;
pointRoue.b = 0;
break;
case 1:
pointRoue.r = maxComposante - substep;
pointRoue.v = maxComposante;
pointRoue.b = 0;
break;
case 2:
pointRoue.r = 0;
pointRoue.v = maxComposante;
pointRoue.b = substep;
break;
case 3:
pointRoue.r = 0;
pointRoue.v = maxComposante - substep;
pointRoue.b = maxComposante;
break;
case 4:
pointRoue.r = substep;
pointRoue.v = 0;
pointRoue.b = maxComposante;
break;
case 5:
pointRoue.r = maxComposante;
pointRoue.v = 0;
pointRoue.b = maxComposante - substep;
break;
}
// Dégradé vers le noir
pointRoue.r = pointRoue.r * lum;
pointRoue.v = pointRoue.v * lum;
pointRoue.b = pointRoue.b * lum;
// // Remise dans l'intervalle
// pointRoue.r = (pointRoue.r > maxComposante ? maxComposante : pointRoue.r);
// pointRoue.v = (pointRoue.v > maxComposante ? maxComposante : pointRoue.v);
// pointRoue.b = (pointRoue.b > maxComposante ? maxComposante : pointRoue.b);
if (imageRoue.s_pixel(x, y, pointRoue) == 1) {
journal << "Erreur : s_pixel() a été entré avec des valeurs incorrectes" <<
endl;
journal << "X : " << x << " - Y: " << y << " - R : " << pointRoue.r << " - V : "
<<
pointRoue.v << " - B : " << pointRoue.b << endl;
}
imageRoue.g_pixel(x, y, pointRoue);
}
}
return imageRoue;
}
Image genererDegrade(int dimX, int dimY, int maxComposante) {
Image image(dimX, dimY, maxComposante, PILG_NIV);
Pixel pixel = image.g_pixelVide();
int x, y;
for (x = 0; x < dimX; x++) {
for (y = 0; y < dimY; y++) {
pixel.g = (float) x * maxComposante / dimX;
image.s_pixel(x, y, pixel);
}
}
return image;
}
Image genererBruit(int dimX, int dimY) {
Image image(dimX, dimY, 0, PILG_BIN);
Pixel pixel = image.g_pixelVide();
int x, y;
for (x = 0; x < dimX; x++) {
for (y = 0; y < dimY; y++) {
pixel.n = ((float) rand() / RAND_MAX) < ((float) x / dimX);
image.s_pixel(x, y, pixel);
}
}
return image;
}
int appliquer(Image &image, string nomFichier, bool ASCII) {
ouvrir(image, "tests/" + nomFichier);
Pixel pixel;
image.g_pixel(image.g_dimensionX() / 2, image.g_dimensionY() / 2, pixel);
// teinte(image, image, 180);
// saturation(image, image, 0.3);
// luminosite(image, image, -0.5);
// trait(image, image, image.g_dimensionX() / 4, image.g_dimensionY() / 4,
// image.g_dimensionX() - image.g_dimensionX() / 4,
// image.g_dimensionY() - image.g_dimensionY() / 4, pixel);
// cercle(image, image, image.g_dimensionX() / 2, image.g_dimensionY() / 2,
// image.g_dimensionY() / 4, pixel);
// disque(image, image, image.g_dimensionX() / 2, image.g_dimensionY() / 2,
// image.g_dimensionY() / 4, pixel);
// redimensionner(image, image, image.g_dimensionX() / 4, image.g_dimensionY() / 4,
// image.g_dimensionX() - image.g_dimensionX() / 4,
// image.g_dimensionY() - image.g_dimensionY() / 4);
// redimensionner(image, image, 0, 0, image.g_dimensionY(), image.g_dimensionY());
// retourner(image, image, 3);
// convBIN(image, image);
// convNIV(image, image);
// convRVB(image, image);
sauver(image, "tests/E_" + nomFichier, ASCII, nomFichier);
afficherImage(image);
attendreFenetre();
}
int main(int argc, char *args[]) {
#if defined(WIN32) // Permet de refaire fonctionner cout et cerr sous Windows après démarrage de SDL
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);
#endif
presentation();
cout << "Éxecution des instructions dans testing.cpp." << endl << endl;
actualiserDimensionsEcran();
#define DIMENSIONS 255
// Image image1 = genererRoue(DIMENSIONS, DIMENSIONS, 255);
Image image1 = imageDefaut();
// Image image = image1.g_vide();
// ouvrir(image1, "tests/PikachuP6.ppm");
// Image image2 = genererRoue(DIMENSIONS * 2, DIMENSIONS, 255);
// afficherImage(image1);
// attendreFenetre();
// Ouvrir fichier
// appliquer(image1, "PikachuP1.pbm", true);
// appliquer(image1, "PikachuP2.pgm", true);
// appliquer(image1, "PikachuP3.ppm", true);
// appliquer(image1, "PikachuP4.pbm", false);
// appliquer(image1, "PikachuP5.pgm", false);
// appliquer(image1, "PikachuP6.ppm", false);
// // Chronomètre
// int tempsDepart = clock();
// journal << "Temps d'execution: " << (float)(clock() - tempsDepart) / 1000000 <<
// "s" << endl;
// // Afficher différentes tailles de fenêtre
// for (int i = 500; i < 1200; i += 10) {
// image1 = genererRoue(i * 2, i, 255);
// afficherImage(image1);
// // attendreFenetre();
// }
// // Roue
// Image image = image1.g_vide();
// for (float i = 0; i < 2 * PI; i += 0.1) {
// pivoter(image1, image, DIMENSIONS/2, DIMENSIONS/2, i);
// afficherImage(image);
// }
// // Roue des couleurs
// for (float i = -1; i <= 1; i += 0.01) {
// teinte(image1, image, i);
// afficherImage(image);
// }
// // Neige en dégradé
// for (int i; i < 300; i++) {
// afficherImage(genererBruit(200, 200));
// }
// Cycle de couleurs avec utilisation d'Image
// Image imageRoue(dimX, dimY, 255, PILG_RVB);
// Pixel pointRoueRoue = imageRoue.g_pixelVide();
// int x, y, c;
// for (c = 0; c < 256; c++) { // À peu près 28 FPS avec SDL
// for (x = 0; x < dimX; x++) {
// for (y = 0; y < dimY; y++) {
// pixel.r = c;
// pixel.v = image.g_maxComposante() - c;
// pixel.b = 0;
// if (image.s_pixel(x, y, pixel) == 1) {
// cerr << "Erreur : s_pixel() a été entré avec des valeurs incorrectes" << endl;
// cout << "X : " << x << " - Y: " << y << " - R : " << pixel.r << " - V : " << pixel.v << " - B : " << pixel.b << endl; // DEBUG
// return 1;
// }
// image.g_pixel(x, y, pixel);
// pointFenetre(x, y, pixel.r, pixel.v, pixel.b);
// }
// }
// afficherFenetre();
// }
// // Cycle de couleurs sans utilisation d'Image
// int x, y, c;
// for (c = 0; c < 256; c++) { // À peu près 75 FPS avec SDL
// for (x = 0; x < dimX; x++) {
// for (y = 0; y < dimY; y++) {
// pointFenetre(x, y, c, 255 - c, 0);
// }
// }
// afficherFenetre();
// }
// cout << "Éxecution du programme terminée. Vous pouvez quitter la fenêtre." << endl;
// fermerFenetre();
journal.close();
return 0;
}

View file

@ -1,694 +0,0 @@
#include <fstream>
#define PI 3.14159265359
#define MAXCOMPOSANTEDEFAUT 255
#define FICHIER_SEPARATEUR (char) 0x0a
typedef enum {PILG_TYPE, PILG_DIMENSIONS, PILG_MAXCOMPOSANTE, PILG_IMAGE} PILG_OuvrirEtape;
// Gestion de fichiers
int creer(Image &sortie, int dimensionX, int dimensionY, int maxComposante,
PILG_Comp typeComposantes) { // Créer une image de dimensions X et Y
sortie = *new Image(dimensionX, dimensionY, maxComposante, typeComposantes);
return 0;
}
int ouvrir(Image &sortie,
string nomFichier) { // Ouvrir une image existante à partir du nom du fichier
// Ouverture du fichier
journal << "" << nomFichier << endl;
ifstream streamFichier(nomFichier.c_str(), ios::in);
if (streamFichier) {
// Calcul de la taille (en octets) du fichier
streamFichier.seekg(0, ios::end);
int tailleFichier(streamFichier.tellg());
// Stockage du fichier dans une chaîne
streamFichier.seekg(0, ios::beg);
char *fichier_caracteres = new char [tailleFichier];
streamFichier.read(fichier_caracteres, tailleFichier);
streamFichier.close();
// Variables d'informations
char cara;
PILG_OuvrirEtape ouvrirEtape(PILG_TYPE);
bool ASCII(false);
int dimensionX;
int dimensionY;
int maxComposante;
PILG_Comp typeComposantes;
// Variables de traitement du fichier
string element("");
int x(0);
int y(0);
int i(0);
Pixel pixel;
string tmpASCII;
char RVBcomposante(0); // Composante actuelle pour RVB
for (int c(0); c < tailleFichier; c++) {
cara = fichier_caracteres[c];
if (ouvrirEtape != PILG_IMAGE) {
if (cara == FICHIER_SEPARATEUR) { // En cas de nouvel élément
if (element[0] !=
'#') { // Si c'est un commentaire, on passe à l'élément suivant
switch (ouvrirEtape) {
case PILG_TYPE:
if (element.length() == 2 && element[0] == 'P') {
switch (element[1]) {
case '1':
case '4':
typeComposantes = PILG_BIN;
break;
case '2':
case '5':
typeComposantes = PILG_NIV;
break;
case '3':
case '6':
typeComposantes = PILG_RVB;
break;
default:
return 3;
break;
}
switch (element[1]) {
case '1':
case '2':
case '3':
ASCII = true;
break;
case '4':
case '5':
case '6':
ASCII = false;
break;
default:
return 3;
break;
}
} else {
return 3;
}
ouvrirEtape = PILG_DIMENSIONS;
journal << "Type de fichier : " << element << " (" << ((
typeComposantes == 0) ? "Noir et Blanc" : ((typeComposantes == 1) ?
"Niveaux de gris" : "Rouge / Vert / Bleu")) << ", " << (ASCII ? "ASCII" :
"Brut") << ")" << endl;
break;
case PILG_DIMENSIONS: {
bool espaceDepasse(false);
string dimensionXchaine("");
string dimensionYchaine("");
for (int j(0); j < element.size(); j++) {
if (element[j] == ' ') {
espaceDepasse = true;
} else if (espaceDepasse) {
dimensionYchaine += element[j];
} else {
dimensionXchaine += element[j];
}
}
chaineVersEntier(dimensionXchaine, dimensionX);
chaineVersEntier(dimensionYchaine, dimensionY);
if (!espaceDepasse || dimensionX == 0 || dimensionY == 0) {
return 5;
}
journal << "Dimensions : " << dimensionX << " px / " << dimensionY << "px" <<
endl;
if (typeComposantes == PILG_BIN) {
ouvrirEtape = PILG_IMAGE;
} else {
ouvrirEtape = PILG_MAXCOMPOSANTE;
}
}
break;
case PILG_MAXCOMPOSANTE:
chaineVersEntier(element, maxComposante);
journal << "Maximum de composante" << ((typeComposantes == 2) ? "s" : "") <<
" : "
<< maxComposante << endl;
ouvrirEtape = PILG_IMAGE;
break;
default:
return 4;
break;
}
if (ouvrirEtape == PILG_IMAGE) {
sortie = *new Image(dimensionX, dimensionY, maxComposante, typeComposantes);
pixel = sortie.g_pixelVide();
}
}
element = "";
} else {
element += cara;
}
} else {
if (ASCII) {
if (typeComposantes == PILG_BIN) {
if (cara != FICHIER_SEPARATEUR) {
pixel.n = (cara == 0x31) ? false : true;
sortie.s_pixel(x, y, pixel);
x++;
}
} else {
if (cara == FICHIER_SEPARATEUR) {
if (typeComposantes == PILG_RVB) {
switch (RVBcomposante) {
case 0:
chaineVersEntier(tmpASCII, pixel.r);
RVBcomposante = 1;
break;
case 1:
chaineVersEntier(tmpASCII, pixel.v);
RVBcomposante = 2;
break;
case 2:
chaineVersEntier(tmpASCII, pixel.b);
RVBcomposante = 0;
sortie.s_pixel(x, y, pixel);
x++;
break;
}
} else {
chaineVersEntier(tmpASCII, pixel.g);
sortie.s_pixel(x, y, pixel);
x++;
}
tmpASCII = "";
} else {
tmpASCII += cara;
}
}
} else {
if (typeComposantes == PILG_BIN) {
for (i = 7; i >= 0; i--) {
pixel.n = !((cara >> i) & 0x01);
sortie.s_pixel(x, y, pixel);
x++;
if (x >= dimensionX) {
y++;
x = 0;
}
}
} else {
if (typeComposantes == PILG_RVB) {
switch (RVBcomposante) {
case 0:
pixel.r = caraVersEntier(cara);
RVBcomposante = 1;
break;
case 1:
pixel.v = caraVersEntier(cara);
RVBcomposante = 2;
break;
case 2:
pixel.b = caraVersEntier(cara);
RVBcomposante = 0;
sortie.s_pixel(x, y, pixel);
x++;
break;
}
} else {
pixel.g = caraVersEntier(cara);
sortie.s_pixel(x, y, pixel);
x++;
}
}
}
if (x >= dimensionX) {
y++;
x += -dimensionX;
}
}
}
} else {
journal << "Impossible d'ouvrir le fichier" << endl;
return 1;
}
journal << endl;
return 0;
}
int sauver(Image entree, string nomFichier, bool ASCII,
string commentaire) { // Sauvegarder l'image obtenue dans un nouveau fichier
ofstream fichier(nomFichier.c_str(), ios::out | ios::trunc);
char numero;
switch (entree.g_typeComposantes()) {
case PILG_BIN:
numero = ASCII ? '1' : '4';
break;
case PILG_NIV:
numero = ASCII ? '2' : '5';
break;
case PILG_RVB:
numero = ASCII ? '3' : '6';
break;
default:
return 1;
}
fichier << "P" << numero << FICHIER_SEPARATEUR;
if (commentaire != "") {
fichier << "# " << commentaire << FICHIER_SEPARATEUR;
}
fichier << entree.g_dimensionX() << " " << entree.g_dimensionY() <<
FICHIER_SEPARATEUR;
if (entree.g_typeComposantes() != PILG_BIN) {
fichier << entree.g_maxComposante() << FICHIER_SEPARATEUR;;
}
Pixel pixel;
char brutBINpixel;
int brutBINpixelRang = 7;
for (int y = 0; y < entree.g_dimensionY(); y++) {
for (int x = 0; x < entree.g_dimensionX(); x++) {
entree.g_pixel(x, y, pixel);
switch (entree.g_typeComposantes()) {
case PILG_BIN:
if (ASCII) {
if (pixel.n) {
fichier << '0';
} else {
fichier << '1';
}
} else {
if (pixel.n) {
brutBINpixel &= ~(1 << brutBINpixelRang);
} else {
brutBINpixel |= 1 << brutBINpixelRang;
}
brutBINpixelRang--;
if (brutBINpixelRang < 0) {
fichier << brutBINpixel;
brutBINpixelRang = 7;
}
}
break;
case PILG_NIV:
if (ASCII) {
fichier << pixel.g << FICHIER_SEPARATEUR;
} else {
fichier << (char) pixel.g;
}
break;
case PILG_RVB:
if (ASCII) {
fichier << pixel.r << FICHIER_SEPARATEUR
<< pixel.v << FICHIER_SEPARATEUR
<< pixel.b << FICHIER_SEPARATEUR;
} else {
fichier << (char) pixel.r
<< (char) pixel.v
<< (char) pixel.b;
}
break;
default:
return 1;
}
}
}
fichier.close();
return 0;
}
int importer(Image entree, Image &sortie, string nomFichier, int x, int y) {
// Image fichierImporte;
// sortie = entree
// ouvrir(fichierImporte, nomFichier)
// Pour x1 = 0 to x1 = fichierImporte.g_dimensionX
// Pour y1 = 0 to y1 = fichierImporte.g_dimensionY
// sortie.s_pixel(x1 + x, y1 + y, fichierImporte.g_pixel(x1, x2));
// FinPour
// FinPour
return 1;
}
// Couleur
int teinte(Image entree, Image &sortie,
float teinte) { // Change la teinte de l'image
sortie = entree.g_vide();
Pixel pixel;
TSL tsl;
for (int x = 0; x < sortie.g_dimensionX(); x++) {
for (int y = 0; y < sortie.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixel);
rvb2tsl(pixel, tsl);
tsl.t += teinte;
tsl2rvb(tsl, pixel);
sortie.s_pixel(x, y, pixel);
}
}
return 0;
}
int saturation(Image entree, Image &sortie,
float saturation) { // Sature l'image
sortie = entree.g_vide();
Pixel pixel;
TSL tsl;
for (int x = 0; x < sortie.g_dimensionX(); x++) {
for (int y = 0; y < sortie.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixel);
rvb2tsl(pixel, tsl);
tsl.s *= saturation;
tsl.s = tsl.s > 1 ? 1 : (tsl.s < 0 ? 0 : tsl.s);
tsl2rvb(tsl, pixel);
sortie.s_pixel(x, y, pixel);
}
}
return 0;
}
int luminosite(Image entree, Image &sortie,
float luminosite) { // Augmente la luminosité de l'image
sortie = entree.g_vide();
Pixel pixel;
TSL tsl;
for (int x = 0; x < sortie.g_dimensionX(); x++) {
for (int y = 0; y < sortie.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixel);
rvb2tsl(pixel, tsl);
tsl.l *= luminosite;
tsl.l = tsl.l > 1 ? 1 : (tsl.l < 0 ? 0 : tsl.l);
tsl2rvb(tsl, pixel);
sortie.s_pixel(x, y, pixel);
}
}
return 0;
}
int contraste(Image entree, Image &sortie,
float contraste) { // Accentue les contrastes de l'image
// À voir
return 1;
}
// Dessin
int trait(Image entree, Image &sortie, int x1, int y1, int x2, int y2,
Pixel couleur) { // Dessine un trait d'un point (x1,y1) à un point (x2,y2)
int x;
sortie = entree;
for (x = 0; x <= x2 - x1; x++) {
// cout << "(" << x << ";__) a=" << ((float) x / (x2 - x1)) << " yD=" <<
// (y2 - y1) * ((float)x / (x2 - x1)) << endl;
sortie.s_pixel(x1 + x, y1 + (y2 - y1) * ((float) x / (x2 - x1)), couleur);
}
return 0;
}
int rectangle(Image entree, Image &sortie, int x1, int y1, int x2, int y2,
Pixel couleur) {
sortie = entree;
for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
sortie.s_pixel(x, y, couleur);
}
}
return 0;
}
int cercle(Image entree, Image &sortie, int x0, int y0, int r, Pixel couleur) {
sortie = entree;
for (int x = 0; x <= entree.g_dimensionX(); x++) {
for (int y = 0; y <= entree.g_dimensionY(); y++) {
if ((int) sqrt(pow(x - x0, 2) + pow(y - y0, 2)) == r) {
sortie.s_pixel(x, y, couleur);
}
}
}
return 0;
}
int disque(Image entree, Image &sortie, int x0, int y0, int r, Pixel couleur) {
sortie = entree;
for (int x = 0; x <= entree.g_dimensionX(); x++) {
for (int y = 0; y <= entree.g_dimensionY(); y++) {
if ((int) sqrt(pow(x - x0, 2) + pow(y - y0, 2)) <= r) {
sortie.s_pixel(x, y, couleur);
}
}
}
return 0;
}
// Geométrie
int zoom(Image entree, Image &sortie) {
return 1;
}
int 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 : 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);
}
}
return 0;
}
int retourner(Image entree, Image &sortie, int rotation) {
rotation = rotation % 4;
int x, y;
Pixel pixel;
if (rotation == 0) {
sortie = entree;
} else {
if (rotation == 2) {
sortie = entree.g_vide();
} else {
sortie = *new Image(entree.g_dimensionY(), entree.g_dimensionX(),
entree.g_maxComposante(), entree.g_typeComposantes());
}
for (x = 0; x < entree.g_dimensionX(); x++) {
for (y = 0; y < entree.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixel);
switch (rotation) {
case 1:
sortie.s_pixel(entree.g_dimensionY() - y - 1, x, pixel);
break;
case 2:
journal << "5";
sortie.s_pixel(entree.g_dimensionX() - x - 1, entree.g_dimensionY() - y - 1,
pixel);
break;
case 3:
sortie.s_pixel(y, entree.g_dimensionX() - x - 1, pixel);
break;
default:
journal << "6";
return 1;
}
}
}
}
return 0;
}
int redimensionner(Image entree, Image &sortie, int x1, int y1, int x2,
int y2) {
sortie = *new Image(x2 - x1, y2 - y1, entree.g_maxComposante(),
entree.g_typeComposantes());
Pixel pixel;
for (int x = 0; x <= x2 - x1; x++) {
for (int y = 0; y <= y2 - y1; y++) {
entree.g_pixel(x1 + x, y1 + y, pixel);
sortie.s_pixel(x, y, pixel);
}
}
return 0;
}
// Modification couleur
int convBIN(Image entree, Image &sortie) {
if (entree.g_typeComposantes() == PILG_BIN) {
sortie = entree;
} else {
sortie = *new Image(entree.g_dimensionX(), entree.g_dimensionY(), 0, PILG_BIN);
Pixel pixelI, pixelF;
pixelF = sortie.g_pixelVide();
for (int x = 0; x <= entree.g_dimensionX(); x++) {
for (int y = 0; y <= entree.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixelI);
switch (entree.g_typeComposantes()) {
case PILG_NIV:
pixelF.n = (pixelI.g > (entree.g_maxComposante() / 2));
break;
case PILG_RVB:
pixelF.n = ((pixelI.r + pixelI.v + pixelI.b) / 3 > (entree.g_maxComposante() /
2));
break;
default:
return 2;
}
sortie.s_pixel(x, y, pixelF);
}
}
}
return 0;
}
int convNIV(Image entree, Image &sortie) {
if (entree.g_typeComposantes() == PILG_NIV) {
sortie = entree;
} else {
sortie = *new Image(entree.g_dimensionX(), entree.g_dimensionY(),
MAXCOMPOSANTEDEFAUT, PILG_NIV);
Pixel pixelI, pixelF;
pixelF = sortie.g_pixelVide();
for (int x = 0; x <= entree.g_dimensionX(); x++) {
for (int y = 0; y <= entree.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixelI);
switch (entree.g_typeComposantes()) {
case PILG_BIN:
pixelF.g = (pixelI.n ? sortie.g_maxComposante() : 0);
break;
case PILG_RVB:
pixelF.g = (pixelI.r + pixelI.v + pixelI.b) / 3.0 / entree.g_maxComposante() *
sortie.g_maxComposante();
break;
default:
return 1;
}
sortie.s_pixel(x, y, pixelF);
}
}
}
return 0;
}
int convRVB(Image entree, Image &sortie) {
if (entree.g_typeComposantes() == PILG_RVB) {
sortie = entree;
} else {
sortie = *new Image(entree.g_dimensionX(), entree.g_dimensionY(),
MAXCOMPOSANTEDEFAUT, PILG_RVB);
Pixel pixelI, pixelF;
pixelF = sortie.g_pixelVide();
for (int x = 0; x <= entree.g_dimensionX(); x++) {
for (int y = 0; y <= entree.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixelI);
switch (entree.g_typeComposantes()) {
case PILG_BIN:
pixelF.r = pixelF.v = pixelF.b = (pixelI.n ? sortie.g_maxComposante() : 0);
break;
case PILG_NIV:
pixelF.r = pixelF.v = pixelF.b = (float) pixelI.g / entree.g_maxComposante() *
sortie.g_maxComposante();
break;
default:
return 1;
}
sortie.s_pixel(x, y, pixelF);
}
}
}
return 0;
}
// Aide
int aide() {
// Afficher le texte suivant :
return 1;
}

View file

@ -1,220 +0,0 @@
#include <math.h>
#include <fstream>
#define NOMBREOR 1.61803398875
ofstream journal("PILG-log.txt", ios::out | ios::trunc);
void presentation() {
cout << " ____ ___ _ ____ " << endl
<< "| _ \\ |_ _ || | / ___|" << endl
<< "| |_) | | | | | | | _ " << endl
<< "| __/ | | | |___ | |_| |" << endl
<< "|_| |___| |_____| \\____|" << endl;
}
typedef struct {
double t;
double s;
double l;
} TSL;
int rvb2tsl(Pixel entree, TSL &sortie) {
double min, max, r = (float) entree.r / entree.maxComposante,
v = (float) entree.v / entree.maxComposante,
b = (float) entree.b / entree.maxComposante;
min = r < v ? r : v;
min = min < b ? min : b;
max = r > v ? r : v;
max = max > b ? max : b;
sortie.l = (max + min) / 2;
if (max == min) {
sortie.s = 0;
sortie.t = NAN;
} else {
sortie.s = sortie.l < 0.5 ? (max - min) / (max + min) : (max - min) /
(2 - max - min);
}
if (r == max) {
sortie.t = (v - b) / (max - min);
} else if (v == max) {
sortie.t = 2 + (b - r) / (max - min);
} else if (b == max) {
sortie.t = 4 + (r - v) / (max - min);
}
sortie.t *= 60;
if (sortie.t < 0) {
sortie.t += 360;
}
return 0;
}
int tsl2rvb(TSL entree, Pixel &sortie) {
double t3[3], c[3], t2, t1;
while (entree.t < 0.0) {
entree.t += 360.0;
}
while (entree.t > 360.0) {
entree.t += -360.0;
}
if (entree.s == 0) {
fill_n(c, 3, entree.l);
} else {
fill_n(t3, 3, 0);
fill_n(c, 3, 0);
t2 = entree.l < 0.5 ? entree.l * (1 + entree.s) : entree.l + entree.s - entree.l
* entree.s;
t1 = 2 * entree.l - t2;
entree.t /= 360.0;
t3[0] = entree.t + 1 / 3.0;
t3[1] = entree.t;
t3[2] = entree.t - 1 / 3.0;
for (int i = 0; i <= 2; i++) {
if (t3[i] < 0) {
t3[i] += 1;
}
if (t3[i] > 1) {
t3[i] -= 1;
}
if (6 * t3[i] < 1) {
c[i] = t1 + (t2 - t1) * 6 * t3[i];
} else if (2 * t3[i] < 1) {
c[i] = t2;
} else if (3 * t3[i] < 2) {
c[i] = t1 + (t2 - t1) * ((2 / 3.0) - t3[i]) * 6;
} else {
c[i] = t1;
}
}
}
sortie.r = c[0] * sortie.maxComposante;
sortie.v = c[1] * sortie.maxComposante;
sortie.b = c[2] * sortie.maxComposante;
return 0;
}
Image imageDefaut() {
int dimY = 256, dimX = dimY * NOMBREOR, maxComposante = 255;
Image imageRoue(dimX, dimY, maxComposante, PILG_RVB);
int x, y;
TSL tsl;
Pixel pointRoue = imageRoue.g_pixelVide();
tsl.s = 1;
for (x = 0; x < dimX; x++) {
for (y = 0; y < dimY; y++) {
tsl.t = ((float) x / dimX) * 360;
tsl.l = 1 - ((float) y / dimY);
tsl2rvb(tsl, pointRoue);
imageRoue.s_pixel(x, y, pointRoue);
}
}
return imageRoue;
}
void afficherImage(Image image) {
#define MARGE 100
int x, y, r, v, b, eX, eY, echelle, contenableX, contenableY,
dimensionX = image.g_dimensionX(),
dimensionY = image.g_dimensionY(),
typeComposantes = image.g_typeComposantes();
float ratio = (255.0 / image.g_maxComposante());
Pixel pixel;
// Calcul de l'échelle
contenableX = (ecranX - MARGE) / dimensionX;
contenableY = (ecranY - MARGE) / dimensionY;
echelle = (contenableX > contenableY ? contenableY : contenableX);
echelle = (echelle > 0 ? echelle : 1);
dimensionX = dimensionX * echelle;
dimensionY = dimensionY * echelle;
// journal << "Fenêtre: Image(" << image.g_dimensionX() << ";" <<
// image.g_dimensionY() << "), Echelle(" << echelle << "), Fenetre(" <<
// dimensionX << ";" << dimensionY << ")" << endl;
if (fenetreOuverte && (dimensionX != fenetreDimensionX ||
dimensionY != fenetreDimensionY)) {
fermerFenetre();
}
ouvrirFenetre(dimensionX, dimensionY, "PILG");
for (x = 0; x < image.g_dimensionX(); x++) {
for (y = 0; y < image.g_dimensionY(); y++) {
image.g_pixel(x, y, pixel);
switch (typeComposantes) {
case PILG_BIN:
r = v = b = (pixel.n ? 255 : 0);
break;
case PILG_NIV:
r = v = b = pixel.g * ratio;
break;
case PILG_RVB:
r = pixel.r * ratio;
v = pixel.v * ratio;
b = pixel.b * ratio;
break;
}
for (eX = 0; eX < echelle; eX++) {
for (eY = 0; eY < echelle; eY++) {
pointFenetre(x * echelle + eX, y * echelle + eY, r, v, b);
}
}
}
}
afficherFenetre();
}
void messageErreur(string message) {
cerr << "Erreur : " << message << '.' << endl;
journal << "Erreur : " << message << '.' << endl;
}
int chaineVersEntier(string chaine, int &entier) {
entier = atoi(chaine.c_str());
if (entier == 0 && chaine != "0") {
return 1;
}
return 0;
}
int chaineVersFlottant(string chaine, float &flottant) {
flottant = atof(chaine.c_str());
if (flottant == 0 && chaine != "0") {
return 1;
}
return 0;
}
int caraVersEntier(char cara) {
// int entier = (int) (0 << 8) + cara;
// entier = entier > 0 ? entier : 256+entier;
int i, entier = 0;
for (i = 0; i < 8; i++) {
entier += ((cara >> i) & 0x01) ? pow(2, i) : 0;
}
return entier;
}

3
tests/.gitignore vendored
View file

@ -1,3 +0,0 @@
*
!.gitignore
!Pikachu*

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.