<commit_before>

#ifndef _PIMAGE_H
#define _PIMAGE_H

#include <SD.h>

class Adafruit_GFX;

/// This class mimics Processing's PImage, but with fewer
/// capabilities. It allows an image stored in the SD card to be
/// drawn to the display.
class PImage {
public:
  PImage() : _valid(false) { }
  
  void draw(Adafruit_GFX & glcd, int16_t x, int16_t y);
  
  static PImage loadImage(const char * fileName);
  
  
  bool isValid() { return _valid; }
  
private:
  File _bmpFile;
  int  _bmpWidth, _bmpHeight;   // W+H in pixels
  uint8_t  _bmpDepth;              // Bit depth (currently must be 24)
  uint32_t _bmpImageoffset;        // Start of image data in file
  uint32_t _rowSize;               // Not always = bmpWidth; may have padding
  bool     _flip; 
  
  bool     _valid;
  
  PImage(File & bmpFile, int bmpWidth, int bmpHeight, uint8_t  bmpDepth, uint32_t bmpImageoffset, uint32_t rowSize, bool     flip) : 
  _bmpFile(bmpFile),
  _bmpWidth(bmpWidth),
  _bmpHeight(bmpHeight),
  _bmpDepth(bmpDepth),
  _bmpImageoffset(bmpImageoffset),
  _rowSize(rowSize),
  _flip(flip),
  _valid(true)
  { }
  
  // TODO close the file in ~PImage and PImage(const PImage&)

};

#endif // _PIMAGE_H
<commit_msg>make Adafruit_GFX a friend of PImage (for a simpler image() impl)<commit_after>

#ifndef _PIMAGE_H
#define _PIMAGE_H

#include <SD.h>

class Adafruit_GFX;

/// This class mimics Processing's PImage, but with fewer
/// capabilities. It allows an image stored in the SD card to be
/// drawn to the display.
class PImage {
public:
  PImage() : _valid(false) { }
  
  void draw(Adafruit_GFX & glcd, int16_t x, int16_t y);
  
  static PImage loadImage(const char * fileName);
  
  
  bool isValid() { return _valid; }
  
private:
  friend class Adafruit_GFX;
  
  File _bmpFile;
  int  _bmpWidth, _bmpHeight;   // W+H in pixels
  uint8_t  _bmpDepth;              // Bit depth (currently must be 24)
  uint32_t _bmpImageoffset;        // Start of image data in file
  uint32_t _rowSize;               // Not always = bmpWidth; may have padding
  bool     _flip; 
  
  bool     _valid;
  
  PImage(File & bmpFile, int bmpWidth, int bmpHeight, uint8_t  bmpDepth, uint32_t bmpImageoffset, uint32_t rowSize, bool     flip) : 
  _bmpFile(bmpFile),
  _bmpWidth(bmpWidth),
  _bmpHeight(bmpHeight),
  _bmpDepth(bmpDepth),
  _bmpImageoffset(bmpImageoffset),
  _rowSize(rowSize),
  _flip(flip),
  _valid(true) // since Adafruit_GFX is friend, we could just let it write the variables and save some CPU cycles
  { }
  
  // TODO close the file in ~PImage and PImage(const PImage&)

};

#endif // _PIMAGE_H

{'fraction_non_alphanumeric': 0.09171483622350675, 'fraction_numerical': 0.01233140655105973, 'mean_word_length': 3.088188976377953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5051074', 'n_tokens_mistral': 994, 'n_tokens_neox': 946, 'n_words': 278}