Commit 4ff17f98 authored by BORNON Théophile's avatar BORNON Théophile

Error correction & activate / desactivate multithreading

parent a16182bc
......@@ -13,15 +13,28 @@ namespace S04_Projet
/// </summary>
public enum Operation
{
Rotate90,
Rotate90 = 0,
Rotate180,
Rotate270,
GrayScaleLinear,
GrayScaleLuminosity,
Shrink,
SwitchMultiThreading,
Save
}
private static string[] menuItems = new string[]
{
"Rotation à 90°",
"Rotation à 180°",
"Rotation à 270°",
"Passage à une image en nuances de gris (linéairement)",
"Passage à une image en nuances de gris (luminosité)",
"Rétrécissement de l'image",
"Désactiver le multithreading",
"Sauvegarder"
};
public static long elapsedTime;
public static string lastOperationMessage;
public static string fileInfos;
......@@ -87,16 +100,6 @@ namespace S04_Projet
Console.ForegroundColor = ConsoleColor.White;
int choosenItem = 0;
string[] menuItems = new string[]
{
"Rotation à 90°",
"Rotation à 180°",
"Rotation à 270°",
"Passage à une image en nuances de gris (linéairement)",
"Passage à une image en nuances de gris (luminosité)",
"Rétrécissement de l'image",
"Sauvegarder"
};
for (int i = 0; i < menuItems.Length; i++)
{
......@@ -179,6 +182,22 @@ namespace S04_Projet
sw.Restart();
output = img.Shrink(input);
}
else if(ope == Operation.SwitchMultiThreading)
{
Program.MULTITHREADING = !Program.MULTITHREADING;
if (Program.MULTITHREADING)
{
lastOperationMessage = "Multithreading activé avec succès";
menuItems[(int)ope] = "Désactiver le multithreading";
}
else
{
lastOperationMessage = "Multithreading désactivé avec succès";
menuItems[(int)ope] = "Activer le multithreading";
}
elapsedTime = 0;
return img;
}
else if (ope == Operation.Save)
{
string path;
......
......@@ -89,7 +89,7 @@ namespace S04_Projet
opt.fileInfoHeaderSize = EndianToInt(file, 14);
opt.width = EndianToInt(file, 18);
opt.padding = opt.width % 4;
opt.height = EndianToInt(file, 226);
opt.height = EndianToInt(file, 22);
opt.colorPlanesNb = EndianToInt(file, 26);
opt.bitsPerPixel = EndianToInt(file, 28);
opt.compressionMethod = EndianToInt(file, 30);
......@@ -158,6 +158,8 @@ namespace S04_Projet
int x, y;
byte r, g, b;
Pixel _pix;
for (int j = start; j < end; j++)
{
x = j % opt.width;
......@@ -166,7 +168,11 @@ namespace S04_Projet
g = file[j * 3 + opt.padding * y + opt.offset + 1];
r = file[j * 3 + opt.padding * y + opt.offset + 2];
Pixels[x, y] = new Pixel(r, g, b);
_pix = new Pixel(r, g, b);
lock (Pixels){
Pixels[x, y] = _pix;
}
}
}
......
......@@ -11,7 +11,7 @@ namespace S04_Projet
{
class Program
{
public static bool MULTITHREADING = false;
public static bool MULTITHREADING = true;
static void Main(string[] args)
{
#region Filters Matrix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment