<commit_before>#include "image.h"

#include <cstdio>

#define cimg_verbosity 1
#include <cimg/CImg.h>
#include <lslutils/misc.h>
#include <lslutils/logging.h>

#ifdef HAVE_WX
	#include <wx/intl.h>
	#include <wx/image.h>
	#include <wx/bitmap.h>
#endif

#ifdef WIN32
#include <boost/filesystem.hpp>
//! we need our own fmemopen implementation since its posix only
FILE* fmemopen(void* data, size_t size, const char* mode)
{
    std::string fn( boost::filesystem::unique_path(
                        boost::filesystem::temp_directory_path() /
                            "tmp-lsl-cimage-%%%%-%%%%-%%%%-%%%%").string() );
    FILE *f = fopen(fn.c_str(), "wb");
    if (NULL == f)
        return NULL;
    fwrite(data, size, 1, f);
    fclose(f);
    return fopen(fn.c_str(), mode);
}
#endif

namespace cimg_library {

template < class T>
//! extends cimg to loading images from in-memory buffer
void load_mem( LSL::Util::uninitialized_array<char>& data, size_t size,
		const std::string& fn, CImg<T>& img) {
  const char* filename = fn.c_str();

  std::FILE *file =  fmemopen( (void*)data, size, "r" );<commit_msg>"fixes" char vs wchar issue when wx is present<commit_after>#include "image.h"

#include <cstdio>

//these need to go before cimg
#ifdef HAVE_WX
  #include <wx/image.h>
  #include <wx/bitmap.h>
#endif

#define cimg_verbosity 1
#include <cimg/CImg.h>
#include <lslutils/misc.h>
#include <lslutils/logging.h>


#ifdef WIN32
#include <boost/filesystem.hpp>
//! we need our own fmemopen implementation since its posix only
FILE* fmemopen(void* data, size_t size, const char* mode)
{
    std::string fn( boost::filesystem::unique_path(
                        boost::filesystem::temp_directory_path() /
                            "tmp-lsl-cimage-%%%%-%%%%-%%%%-%%%%").string() );
    FILE *f = fopen(fn.c_str(), "wb");
    if (NULL == f)
        return NULL;
    fwrite(data, size, 1, f);
    fclose(f);
    return fopen(fn.c_str(), mode);
}
#endif

namespace cimg_library {

template < class T>
//! extends cimg to loading images from in-memory buffer
void load_mem( LSL::Util::uninitialized_array<char>& data, size_t size,
		const std::string& fn, CImg<T>& img) {
  const char* filename = fn.c_str();

  std::FILE *file =  fmemopen( (void*)data, size, "r" );
{'fraction_non_alphanumeric': 0.1627701808557565, 'fraction_numerical': 0.0035288928098809, 'mean_word_length': 3.473372781065089, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, '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': '7525933', 'n_tokens_mistral': 829, 'n_tokens_neox': 810, 'n_words': 214}