Skip to content

Commit 841a2db

Browse files
snake case
1 parent ce6bd9a commit 841a2db

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

ImageManipulator.java

+51-51
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
import java.util.stream.Stream;
1212

1313
public class ImageManipulator {
14-
private final String rawImagePath;
15-
private BufferedImage imageBuffer;
16-
private File fileBuffer;
14+
private final String raw_image_path;
15+
private BufferedImage image_buffer;
16+
private File file_buffer;
1717
private final String format;
1818

19-
public ImageManipulator(String rawImagePath, String format) {
20-
this.rawImagePath = rawImagePath;
21-
this.imageBuffer = null;
22-
this.fileBuffer = null;
19+
public ImageManipulator(String raw_image_path, String format) {
20+
this.raw_image_path = raw_image_path;
21+
this.image_buffer = null;
22+
this.file_buffer = null;
2323
this.format = format;
2424
}
2525

26-
public void addSepia(String outputImagePath) {
26+
public void addSepia(String out_image_path) {
2727
setBuffer();
28-
int width = imageBuffer.getWidth();
29-
int height = imageBuffer.getHeight();
28+
int width = image_buffer.getWidth();
29+
int height = image_buffer.getHeight();
3030

3131
for (int vertical = 0; vertical < height; vertical++) {
3232
for (int horizontal = 0; horizontal < width; horizontal++) {
33-
int pixels = imageBuffer.getRGB(horizontal, vertical);
33+
int pixels = image_buffer.getRGB(horizontal, vertical);
3434

3535
int autos = (pixels >> 24) & 0xff;
3636
int red = (pixels >> 16) & 0xff;
@@ -46,39 +46,39 @@ public void addSepia(String outputImagePath) {
4646
blue = Math.min(avgBlue, 255);
4747

4848
pixels = (autos << 24) | (red << 16) | (green << 8) | blue;
49-
imageBuffer.setRGB(horizontal, vertical, pixels);
49+
image_buffer.setRGB(horizontal, vertical, pixels);
5050
}
5151
}
52-
writeImage(outputImagePath, format);
52+
writeImage(out_image_path, format);
5353
}
5454

55-
public void addRedDevil(String outputImagePath) {
55+
public void addRedDevil(String out_image_path) {
5656
setBuffer();
57-
int width = imageBuffer.getWidth();
58-
int height = imageBuffer.getHeight();
57+
int width = image_buffer.getWidth();
58+
int height = image_buffer.getHeight();
5959

6060
for (int vertical = 0; vertical < height; vertical++) {
6161
for (int horizontal = 0; horizontal < width; horizontal++) {
62-
int pixels = imageBuffer.getRGB(horizontal, vertical);
62+
int pixels = image_buffer.getRGB(horizontal, vertical);
6363

6464
int autos = (pixels >> 24) & 0xff;
6565
int red = (pixels >> 16) & 0xff;
6666

6767
pixels = (autos << 24) | (red << 16) | (0);
68-
imageBuffer.setRGB(horizontal, vertical, pixels);
68+
image_buffer.setRGB(horizontal, vertical, pixels);
6969
}
7070
}
71-
writeImage(outputImagePath, format);
71+
writeImage(out_image_path, format);
7272
}
7373

74-
public void addNegativeEffect(String outputImagePath) {
74+
public void addNegativeEffect(String out_image_path) {
7575
setBuffer();
76-
int width = imageBuffer.getWidth();
77-
int height = imageBuffer.getHeight();
76+
int width = image_buffer.getWidth();
77+
int height = image_buffer.getHeight();
7878

7979
for (int vertical = 0; vertical < height; vertical++) {
8080
for (int horizontal = 0; horizontal < width; horizontal++) {
81-
int pixels = imageBuffer.getRGB(horizontal, vertical);
81+
int pixels = image_buffer.getRGB(horizontal, vertical);
8282

8383
int autos = (pixels >> 24) & 0xff;
8484
int red = (pixels >> 16) & 0xff;
@@ -90,36 +90,36 @@ public void addNegativeEffect(String outputImagePath) {
9090
blue = 255 - blue;
9191

9292
pixels = (autos << 24) | (red << 16) | (green << 8) | blue;
93-
imageBuffer.setRGB(horizontal, vertical, pixels);
93+
image_buffer.setRGB(horizontal, vertical, pixels);
9494
}
9595
}
96-
writeImage(outputImagePath, format);
96+
writeImage(out_image_path, format);
9797
}
9898

99-
public void addGreenMatrix(String outputImagePath) {
99+
public void addGreenMatrix(String out_image_path) {
100100
setBuffer();
101-
int width = imageBuffer.getWidth();
102-
int height = imageBuffer.getHeight();
101+
int width = image_buffer.getWidth();
102+
int height = image_buffer.getHeight();
103103

104104
for (int vertical = 0; vertical < height; vertical++) {
105105
for (int horizontal = 0; horizontal < width; horizontal++) {
106-
int pixels = imageBuffer.getRGB(horizontal, vertical);
106+
int pixels = image_buffer.getRGB(horizontal, vertical);
107107
int autos = (pixels >> 24) & 0xff;
108108
int green = (pixels >> 8) & 0xff;
109109
pixels = (autos << 24) | (0) | (green << 8);
110-
imageBuffer.setRGB(horizontal, vertical, pixels);
110+
image_buffer.setRGB(horizontal, vertical, pixels);
111111
}
112112
}
113-
writeImage(outputImagePath, format);
113+
writeImage(out_image_path, format);
114114
}
115115

116-
public void addGrayScale(String outputImagePath) {
116+
public void addGrayScale(String out_image_path) {
117117
setBuffer();
118-
int width = imageBuffer.getWidth();
119-
int height = imageBuffer.getHeight();
118+
int width = image_buffer.getWidth();
119+
int height = image_buffer.getHeight();
120120
for (int vertical = 0; vertical < height; vertical++) {
121121
for (int horizontal = 0; horizontal < width; horizontal++) {
122-
int pixels = imageBuffer.getRGB(horizontal, vertical);
122+
int pixels = image_buffer.getRGB(horizontal, vertical);
123123
int autos = (pixels >> 24) & 0xff;
124124
int red = (pixels >> 16) & 0xff;
125125
int green = (pixels >> 8) & 0xff;
@@ -129,60 +129,60 @@ public void addGrayScale(String outputImagePath) {
129129
.getAverage();
130130
pixels = (autos << 24) | (average << 16)
131131
| (average << 8) | average;
132-
imageBuffer.setRGB(horizontal, vertical, pixels);
132+
image_buffer.setRGB(horizontal, vertical, pixels);
133133
}
134134
}
135-
writeImage(outputImagePath, format);
135+
writeImage(out_image_path, format);
136136
}
137137

138138
public void addBlueEffect(String outputImagePath) {
139139
setBuffer();
140-
int width = imageBuffer.getWidth();
141-
int height = imageBuffer.getHeight();
140+
int width = image_buffer.getWidth();
141+
int height = image_buffer.getHeight();
142142

143143
for (int vertical = 0; vertical < height; vertical++) {
144144
for (int horizontal = 0; horizontal < width; horizontal++) {
145-
int pixels = imageBuffer.getRGB(horizontal, vertical);
145+
int pixels = image_buffer.getRGB(horizontal, vertical);
146146
int autos = (pixels >> 24) & 0xff;
147147
int blue = pixels & 0xff;
148148
pixels = (autos << 24) | (0) | blue;
149-
imageBuffer.setRGB(horizontal, vertical, pixels);
149+
image_buffer.setRGB(horizontal, vertical, pixels);
150150
}
151151
}
152152
writeImage(outputImagePath, format);
153153
}
154154

155155
private void setBuffer() {
156156
try {
157-
fileBuffer = new File(rawImagePath);
158-
imageBuffer = ImageIO.read(fileBuffer);
157+
file_buffer = new File(raw_image_path);
158+
image_buffer = ImageIO.read(file_buffer);
159159
} catch (IOException ex) {
160160
logger(ex.getMessage());
161161
}
162162
}
163163

164-
private void writeImage(String filePath, String format) {
164+
private void writeImage(String file_path, String format) {
165165
try {
166-
fileBuffer = new File(filePath);
167-
ImageIO.write(imageBuffer, format, fileBuffer);
168-
logger("Image successfully saved to " + filePath);
166+
file_buffer = new File(file_path);
167+
ImageIO.write(image_buffer, format, file_buffer);
168+
logger("Image successfully saved to " + file_path);
169169
} catch (IOException ex) {
170170
logger(ex.getMessage());
171171
}
172172
}
173173

174174
private void logger(String message) {
175-
final String filePath = "details.log";
175+
final String file_path = "details.log";
176176
try {
177-
File file = new File(filePath);
177+
File file = new File(file_path);
178178
if (!file.exists())
179179
file.createNewFile();
180180

181-
try (FileWriter writer = new FileWriter(filePath, true)) {
181+
try (FileWriter writer = new FileWriter(file_path, true)) {
182182
writer.append("\n").append(message);
183183
}
184184
} catch (Exception e) {
185-
System.err.println("A full log can be found at " + filePath);
185+
System.err.println("A full log can be found at " + file_path);
186186
}
187187
}
188188
}

0 commit comments

Comments
 (0)