Coding Challenge #22

Coding Challenge Series / Technical Interview Series

Now that you’ve become an expert in efficiently copying bytes (you did solve the last challenge, didn’t you?), I have an even more challenging question….

You have a large block of byte oriented data representing a 256-color LCD panel. Each byte represents the color of the pixel.

You’ll need to write a Copy Image function for me …

Your function is provided: width and height of the LCD panel, a reference (or pointer) to the LCD pixel storage, an array with the new colors to set, and a rectangle with the bounds for the new pixels.

The LCD display’s size may not be evenly divisible by 8, yet a pixel row must end on a boundary that is evenly divisible by 8. The image bytes as being provided do not have this behavior.

Copy the new pixels/colors into the LCD storage.