<commit_before>#ifndef _IMAGE_H_
#define _IMAGE_H_

#include <cstring>
#include <cassert>

namespace canvas {
  class Image {
  public:
    Image() 
      : width(0), height(0), data(0) {

    }
    Image(unsigned int _width, unsigned int _height, const unsigned char * _data)
      : width(_width), height(_height)
    {
      assert(_data);
      data = new unsigned char[width * height * 3];
      memcpy(data, _data, width * height * 3);
    }
    Image(const Image & other)
      : width(other.getWidth()), height(other.getHeight())
      {
	if (other.getData()) {
	  data = new unsigned char[width * height * 3];
	  memcpy(data, other.getData(), width * height * 3);	
	} else {
	  data = 0;
	}
      }
    ~Image() {
      delete[] data;
    }

    Image & operator=(const Image & other) {
      if (&other != this) {
	delete[] data;
	width = other.width;
	height = other.height;
	if (other.data) {
	  data = new unsigned char[width * height * 3];
	  memcpy(data, other.data, width * height * 3);
	} else {
	  data = 0;
	}
      }
      return *this;
    }

    unsigned int getWidth() const { return width; }
    unsigned int getHeight() const { return height; }
    const unsigned char * getData() const { return data; }

  private:
    unsigned int width, height;
    unsigned char * data;
  };
};
#endif<commit_msg>add alpha<commit_after>#ifndef _IMAGE_H_
#define _IMAGE_H_

#include <cstring>
#include <cassert>

namespace canvas {
  class Image {
  public:
    Image() : width(0), height(0), data(0), has_alpha(false) { }
    Image(unsigned int _width, unsigned int _height, const unsigned char * _data, bool _has_alpha)
      : width(_width), height(_height), has_alpha(_has_alpha)
    {
      assert(_data);
      unsigned int s = width * height * (has_alpha ? 4 : 3);
      data = new unsigned char[s];
      memcpy(data, _data, s);
    }
    Image(const Image & other)
      : width(other.getWidth()), height(other.getHeight()), has_alpha(other.hasAlpha())
    {
      if (other.getData()) {
	unsigned int s = width * height * (has_alpha ? 4 : 3);
	data = new unsigned char[s];
	memcpy(data, other.getData(), s);
      } else {
	data = 0;
      }
    }
    ~Image() {
      delete[] data;
    }

    Image & operator=(const Image & other) {
      if (&other != this) {
	delete[] data;
	width = other.width;
	height = other.height;
	has_alpha = other.has_alpha;
	if (other.data) {
	  unsigned int s = width * height * (has_alpha ? 4 : 3);
	  data = new unsigned char[s];
	  memcpy(data, other.data, s);
	} else {
	  data = 0;
	}
      }
      return *this;
    }

    unsigned int getWidth() const { return width; }
    unsigned int getHeight() const { return height; }
    bool hasAlpha() const { return has_alpha; }
    const unsigned char * getData() const { return data; }

  private:
    unsigned int width, height;
    unsigned char * data;
    bool has_alpha;
  };
};
#endif
{'fraction_non_alphanumeric': 0.13743093922651933, 'fraction_numerical': 0.007596685082872928, 'mean_word_length': 2.7284427284427286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '559097', 'n_tokens_mistral': 976, 'n_tokens_neox': 945, 'n_words': 274}