Commit 2c48fe18 authored by Théophile BORNON's avatar Théophile BORNON

Rotations + beginning of gray scales

parent f4cc1cd1
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace S04_Projet
{
public class Options
{
public int fileInfoHeaderSize;
public int width;
public int height;
public int colorPlanesNb;
public int bitsPerPixel;
public int compressionMethod;
public int imgSize;
public int horizontalRes;
public int VerticalRes;
public int nbColor;
public int nbImportantColor;
public string format;
public int fileSize;
public int offset;
public Options() { }
public Options Copy()
{
Options options = new Options();
options.fileInfoHeaderSize = fileInfoHeaderSize;
options.width = width;
options.height = height;
options.colorPlanesNb = colorPlanesNb;
options.bitsPerPixel = bitsPerPixel;
options.compressionMethod = compressionMethod;
options.imgSize = imgSize;
options.horizontalRes = horizontalRes;
options.VerticalRes = VerticalRes;
options.nbColor = nbColor;
options.nbImportantColor = nbImportantColor;
options.format = format;
options.fileSize = fileSize;
options.offset = offset;
return options;
}
}
}
......@@ -19,9 +19,34 @@ namespace S04_Projet
this.b = b;
}
public Pixel(byte[] rgb)
{
r = rgb[0];
g = rgb[1];
b = rgb[2];
}
public byte[] getRGB()
{
return new byte[] { r, g, b };
}
public Pixel getGrayScale(byte scale)
{
byte pix = (byte)((r + g + b) / 3);
pix = (byte)((pix / 255) * (scale-1)); // [0, scale-1]
if (pix == 1) Console.WriteLine("1");
pix = (byte)(pix * 255 * (scale-1));
if (pix == 255) Console.WriteLine("255");
return new Pixel(pix, pix, pix);
}
public Pixel getGrayScaleLuminosity(byte scale)
{
byte pix = (byte)(0.21 * r + 0.72 * g + 0.07 * b);
pix = (byte)(pix / (255 / scale));
pix = (byte)((pix * (255 / scale)) + (255 / scale));
return new Pixel(pix, pix, pix);
}
}
}
......@@ -14,7 +14,21 @@ namespace S04_Projet
static void Main(string[] args)
{
MyImage img = new MyImage("img/flocon.bmp");
/*MyImage imgRotate90 = img.Rotate90();
imgRotate90.Save("90.bmp");
MyImage imgRotate180 = img.Rotate180();
imgRotate180.Save("180.bmp");
MyImage imgRotate270 = img.Rotate270();
imgRotate270.Save("270.bmp");
Console.WriteLine("Rotations terminées");*/
//img.FromImageToFile("test.bmp");
MyImage bw = img.ToGrayScale(4);
bw.Save("bw.bmp");
Console.WriteLine("Done");
Console.Read();
}
}
......
......@@ -44,6 +44,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="MyImage.cs" />
<Compile Include="Options.cs" />
<Compile Include="Pixel.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
This image diff could not be displayed because it is too large. You can view the blob instead.
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