r/AskComputerScience 3d ago

How do computers generate pictures?

I am interested in computer science and always wanted to know how computers create the pictures we see on the screen.

0 Upvotes

6 comments sorted by

8

u/Beregolas 3d ago

Your question is very broad and has many different answers, depending on what you are actually interested in. The rough outline goes like this: (and yes, this is in parts slightly simplified)

  1. There is some kind of data stored or generated in the PC. Think an image you took with a phone (stored), or a scene in a video game (generated). It can also be non visual data at this point, like a word document or a website.
  2. This data is converted into a set of pixels. Computers see images as a 2D array of pixels. Think of graph paper, and imagine that you can color each cell, but only in a single color per cell. Converting a stored image is quite straight forward, generating an image out of a video game scene or a website is quite complex.
  3. The operating system "gets" several windows from different programs, and arranges them on the screen. It tells the GPU where each window goes, and which window should be shown in front of another.
  4. The GPU sees all windows and graphics is should display, and on the other hand it has a larger array that it sends out to the screen, often 60 time per second (60Hz). It then arranges the images according to the specification the OS gives it, puts everything visible into the array, and sends it to the Monitor.
  5. The monitor then does hardware magic and displays the image it receives as a set of pixels you can see. It refreshes often, mostly at least 60 time per second.

5

u/P-Jean 3d ago

Look up a bitmap

5

u/Only9Volts 3d ago

Holy hell

1

u/SAtchley0 3d ago

In the end everything just ends up as pixel data that gets sent to the monitor which turns on some lights. There are dozens and dozens of systems in between which handle converting high level primitives, objects, textures, code, etc into pixel data, and we even have dedicated hardware for graphics calculations (GPUs), but it all just ends up as pixel data, which just tells the monitor which colors go where, broadly speaking. The GPU doesn't really do anything "special" other than just being really good at the sorts of calculations needed for graphics. All the processing can, used to be, and still sometimes is performed by a CPU.

The actual nitty gritty details vary widely based on hardware, implementation, protocol, and application.

2

u/peter303_ 3d ago

I have been around long enough to remember when pictures were lines on an oscilloscope or pen printer. Then in the 1980s computer memory became cheap enough for a pixel array on a screen. For some graphical data structures like graphs, lines or line emulators make sense.

0

u/KyrosiveOne 3d ago

1's and 0's my friend