17.8 STORING IMAGE ON THE DISK

So far, our programs used screen to output graphics. If the figures involve extensive calculations, there is no point in taxing the computer every time. We should put the (screen) images in a file and store it on the disk. We can use these images in other applications too. In addition, the code to read the image from the disk is very short as compared to creating an image. Therefore, the code will be easy to understand.

Let us write a program to draw faces of a dice.

Problem: Write a program to draw faces of a dice and store them in a file.

Solution: Dice has six faces. They contain dots. Face one has one dot and so on. First, we have to sketch the faces and then we have to mark the locations of the dots. It is ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.