<commit_before>#include "assettool.h"
#include <SDL_image.h>
#include <string>
#include <vector>
#include <algorithm>

#pragma warning(disable: 4996)

char fileNameBuffer[300];
void ImportImage(uint32_t** pixels, uint32_t* width, uint32_t* height) {
	if (pixels == nullptr) {
		DisplayMessageBox("Error", "Reference error in ImportImage", MESSAGEBOX_ERROR);
		return;
	}

	const char* path 
		= OpenFileDialog("All Files\0*.*\0Portable Network Graphics (.png)\0*.png\0Windows Bitmap Images (.bmp)\0*.bmp\0JPEG Images (.jpg)\0*.jpg", 0);
	if (path[0] == '\0') {
		return; // User canceled dialog box
	}

	SDL_Surface* newSurf = IMG_Load(path);
	if (newSurf == nullptr) {
		DisplayMessageBox("Error", "Could not open image file", MESSAGEBOX_ERROR);
		return;
	}

	// Copy pixels over
	SDL_LockSurface(newSurf);
	
	*width = newSurf->w;
	*height = newSurf->h;
	if (*pixels != nullptr) {
		free(*pixels);
	}

	size_t imgTotalSize = *width * *height * sizeof(uint32_t);
	*pixels = (uint32_t*)malloc(imgTotalSize);
	memcpy(*pixels, newSurf->pixels, imgTotalSize);

	SDL_UnlockSurface(newSurf);

	SDL_FreeSurface(newSurf);
}

void ImportRGBASprite(uint32_t** pixels, int numDirections, uint32_t* frameWidth, uint32_t* frameHeight, uint32_t* totalWidth, uint32_t* totalHeight) {<commit_msg>Fixed an issue with importing images.<commit_after>#include "assettool.h"
#include <SDL_image.h>
#include <string>
#include <vector>
#include <algorithm>

#pragma warning(disable: 4996)

char fileNameBuffer[300];
void ImportImage(uint32_t** pixels, uint32_t* width, uint32_t* height) {
	if (pixels == nullptr) {
		DisplayMessageBox("Error", "Reference error in ImportImage", MESSAGEBOX_ERROR);
		return;
	}

	const char* path 
		= OpenFileDialog("All Files\0*.*\0Portable Network Graphics (.png)\0*.png\0Windows Bitmap Images (.bmp)\0*.bmp\0JPEG Images (.jpg)\0*.jpg", 0);
	if (path[0] == '\0') {
		return; // User canceled dialog box
	}

	// The image is not always in RGBA format, big example is GIF (web color) or PNG (backwards)
	SDL_Surface* imgSurf = IMG_Load(path);
	SDL_Surface* newSurf = SDL_ConvertSurfaceFormat(imgSurf, SDL_PIXELFORMAT_RGBA8888, 0);

	if (newSurf == nullptr) {
		DisplayMessageBox("Error", "Could not open image file", MESSAGEBOX_ERROR);
		return;
	}

	// Copy pixels over
	SDL_LockSurface(newSurf);
	
	*width = newSurf->w;
	*height = newSurf->h;
	if (*pixels != nullptr) {
		free(*pixels);
	}

	size_t imgTotalSize = *width * *height * sizeof(uint32_t);
	*pixels = (uint32_t*)malloc(imgTotalSize);
	memcpy(*pixels, newSurf->pixels, imgTotalSize);

	SDL_UnlockSurface(newSurf);

	SDL_FreeSurface(newSurf);
	SDL_FreeSurface(imgSurf);
}

void ImportRGBASprite(uint32_t** pixels, int numDirections, uint32_t* frameWidth, uint32_t* frameHeight, uint32_t* totalWidth, uint32_t* totalHeight) {
{'fraction_non_alphanumeric': 0.1430615164520744, 'fraction_numerical': 0.028254649499284693, 'mean_word_length': 5.444700460829493, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '2222699', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1006, 'n_words': 238}