After reading a PNG image file and storing the pixels in memory, your code can modify the data to draw on the image. Special structures must be created to set pixel data properly, and the file's color format must be confirmed to ensure that the pixels are manipulated correctly.
- [Instructor] With image data … from the png file located in the memory … you're free to manipulate it, … changing pixels in whatever way you prefer. … In this code I draw an X … over the sample png image, 05_05-image1.png … which is included with the exercise files. … At line eight … I create a png pixel structure … which contains the four elements of a pixel … in RGBA png image data. … Bytes for red, green, blue, and the alpha channel. … This structure allows me to create color pixels … to place in the image data in memory. … At lines 27 and 28 … I create two png pixel variables. … One for the color black, … and another for white. … I also create a pointer to use … when referencing the pixel data in memory … pixel_ptr at line 29. … After the image data is read … and stored in memory … manipulation begins after line 95. … First I confirm the image color type, … which must be RGBA … or the pixel modification looks funky. … If the image isn't of the RGBA type, … the program exits. … Starting at line 105 the X is drawn. …
- Finding, installing, and linking libraries
- Accessing and generating XML data
- Working with JSON
- Working with the libcurl library
- Text programming
- Reading, writing, and manipulating JPEG images
- Working with PNG images
Skill Level Advanced
1. Setup and Configuration
2. Data Structures
3. Web Access
4. Text Programming
5. Computer Graphics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.