| 53 | typename mem_manager |
| 54 | > |
| 55 | void deserialize ( |
| 56 | array2d<rgb_pixel,mem_manager>& item, |
| 57 | std::istream& in |
| 58 | ) |
| 59 | { |
| 60 | try |
| 61 | { |
| 62 | COMPILE_TIME_ASSERT(sizeof(rgb_pixel) == 3); |
| 63 | |
| 64 | long nr, nc; |
| 65 | deserialize(nr,in); |
| 66 | deserialize(nc,in); |
| 67 | |
| 68 | // this is the newer serialization format |
| 69 | if (nr < 0 || nc < 0) |
| 70 | { |
| 71 | nr *= -1; |
| 72 | nc *= -1; |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | std::swap(nr,nc); |
| 77 | } |
| 78 | |
| 79 | item.set_size(nr,nc); |
| 80 | |
| 81 | if (item.size() != 0) |
| 82 | in.read((char*)&item[0][0], sizeof(rgb_pixel)*item.size()); |
| 83 | } |
| 84 | catch (serialization_error& e) |
| 85 | { |
| 86 | item.clear(); |
| 87 | throw serialization_error(e.info + "\n while deserializing object of type array2d"); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // ---------------------------------------------------------------------------------------- |
| 92 | |