aboutsummaryrefslogtreecommitdiff
path: root/src/bitmap.c
blob: ffae72ced397f031b81d6e0f2d40dcd615cc0f71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "bitmap.h"

#include <stdlib.h>
#include <string.h>

struct imv_bitmap *imv_bitmap_clone(struct imv_bitmap *bmp)
{
  struct imv_bitmap *copy = malloc(sizeof(struct imv_bitmap));
  const size_t num_bytes = 4 * bmp->width * bmp->height;
  copy->width = bmp->width;
  copy->height = bmp->height;
  copy->format = bmp->format;
  copy->data = malloc(num_bytes);
  memcpy(copy->data, bmp->data, num_bytes);
  return copy;
}

void imv_bitmap_free(struct imv_bitmap *bmp)
{
  free(bmp->data);
  free(bmp);
}