24 const double r_linear = red / 255.0;
25 const double g_linear = green / 255.0;
26 const double b_linear = blue / 255.0;
28 const double y_linear =
29 0.2126 * r_linear + 0.7152 * g_linear + 0.0722 * b_linear;
30 return (
int)(y_linear * 255.999);
34static bool is_space(
const unsigned char *base,
size_t size) {
35 assert(base !=
NULL || size == 0);
37 for (
size_t i = 0; i < size; ++i) {
48 assert(job->
width <= INT_MAX);
49 const int width = (int)job->
width;
50 assert(job->
height <= INT_MAX);
51 const int height = (int)job->
height;
60 aa_hardwareparams params = aa_defparams;
62 params.height = height;
63 aa_context *ctx = aa_init(&mem_d, ¶ms,
NULL);
65 agerrorf(
"failed to initialized AA-lib\n");
70 const unsigned char *
const data = job->
imagedata;
71 for (
unsigned y = 0; y < job->
height; ++y) {
72 for (
unsigned x = 0; x < job->
width; ++x) {
75 const unsigned offset =
77 const unsigned red = data[offset + 2];
78 const unsigned green = data[offset + 1];
79 const unsigned blue = data[offset];
83 assert(gray >= 0 && gray < 256);
84 aa_putpixel(ctx, (
int)x, (
int)y, gray);
89 aa_fastrender(ctx, 0, 0, width, height);
94 const unsigned char *
const text = aa_text(ctx);
96 for (
size_t y = 0; y < job->
height; ++y) {
101 for (
size_t x = 0; x < job->
width; ++x) {
106 printf(
"%c", (
char)text[y * job->
width + x]);
130#define GVPLUGIN_ASCII_API __declspec(dllexport)
132#define GVPLUGIN_ASCII_API
void agerrorf(const char *fmt,...)
Arithmetic helper functions.
static gvplugin_installed_t device_types[]
static gvdevice_features_t device_features
static void process(GVJ_t *job)
GVPLUGIN_ASCII_API gvplugin_library_t gvplugin_ascii_LTX_library
static bool is_space(const unsigned char *base, size_t size)
does the given range only contain space characters?
#define GVPLUGIN_ASCII_API
static gvplugin_api_t apis[]
static gvdevice_engine_t engine
static int rgb_to_grayscale(unsigned red, unsigned green, unsigned blue)
convert an RGB color to grayscale
unsigned char * imagedata
location of imagedata
void(* format)(GVJ_t *firstjob)