Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Albert Y. Huang
lab02
Commits
a1697c32
Unverified
Commit
a1697c32
authored
1 year ago
by
Exr0n
Browse files
Options
Download
Email Patches
Plain Diff
truncate if too long
parent
088ec1ac
master
No related merge requests found
Pipeline
#94816
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/edu/caltech/cs2/lab02/Image.java
+6
-2
src/edu/caltech/cs2/lab02/Image.java
with
6 additions
and
2 deletions
+6
-2
src/edu/caltech/cs2/lab02/Image.java
View file @
a1697c32
...
...
@@ -69,9 +69,12 @@ public class Image {
int
ctr
=
0
;
for
(
char
c
:
text
.
toCharArray
())
{
// https://stackoverflow.com/a/2451660
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
// bits_to_write[ctr] = (c >> (7-j)) & 1;
if
(
ctr
>=
height
*
width
)
break
;
bits_to_write
[
ctr
]
=
(
c
>>
j
)
&
1
;
ctr
++;
}
if
(
ctr
>=
height
*
width
)
break
;
}
Pixel
[][]
new_pix
=
new
Pixel
[
height
][
width
];
...
...
@@ -79,8 +82,9 @@ public class Image {
ctr
=
0
;
for
(
int
i
=
0
;
i
<
height
;
i
++)
{
for
(
int
j
=
0
;
j
<
width
;
j
++)
{
new_pix
[
i
][
j
]
=
this
.
pixels
[
i
][
j
];
new_pix
[
i
][
j
].
fixLowestBitOfR
(
bits_to_write
[
ctr
]);
// new_pix[i][j] = this.pixels[i][j];
// new_pix[i][j].fixLowestBitOfR(bits_to_write[ctr]);
new_pix
[
i
][
j
]
=
this
.
pixels
[
i
][
j
].
fixLowestBitOfR
(
bits_to_write
[
ctr
]);
ctr
++;
}
}
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help