//: grafik.cpp : Grafik-Bibliothek ohne Grafiktreiber - R.Richter 2011-01-15 //////////////////////////////////////////////////////////////////////////// #include #include #include #include "image.h" void print(std::ostream& out, Image const& image) { out << "\n\nRGB-Alpha-Bild " << image.width() << " x " << image.height() << '\n'; for (unsigned y = 0; y < image.height(); ++y) { for (unsigned x = 0; x < image.width(); ++x) { out << std::setw(9) << std::hex << image.pixel(x,y); } out << '\n'; } } int main() { Color c(255, 0, 0, 127); // red, 50% transparency Image image(100, 75); for (unsigned x = 0; x < image.height(); ++x) { image.pixel(x, x) = c; // rising line image.pixel(x, image.height()/2 ) = Color::BLUE; // mid horizon line image.pixel(x, image.height()-1-x) = Color::GREEN; // falling line } image.pixel(-1, 1) = Color::WHITE; // outside ignored, doesn't crash! std::ofstream file("image.dat"); print(file, image); saveBMP("image24.bmp", image); return 0; } //~