Commit 998c7b2f authored by Davis King's avatar Davis King

Fixed code so it throws the right type of exception.

parent ddac90f4
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#define DLIB_SAVE_PnG_H__ #define DLIB_SAVE_PnG_H__
#include "save_png_abstract.h" #include "save_png_abstract.h"
#include "../image_loader/image_loader.h" #include "image_saver.h"
#include "dlib/array2d.h" #include "dlib/array2d.h"
#include "dlib/pixel.h" #include "dlib/pixel.h"
#include <cstdio> #include <cstdio>
...@@ -62,7 +62,7 @@ namespace dlib ...@@ -62,7 +62,7 @@ namespace dlib
/* Open the file */ /* Open the file */
fp = fopen(file_name.c_str(), "wb"); fp = fopen(file_name.c_str(), "wb");
if (fp == NULL) if (fp == NULL)
throw image_load_error("Unable to open " + file_name + " for writing."); throw image_save_error("Unable to open " + file_name + " for writing.");
/* Create and initialize the png_struct with the desired error handler /* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method, * functions. If you want to use the default stderr and longjump method,
...@@ -75,7 +75,7 @@ namespace dlib ...@@ -75,7 +75,7 @@ namespace dlib
if (png_ptr == NULL) if (png_ptr == NULL)
{ {
fclose(fp); fclose(fp);
throw image_load_error("Error while writing PNG file " + file_name); throw image_save_error("Error while writing PNG file " + file_name);
} }
/* Allocate/initialize the image information data. REQUIRED */ /* Allocate/initialize the image information data. REQUIRED */
...@@ -84,7 +84,7 @@ namespace dlib ...@@ -84,7 +84,7 @@ namespace dlib
{ {
fclose(fp); fclose(fp);
png_destroy_write_struct(&png_ptr, NULL); png_destroy_write_struct(&png_ptr, NULL);
throw image_load_error("Error while writing PNG file " + file_name); throw image_save_error("Error while writing PNG file " + file_name);
} }
/* Set error handling. REQUIRED if you aren't supplying your own /* Set error handling. REQUIRED if you aren't supplying your own
...@@ -95,7 +95,7 @@ namespace dlib ...@@ -95,7 +95,7 @@ namespace dlib
/* If we get here, we had a problem writing the file */ /* If we get here, we had a problem writing the file */
fclose(fp); fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
throw image_load_error("Error while writing PNG file " + file_name); throw image_save_error("Error while writing PNG file " + file_name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment