Plagued Soyjak.Party / The Sharty - The altchan born from the ashes of /qa/; also a containment thread

  • πŸ• I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
If the schlog never existed I guarantee this thread would be like 400 pages long and not have the Plagued tag.
It was plagued before schlog, but it's five times worse now and @Null needs to make a new tag for this thread like BRAPHAZARD.
 
1749826825106.webp
 
This thread has been so preoccupied with writing erotica about @Creasman that nobody has bothered to post the SNCAjak for the last few features

If shiwicacas had just thumbnailed their images...
Thoughie usually makes them and everybody else is too lazy to these days, including myself.

Womp womp.
 
Made a small project in C that uses bmp files and does what you did:
C:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    unsigned char r, g, b;
} RGB;

char *file_name, *output_file_name;


char ends_with_bmp(const char *input) {
    const char *extension = ".bmp";
    size_t len_filename = strlen(input);
    size_t len_extension = strlen(extension);

    // Check if filename is shorter than the extension
    if (len_filename < len_extension)
        return -1;

    // Compare the end of the filename with ".bmp"
    if(strcmp(input + len_filename - len_extension, extension) != 0)
        return 0;

    return 1;
}

char *name_wo_ext (const char *input) {
    // Find the dot before file extension
    const char *dot = strrchr(input, '.');
    size_t base_len = dot ? (size_t)(dot - input) : strlen(input);

    // Allocate enough space for base + "_bbcode.txt" + null terminator
    char *output = malloc(base_len + strlen("_bbcode.txt") + 1);
    if (!output) return NULL;

    strncpy(output, input, base_len);
    output[base_len] = '\0';
    strcat(output, "_bbcode.txt");

    return output;
}

FILE* create_output_file (const char *name) {
    FILE *g = fopen(name, "w");
    if (!g) {
        perror("Error opening output file");
        return NULL;
    }
    return g;
 }

void bmp_image(FILE* fin){
    unsigned char header[54];


    if (fread(header, 1, 54, fin) != 54) {
        fprintf(stderr, "Failed to read BMP header\n");
        return;
    }

    unsigned int width, height;
    memcpy(&width, &header[18], 4); // done for platform portability (endianess/ aligment)
    memcpy(&height, &header[22], 4);

    int row_padded = (width * 3 + 3) & 0xFFFFFFFC; // each row is padded to multiple of 4
    unsigned char *data = (unsigned char *)malloc(row_padded);
    printf("Width: %d, Height: %d\n\n", width, height);

    output_file_name = name_wo_ext(file_name);
    FILE *fout = create_output_file(output_file_name);

    if(!fout){
        goto final_routine;
    }

    for (int i = height - 1; i >= 0; i--) { // BMP stores pixels bottom to top
        fread(data, sizeof(unsigned char), row_padded, fin);
        for (int j = 0; j < width * 3; j += 3) {
            unsigned char blue = data[j];
            unsigned char green = data[j + 1];
            unsigned char red = data[j + 2];

            fprintf(fout, "[COLOR=#%02x%02x%02x]β–ˆ[/COLOR]", red, green, blue);
        }
        fprintf(fout, "\n");
    }
final_routine:
    free(data);
    free(output_file_name);
    if(fout) fclose(fout);
    return;
}

int main(int argc, char *argv[]){
    if (argc != 2) {
        printf("Usage: %s <image.bmp>\n", argv[0]);
        return 1;
    }
    file_name = argv[1];

    switch(ends_with_bmp(file_name)){
        case 0 : {perror("Only BMP files are supported for now"); return 2;} break;
        case -1: {perror("Invalid file name"); return 2;} break;
    }

    FILE *fin = fopen(argv[1], "rb");
    if (!fin) {
        perror("Error opening file");
        return 3;
    }

    bmp_image(fin);
    fclose(fin);

    return 0;
}
The limit on KF for characters is around 64K, I achieved using a 50x50 BMP image.
I will think how to implement compression (include multiple consecutive pixels that use the same color in one print), but I am too lazy now.
Have fun.
 
Back