Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Traitement_Images
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jorge.leitemac
Traitement_Images
Commits
e5bd65ce
Commit
e5bd65ce
authored
4 years ago
by
jorge.leitemac
Browse files
Options
Downloads
Patches
Plain Diff
ajout fonction write to file ok
parent
a5d1f0c2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
img/mandrill2.pgm
+22
-0
22 additions, 0 deletions
img/mandrill2.pgm
main.c
+2
-2
2 additions, 2 deletions
main.c
pgm.c
+29
-0
29 additions, 0 deletions
pgm.c
with
53 additions
and
2 deletions
img/mandrill2.pgm
0 → 100644
+
22
−
0
View file @
e5bd65ce
File added
This diff is collapsed.
Click to expand it.
main.c
+
2
−
2
View file @
e5bd65ce
...
...
@@ -7,8 +7,8 @@ void foo(int* elem){
int
main
(){
matrix
m
;
pgm
p
;
pmg_read_from_file
(
&
p
,
"./img/mandrill.pgm"
);
pmg_write_to_file
(
&
p
,
"./img/mandrill2.pgm"
);
pmg_read_from_file
(
&
p
,
"./img/mandrill.pgm"
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pgm.c
+
29
−
0
View file @
e5bd65ce
...
...
@@ -48,3 +48,32 @@ pgm_error pmg_read_from_file(pgm *p, char *filename)
return
success
;
}
pgm_error
pmg_write_to_file
(
pgm
*
p
,
char
*
filename
){
FILE
*
f
=
fopen
(
filename
,
"w"
);
if
(
NULL
==
f
)
{
fprintf
(
stderr
,
"Can't open output file %s!
\n
"
,
filename
);
// affiche dans le canal d'erreur
exit
(
0
);
}
//Ecrit le type de fichier a la première ligne
fprintf
(
f
,
"P5
\n
"
);
fprintf
(
f
,
"%d %d
\n
"
,
p
->
pixels
.
m
,
p
->
pixels
.
n
);
int32_t
elem
;
for
(
int
i
=
0
;
i
<
p
->
pixels
.
m
;
i
++
)
{
for
(
int
j
=
0
;
j
<
p
->
pixels
.
n
;
j
++
)
{
if
(
matrix_get
(
&
elem
,
p
->
pixels
,
i
,
j
)
!=
OK
){
return
failure
;
};
fwrite
(
&
elem
,
sizeof
(
uint8_t
),
1
,
f
);
}
}
fprintf
(
f
,
"%d %d
\n
"
,
p
->
pixels
.
m
,
p
->
pixels
.
n
);
fclose
(
f
);
return
success
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment