mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Use the new C code
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "char-props.h"
|
||||
#include "decorations.h"
|
||||
#include "glyph-cache.h"
|
||||
#include "print-graphics.h"
|
||||
|
||||
#define MISSING_GLYPH 1
|
||||
#define MAX_NUM_EXTRA_GLYPHS_PUA 4u
|
||||
@@ -136,11 +137,7 @@ static void initialize_font_group(FontGroup *fg);
|
||||
|
||||
static void
|
||||
display_rgba_data(const pixel *b, unsigned width, unsigned height) {
|
||||
RAII_PyObject(m, PyImport_ImportModule("kitty.fonts.render"));
|
||||
RAII_PyObject(f, PyObject_GetAttrString(m, "show"));
|
||||
RAII_PyObject(data, PyMemoryView_FromMemory((char*)b, (Py_ssize_t)width * height * sizeof(b[0]), PyBUF_READ));
|
||||
RAII_PyObject(ret, PyObject_CallFunction(f, "OII", data, width, height));
|
||||
if (ret == NULL) PyErr_Print();
|
||||
print_rgba32(b, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1224,6 +1221,7 @@ render_group(
|
||||
scaled_canvas_width = canvas_width;
|
||||
} else memcpy(fg->canvas.buf, canvas, sizeof(pixel) * canvas_width * scaled_metrics.cell_height);
|
||||
canvas = fg->canvas.buf;
|
||||
if (0) { print_rgba32(fg->canvas.buf, canvas_width, unscaled_metrics.cell_height); printf("\n"); }
|
||||
}
|
||||
apply_horizontal_alignment(
|
||||
canvas, rf, center_glyph, ri, canvas_width,
|
||||
|
||||
@@ -10,15 +10,14 @@
|
||||
#include <stdbool.h>
|
||||
#include "base64.h"
|
||||
|
||||
// Write the kitty graphics protocol escape codes for a 32-bit RGBA raster image to fp.
|
||||
// Write the kitty graphics protocol escape codes for a 32-bit RGBA image to fp.
|
||||
static inline void
|
||||
fprint_rgba32(FILE *fp, const uint32_t *rgba, uint32_t width, uint32_t height) {
|
||||
const uint8_t *data = (const uint8_t *)rgba;
|
||||
const size_t total_bytes = (size_t)width * height * 4;
|
||||
unsigned char b64_buf[4096];
|
||||
const size_t total_bytes = (size_t)width * height * sizeof(uint32_t);
|
||||
uint8_t b64_buf[4096];
|
||||
size_t offset = 0;
|
||||
bool first = true;
|
||||
|
||||
while (offset < total_bytes) {
|
||||
size_t chunk = total_bytes - offset;
|
||||
if (chunk > 3072) chunk = 3072;
|
||||
|
||||
Reference in New Issue
Block a user