diff --git a/Stream_support/include/CGAL/IO/io.h b/Stream_support/include/CGAL/IO/io.h index 679565c8480..eb67fd391aa 100644 --- a/Stream_support/include/CGAL/IO/io.h +++ b/Stream_support/include/CGAL/IO/io.h @@ -393,39 +393,45 @@ std::ostream& operator<<( std::ostream& out, const Color& col) switch(get_mode(out)) { case IO::ASCII : return out << static_cast(col.red()) << ' ' - << static_cast(col.green()) << ' ' - << static_cast(col.blue()); + << static_cast(col.green()) << ' ' + << static_cast(col.blue()) << ' ' + << static_cast(col.alpha()); case IO::BINARY : - write(out, static_cast(col.red())); - write(out, static_cast(col.green())); - write(out, static_cast(col.blue())); + out.write(reinterpret_cast(col.to_rgba().data()), 4); return out; default: return out << "Color(" << static_cast(col.red()) << ", " - << static_cast(col.green()) << ", " - << static_cast(col.blue()) << ')'; + << static_cast(col.green()) << ", " + << static_cast(col.blue()) << ", " + << static_cast(col.alpha()) << ")"; } } inline std::istream &operator>>(std::istream &is, Color& col) { - int r = 0, g = 0, b = 0; + unsigned char r = 0, g = 0, b = 0, a = 0; + int ir = 0, ig = 0, ib = 0, ia = 0; switch(get_mode(is)) { case IO::ASCII : - is >> r >> g >> b; + is >> ir >> ig >> ib >> ia; + r = (unsigned char)ir; + g = (unsigned char)ig; + b = (unsigned char)ib; + a = (unsigned char)ia; break; case IO::BINARY : read(is, r); read(is, g); read(is, b); + read(is, a); break; default: std::cerr << "" << std::endl; std::cerr << "Stream must be in ascii or binary mode" << std::endl; break; } - col = Color((unsigned char)r,(unsigned char)g,(unsigned char)b); + col = Color(r,g,b,a); return is; }