mirror of
https://github.com/2martens/uni.git
synced 2026-05-07 03:46:25 +02:00
[ES] Added printImage function
Signed-óff-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -313,6 +313,33 @@ int printString(int x, int y, const char* text, int textLength)
|
|||||||
return 0;
|
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.
|
* Reads the contents of a text file into a string.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user