Skip to content
Browse files

Completato server con rotazione e flipping

  • Loading branch information...
1 parent d0c08f9 commit 206fc7bbc8c587ad0c0b7489b81c9d7ca361d84f @indrimuska committed
View
2 Application/HorizontalFlipService.cpp
@@ -20,7 +20,7 @@ class HorizontalFlipService : public ImageManipulation {
Response response;
string inFile = workDirectory + "/source.gif";
string outFile = workDirectory + "/flipped.gif";
- getImageFromBuffer(inParameters[0], inFile);
+ getImageFromBuffer(inParameters[0], inFile, true);
CImg<unsigned char> image(inFile.c_str());
image.mirror('x').save(outFile.c_str());
putImageInBuffer(outParameters[0], outFile);
View
10 Application/ImageManipulation.cpp
@@ -14,18 +14,16 @@ ImageManipulation::ImageManipulation() {
ImageManipulation::ImageManipulation(string workDirectory) {
this->workDirectory = workDirectory;
}
-bool ImageManipulation::getImageFromBuffer(parameter &p, string filename) {
+bool ImageManipulation::getImageFromBuffer(parameter &p, string filename, bool hideWarning) {
FILE * file;
- if ((file = fopen(filename.c_str(), "w")) != 0) {
+ if (!hideWarning && (file = fopen(filename.c_str(), "r")) != 0) {
+ fclose(file);
char response;
cout << "Il file '" << filename << "' esiste già. Sovrascriverlo [Y/N]? ";
while (response != 'Y' && response != 'N' && response != 'S') {
cin >> response;
response = toupper(response);
- if (response == 'N') {
- fclose(file);
- return false;
- }
+ if (response == 'N') return false;
}
}
if (!(file = fopen(filename.c_str(), "w"))) {
View
2 Application/ImageManipulation.h
@@ -22,7 +22,7 @@ class ImageManipulation : public Service {
protected:
string workDirectory;
- bool getImageFromBuffer(parameter &p, string filename);
+ bool getImageFromBuffer(parameter &p, string filename, bool hideWarning = false);
bool putImageInBuffer(parameter &p, string filename);
public:
ImageManipulation();
View
2 Application/RotateService.cpp
@@ -20,7 +20,7 @@ class RotateService : public ImageManipulation {
bool execute(Socket * sk) {
string inFile = workDirectory + "/source.gif";
string outFile = workDirectory + "/rotated.gif";
- getImageFromBuffer(inParameters[1], inFile);
+ getImageFromBuffer(inParameters[1], inFile, true);
int degrees;
inParameters[0].getValue(degrees);
CImg<unsigned char> image(inFile.c_str());
View
BIN design-flipped.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN design-rotated.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN design0.gif
Deleted file not rendered

0 comments on commit 206fc7b

Please sign in to comment.
Something went wrong with that request. Please try again.