Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imageProcessing
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ecole
imageProcessing
Commits
b2f32485
Commit
b2f32485
authored
Feb 08, 2018
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parallelism
parent
9d492d61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
42 deletions
+92
-42
MyImage.cs
S04_Projet/MyImage.cs
+81
-1
Pixel.cs
S04_Projet/Pixel.cs
+10
-3
Program.cs
S04_Projet/Program.cs
+1
-38
No files found.
S04_Projet/MyImage.cs
View file @
b2f32485
using
System
;
using
System.IO
;
using
System.Diagnostics
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -13,11 +15,89 @@ namespace S04_Projet
private
int
offset
;
private
int
width
;
private
int
height
;
private
Pixel
[,]
Pixel
;
private
Pixel
[,]
Pixel
s
;
public
MyImage
(
string
path
)
{
byte
[]
file
=
new
byte
[
0
];
try
{
file
=
File
.
ReadAllBytes
(
path
);
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
"Une erreur est survenue : "
+
e
.
Message
);
}
finally
{
#
region
Header
string
format
=
(
char
)
file
[
0
]
+
""
+
(
char
)
file
[
1
];
int
endian
=
EndianToInt
(
file
,
2
,
6
);
int
offset
=
EndianToInt
(
file
,
10
,
14
);
Console
.
WriteLine
(
"Format : {0}\nTaille : {1} octets"
,
format
,
endian
);
Console
.
WriteLine
(
"Offset : "
+
offset
);
#
endregion
#
region
File
info
int
fileInfoHeaderSize
=
EndianToInt
(
file
,
14
,
18
);
int
width
=
EndianToInt
(
file
,
18
,
22
);
int
height
=
EndianToInt
(
file
,
22
,
26
);
int
colorPlanesNb
=
EndianToInt
(
file
,
26
,
28
);
int
bitsPerPixel
=
EndianToInt
(
file
,
28
,
30
);
int
compressionMethod
=
EndianToInt
(
file
,
30
,
34
);
int
imgSize
=
EndianToInt
(
file
,
34
,
38
);
int
horizontalRes
=
EndianToInt
(
file
,
38
,
42
);
int
VerticalRes
=
EndianToInt
(
file
,
42
,
46
);
int
nbColor
=
EndianToInt
(
file
,
46
,
50
);
int
nbImportantColor
=
EndianToInt
(
file
,
50
,
54
);
Console
.
WriteLine
(
"File info header size : {0} octets"
,
fileInfoHeaderSize
);
Console
.
WriteLine
(
"Size : {0}x{1}px"
,
width
,
height
);
Console
.
WriteLine
(
"Color planes number : "
+
colorPlanesNb
);
Console
.
WriteLine
(
"Bits per pixel : "
+
bitsPerPixel
);
Console
.
WriteLine
(
"Compression method : "
+
compressionMethod
);
Console
.
WriteLine
(
"Image size : {0} octets"
,
imgSize
);
Console
.
WriteLine
(
"Horizontal res : {0}\nVertical res : {1}"
,
horizontalRes
,
VerticalRes
);
Console
.
WriteLine
(
"Number of colors : "
+
nbColor
);
Console
.
WriteLine
(
"Number of important colors : "
+
nbImportantColor
);
#
endregion
#
region
Pixel
array
int
pixelNumber
=
width
*
height
;
Pixels
=
new
Pixel
[
width
,
height
];
Stopwatch
s
=
new
Stopwatch
();
#
region
Mono
s
.
Start
();
for
(
int
i
=
0
;
i
<
pixelNumber
;
i
++)
{
int
x
=
i
%
width
;
int
y
=
i
/
width
;
byte
r
=
file
[
i
*
3
+
offset
];
byte
g
=
file
[
i
*
3
+
offset
+
1
];
byte
b
=
file
[
i
*
3
+
offset
+
2
];
Pixels
[
x
,
y
]
=
new
Pixel
(
r
,
g
,
b
);
}
s
.
Stop
();
Console
.
WriteLine
(
s
.
ElapsedMilliseconds
);
#
endregion
#
region
Parallel
/*s.Start();
Parallel.For(0, pixelNumber, i =>
{
int x = i % width;
int y = i / width;
Pixels[x, y] = new Pixel(file[i * 3 + offset], file[i * 3 + offset + 1], file[i * 3 + offset + 2]);
});
s.Stop();
Console.WriteLine(s.ElapsedMilliseconds);*/
#
endregion
#
endregion
}
}
public
void
FromImageToFile
(
string
path
)
...
...
S04_Projet/Pixel.cs
View file @
b2f32485
...
...
@@ -8,8 +8,15 @@ namespace S04_Projet
{
public
class
Pixel
{
int
red
;
int
green
;
int
blue
;
byte
r
;
byte
g
;
byte
b
;
public
Pixel
(
byte
r
,
byte
g
,
byte
b
)
{
this
.
r
=
r
;
this
.
g
=
g
;
this
.
b
=
b
;
}
}
}
S04_Projet/Program.cs
View file @
b2f32485
...
...
@@ -13,44 +13,7 @@ namespace S04_Projet
{
static
void
Main
(
string
[]
args
)
{
byte
[]
file
=
File
.
ReadAllBytes
(
"img/lac_en_montagne.bmp"
);
#
region
Header
string
format
=
(
char
)
file
[
0
]
+
""
+
(
char
)
file
[
1
];
int
endian
=
MyImage
.
EndianToInt
(
file
,
2
,
6
);
int
offset
=
MyImage
.
EndianToInt
(
file
,
10
,
14
);
Console
.
WriteLine
(
"Format : {0}\nTaille : {1} octets"
,
format
,
endian
);
Console
.
WriteLine
(
"Offset : "
+
offset
);
#
endregion
#
region
File
info
int
fileInfoHeaderSize
=
MyImage
.
EndianToInt
(
file
,
14
,
18
);
int
width
=
MyImage
.
EndianToInt
(
file
,
18
,
22
);
int
height
=
MyImage
.
EndianToInt
(
file
,
22
,
26
);
int
colorPlanesNb
=
MyImage
.
EndianToInt
(
file
,
26
,
28
);
int
bitsPerPixel
=
MyImage
.
EndianToInt
(
file
,
28
,
30
);
int
compressionMethod
=
MyImage
.
EndianToInt
(
file
,
30
,
34
);
int
imgSize
=
MyImage
.
EndianToInt
(
file
,
34
,
38
);
int
horizontalRes
=
MyImage
.
EndianToInt
(
file
,
38
,
42
);
int
VerticalRes
=
MyImage
.
EndianToInt
(
file
,
42
,
46
);
int
nbColor
=
MyImage
.
EndianToInt
(
file
,
46
,
50
);
int
nbImportantColor
=
MyImage
.
EndianToInt
(
file
,
50
,
54
);
Console
.
WriteLine
(
"File info header size : {0} octets"
,
fileInfoHeaderSize
);
Console
.
WriteLine
(
"Size : {0}x{1}px"
,
width
,
height
);
Console
.
WriteLine
(
"Color planes number : "
+
colorPlanesNb
);
Console
.
WriteLine
(
"Bits per pixel : "
+
bitsPerPixel
);
Console
.
WriteLine
(
"Compression method : "
+
compressionMethod
);
Console
.
WriteLine
(
"Image size : {0} octets"
,
imgSize
);
Console
.
WriteLine
(
"Horizontal res : {0}\nVertical res : {1}"
,
horizontalRes
,
VerticalRes
);
Console
.
WriteLine
(
"Number of colors : "
+
nbColor
);
Console
.
WriteLine
(
"Number of important colors : "
+
nbImportantColor
);
#
endregion
/*for (int i = 54; i < file.Length; i++)
{
Console.Write(file[i] + "\t");
}*/
MyImage
img
=
new
MyImage
(
"img/lac_en_montagne.bmp"
);
Console
.
Read
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment