1 // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 // License: Boost Software License See LICENSE.txt for the full license. 3 #undef DLIB_IMAGE_SAVEr_ABSTRACT_ 4 #ifdef DLIB_IMAGE_SAVEr_ABSTRACT_ 5 6 #include <iosfwd> 7 #include "../algs.h" 8 #include "../pixel.h" 9 #include "../image_processing/generic_image.h" 10 11 namespace dlib 12 { 13 class image_save_error : public dlib::error 14 { 15 /*! 16 WHAT THIS OBJECT REPRESENTS 17 This is an exception used to indicate a failure to save an image. 18 Its type member variable will be set to EIMAGE_SAVE. 19 !*/ 20 }; 21 22 // ---------------------------------------------------------------------------------------- 23 24 template < 25 typename image_type 26 > 27 void save_bmp ( 28 const image_type& image, 29 std::ostream& out 30 ); 31 /*! 32 requires 33 - image_type == an image object that implements the interface defined in 34 dlib/image_processing/generic_image.h or any kind of matrix expression. 35 ensures 36 - writes the image to the out stream in the Microsoft Windows BMP format. 37 - image[0][0] will be in the upper left corner of the image. 38 - image[image.nr()-1][image.nc()-1] will be in the lower right 39 corner of the image. 40 - This routine can save images containing any type of pixel. However, it 41 will convert all color pixels into rgb_pixel and grayscale pixels into 42 uint8 type before saving to disk. 43 throws 44 - image_save_error 45 This exception is thrown if there is an error that prevents us 46 from saving the image. 47 - std::bad_alloc 48 !*/ 49 50 // ---------------------------------------------------------------------------------------- 51 52 template < 53 typename image_type 54 > 55 void save_bmp ( 56 const image_type& image, 57 const std::string& file_name 58 ); 59 /*! 60 requires 61 - image_type == an image object that implements the interface defined in 62 dlib/image_processing/generic_image.h or any kind of matrix expression. 63 ensures 64 - opens the file indicated by file_name with an output file stream named fout 65 and performs: 66 save_bmp(image,fout); 67 !*/ 68 69 // ---------------------------------------------------------------------------------------- 70 71 /*! 72 dlib dng file format: 73 This is a file format I created for this library. It is a lossless 74 compressed image format that is similar to the PNG format but uses 75 the dlib PPM compression algorithms instead of the DEFLATE algorithm. 76 !*/ 77 78 template < 79 typename image_type 80 > 81 void save_dng ( 82 const image_type& image, 83 std::ostream& out 84 ); 85 /*! 86 requires 87 - image_type == an image object that implements the interface defined in 88 dlib/image_processing/generic_image.h or any kind of matrix expression. 89 ensures 90 - writes the image to the out stream in the dlib dng format. 91 - image[0][0] will be in the upper left corner of the image. 92 - image[image.nr()-1][image.nc()-1] will be in the lower right 93 corner of the image. 94 - This routine can save images containing any type of pixel. However, the DNG 95 format can natively store only the following pixel types: rgb_pixel, 96 hsi_pixel, rgb_alpha_pixel, uint8, uint16, float, and double. 97 All other pixel types will be converted into one of these types as 98 appropriate before being saved to disk. 99 throws 100 - image_save_error 101 This exception is thrown if there is an error that prevents us 102 from saving the image. 103 - std::bad_alloc 104 !*/ 105 106 // ---------------------------------------------------------------------------------------- 107 108 template <typename image_type> 109 void save_dng ( 110 const image_type& image, 111 const std::string& file_name 112 ); 113 /*! 114 requires 115 - image_type == an image object that implements the interface defined in 116 dlib/image_processing/generic_image.h or any kind of matrix expression. 117 ensures 118 - opens the file indicated by file_name with an output file stream named fout 119 and performs: 120 save_dng(image,fout); 121 !*/ 122 123 // ---------------------------------------------------------------------------------------- 124 125 } 126 127 #endif // DLIB_IMAGE_SAVEr_ABSTRACT_ 128 129 130