<commit_before>//
//  binary.c
//  AnsiLove/C
//
//  Copyright (C) 2011-2017 <NAME>, <NAME>, and <NAME>.
//  All rights reserved.
//
//  This source code is licensed under the BSD 2-Clause License.
//  See the file LICENSE for details.
//

#include "binary.h"

void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFile, char *retinaout, int32_t columns, char *font, int32_t bits, bool icecolors, bool createRetinaRep)
{
    // some type declarations
    struct fontStruct fontData;

    // font selection
    alSelectFont(&fontData, font);

    // libgd image pointers
    gdImagePtr canvas;

    // allocate buffer image memory
    canvas = gdImageCreate(columns * bits,
                              ((inputFileSize / 2) / columns * fontData.height));

    if (!canvas) {
        perror("Error, can't allocate buffer image memory");
        exit (6);
    }

    // allocate black color
    gdImageColorAllocate(canvas, 0, 0, 0);

    // allocate color palette
    int32_t colors[16];

    colors[0] = gdImageColorAllocate(canvas, 0, 0, 0);
    colors[1] = gdImageColorAllocate(canvas, 0, 0, 170);
    colors[2] = gdImageColorAllocate(canvas, 0, 170, 0);
    colors[3] = gdImageColorAllocate(canvas, 0, 170, 170);
    colors[4] = gdImageColorAllocate(canvas, 170, 0, 0);
    colors[5] = gdImageColorAllocate(canvas, 170, 0, 170);<commit_msg>Ensure binary files have an even size<commit_after>//
//  binary.c
//  AnsiLove/C
//
//  Copyright (C) 2011-2017 <NAME>, <NAME>, and <NAME>.
//  All rights reserved.
//
//  This source code is licensed under the BSD 2-Clause License.
//  See the file LICENSE for details.
//

#include "binary.h"

void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFile, char *retinaout, int32_t columns, char *font, int32_t bits, bool icecolors, bool createRetinaRep)
{
    // binary files must have an even size
    if (inputFileSize % 2) {
        fprintf(stderr, "\nBinary file is not valid.\n");
        exit(1);
    }

    // some type declarations
    struct fontStruct fontData;

    // font selection
    alSelectFont(&fontData, font);

    // libgd image pointers
    gdImagePtr canvas;

    // allocate buffer image memory
    canvas = gdImageCreate(columns * bits,
                              ((inputFileSize / 2) / columns * fontData.height));

    if (!canvas) {
        perror("Error, can't allocate buffer image memory");
        exit (6);
    }

    // allocate black color
    gdImageColorAllocate(canvas, 0, 0, 0);

    // allocate color palette
    int32_t colors[16];

    colors[0] = gdImageColorAllocate(canvas, 0, 0, 0);
    colors[1] = gdImageColorAllocate(canvas, 0, 0, 170);
    colors[2] = gdImageColorAllocate(canvas, 0, 170, 0);
    colors[3] = gdImageColorAllocate(canvas, 0, 170, 170);
    colors[4] = gdImageColorAllocate(canvas, 170, 0, 0);
    colors[5] = gdImageColorAllocate(canvas, 170, 0, 170);
{'fraction_non_alphanumeric': 0.1238846945778998, 'fraction_numerical': 0.043239533287577216, 'mean_word_length': 2.9075067024128685, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5070507', 'n_tokens_mistral': 1044, 'n_tokens_neox': 921, 'n_words': 280}