mirror of https://github.com/2martens/uni.git
[ES] Added printImage function
Signed-óff-by: Jim Martens <github@2martens.de>
This commit is contained in:
parent
1739c2c3f2
commit
2e1aaa41c5
|
@ -313,6 +313,33 @@ int printString(int x, int y, const char* text, int textLength)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an image with given parameters.
|
||||
*
|
||||
* @param int x
|
||||
* @param int y
|
||||
* @param int rows
|
||||
* @param int cols
|
||||
* @param const int* pixels
|
||||
*/
|
||||
void printImage(int x, int y, int rows, int cols, const int* pixels)
|
||||
{
|
||||
int currentX = x;
|
||||
int currentY = y;
|
||||
int maxIndex = rows * cols;
|
||||
|
||||
for (int i = 0; i < maxIndex; i++) {
|
||||
if (currentY == cols) {
|
||||
currentX++;
|
||||
currentY = y;
|
||||
}
|
||||
|
||||
int pixel = pixels[i];
|
||||
setPixel(currentX, currentY, pixel);
|
||||
currentY++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the contents of a text file into a string.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue