|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
#include "images.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int image_new(int width, int height, Image* img) {
|
|
|
|
|
int image_new(unsigned int width, unsigned int height, Image* img) {
|
|
|
|
|
//Image img = malloc(sizeof(Image));
|
|
|
|
|
|
|
|
|
|
if (img == NULL) return 0;
|
|
|
|
@ -20,7 +20,7 @@ int image_new(int width, int height, Image* img) {
|
|
|
|
|
|
|
|
|
|
// initialize bitmap...
|
|
|
|
|
img->bitmap = malloc(height * sizeof(char*));
|
|
|
|
|
for (int i = 0; i < height; i++) {
|
|
|
|
|
for (unsigned int i = 0; i < height; i++) {
|
|
|
|
|
img->bitmap[i] = malloc(3 * width * sizeof(char));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -28,7 +28,7 @@ int image_new(int width, int height, Image* img) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int image_set_px(Image image, int x, int y, int r, int g, int b) {
|
|
|
|
|
int image_set_px(Image image, unsigned int x, unsigned int y, int r, int g, int b) {
|
|
|
|
|
if (!image_check_coords(image, x, y)) return 0;
|
|
|
|
|
|
|
|
|
|
image.bitmap[y][(3 * x) + 0] = r;
|
|
|
|
@ -37,7 +37,7 @@ int image_set_px(Image image, int x, int y, int r, int g, int b) {
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
int image_set_px_c(Image image, int x, int y, Color color) {
|
|
|
|
|
int image_set_px_c(Image image, unsigned int x, unsigned int y, Color color) {
|
|
|
|
|
if (!image_check_coords(image, x, y)) return 0;
|
|
|
|
|
|
|
|
|
|
if (color.alpha == 0) return 1;
|
|
|
|
@ -55,7 +55,7 @@ int image_set_px_c(Image image, int x, int y, Color color) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int image_check_coords(Image image, int x, int y) {
|
|
|
|
|
int image_check_coords(Image image, unsigned int x, unsigned int y) {
|
|
|
|
|
return x >= 0 && x < image.width &&
|
|
|
|
|
y >= 0 && y < image.height;
|
|
|
|
|
}
|
|
|
|
|