aboutsummaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2017-11-26 13:43:05 +0000
committerHarry Jeffery <harry@exec64.co.uk>2017-11-26 13:43:18 +0000
commit7d310e4897887909099afa1cb9333dd85eae3bd4 (patch)
treecc8b7ac3e5b8d64baaa90a9cbdfcd8b7f1afe64a /src/image.c
parent2c51ecf4eef9e06a464ed73f17bd3752d47d3dee (diff)
downloadimv-7d310e4897887909099afa1cb9333dd85eae3bd4.tar.gz
Use imv_bitmap for bitmaps intead of FIBITMAP
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/image.c b/src/image.c
index 155a57b..617d45c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -41,10 +41,10 @@ void imv_image_free(struct imv_image *image)
free(image);
}
-int imv_image_set_bitmap(struct imv_image *image, FIBITMAP *bmp)
+int imv_image_set_bitmap(struct imv_image *image, struct imv_bitmap *bmp)
{
- image->width = FreeImage_GetWidth(bmp);
- image->height = FreeImage_GetHeight(bmp);
+ image->width = bmp->width;
+ image->height = bmp->height;
/* figure out how many chunks are needed, and create them */
if(image->num_chunks > 0) {
@@ -100,21 +100,16 @@ int imv_image_set_bitmap(struct imv_image *image, FIBITMAP *bmp)
return 1;
}
- BYTE* pixels = malloc(4 * image->width * image->height);
- FreeImage_ConvertToRawBits(pixels, bmp, 4 * image->width, 32,
- FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, TRUE);
-
for(int y = 0; y < image->num_chunks_tall; ++y) {
for(int x = 0; x < image->num_chunks_wide; ++x) {
ptrdiff_t offset = 4 * x * image->chunk_width +
y * 4 * image->width * image->chunk_height;
- BYTE* addr = pixels + offset;
+ unsigned char* addr = bmp->data + offset;
SDL_UpdateTexture(image->chunks[x + y * image->num_chunks_wide],
NULL, addr, 4 * image->width);
}
}
- free(pixels);
return 0;
}