bitmap_free_c.h 812 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "MMBitmap.h"
  2. #include <assert.h>
  3. #include <string.h>
  4. MMBitmapRef createMMBitmap_c(uint8_t *buffer, int32_t width, int32_t height,
  5. int32_t bytewidth, uint8_t bitsPerPixel, uint8_t bytesPerPixel
  6. ) {
  7. MMBitmapRef bitmap = malloc(sizeof(MMBitmap));
  8. if (bitmap == NULL) { return NULL; }
  9. bitmap->imageBuffer = buffer;
  10. bitmap->width = width;
  11. bitmap->height = height;
  12. bitmap->bytewidth = bytewidth;
  13. bitmap->bitsPerPixel = bitsPerPixel;
  14. bitmap->bytesPerPixel = bytesPerPixel;
  15. return bitmap;
  16. }
  17. void destroyMMBitmap(MMBitmapRef bitmap) {
  18. assert(bitmap != NULL);
  19. if (bitmap->imageBuffer != NULL) {
  20. free(bitmap->imageBuffer);
  21. bitmap->imageBuffer = NULL;
  22. }
  23. free(bitmap);
  24. }
  25. void destroyMMBitmapBuffer(char * bitmapBuffer, void * hint) {
  26. if (bitmapBuffer != NULL) {
  27. free(bitmapBuffer);
  28. }
  29. }