Kitty 图形协议仅在 kitty 中不起作用
我有AC程序,应该使用 nofollow noreferrer“> kitty graphics protable 并利用 ImageMagick 7 。
我从我的代码中创建了这个最小示例。请注意,错误检查和释放内存的错误是为了简单性:
#include <stdint.h>
#include <stdio.h>
#include <MagickCore/MagickCore.h>
int main()
{
ExceptionInfo* exceptionInfo = AcquireExceptionInfo();
ImageInfo* imageInfoIn = AcquireImageInfo();
CopyMagickString(imageInfoIn->filename, "./image.jpg", 12);
Image* image = ReadImage(imageInfoIn, exceptionInfo);
ImageInfo* imageInfoOut = AcquireImageInfo();
CopyMagickString(imageInfoOut->magick, "RGBA", 5);
size_t length;
void* blob = ImageToBlob(imageInfoOut, image, &length, exceptionInfo);
blob = Base64Encode(blob, length, &length);
printf("\033_Ga=T,f=32,s=%u,v=%u;", image->columns, image->rows);
fwrite(blob, sizeof(char), length, stdout);
puts("\033\\");
return 0;
}
此代码在Konsole,Wezterm和Wayst(显示图像)中的工作正常,但在Kitty本身中,它只是将RGBA数据的Base64编码作为文本打印。
Kitty +小猫ICAT路径/to/lose/image.png
正常工作,因此终端支持正在工作。
我想让它在凯蒂(Kitty)也有什么作用?
I have a c program, that should print an image to a terminal, using the Kitty graphics protocol and utilizing ImageMagick 7.
I created this minimal example from the code i have. Note that error checks and memory freeing is missing for simplicity:
#include <stdint.h>
#include <stdio.h>
#include <MagickCore/MagickCore.h>
int main()
{
ExceptionInfo* exceptionInfo = AcquireExceptionInfo();
ImageInfo* imageInfoIn = AcquireImageInfo();
CopyMagickString(imageInfoIn->filename, "./image.jpg", 12);
Image* image = ReadImage(imageInfoIn, exceptionInfo);
ImageInfo* imageInfoOut = AcquireImageInfo();
CopyMagickString(imageInfoOut->magick, "RGBA", 5);
size_t length;
void* blob = ImageToBlob(imageInfoOut, image, &length, exceptionInfo);
blob = Base64Encode(blob, length, &length);
printf("\033_Ga=T,f=32,s=%u,v=%u;", image->columns, image->rows);
fwrite(blob, sizeof(char), length, stdout);
puts("\033\\");
return 0;
}
This code works perfectly fine in Konsole, WezTerm and Wayst (displays the image), but in kitty itself it just prints the base64 encoding of the RGBA data as text.
kitty +kitten icat path/to/some/image.png
works fine, so terminal support is working.
What am i missing to make it work in kitty too?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,kitty 一次只允许发送 4096 字节的图像数据。所以你需要将它分成多个转义码才能使用它。
上面的程序修改为在 kitty 中工作也如下所示:
注意 m= 键,告诉 kitty 是否有更多数据到来。
感谢 Reddit 上的 u/aumerlex 帮助解决这个问题。
The problem was, that kitty allows only 4096 bytes of image data to be sent at once. So you need to split it up in multiple escape codes to use it.
The program above modified to work in kitty too looks like this:
Note the m= key, telling kitty if there is more data to come or not.
Thanks to u/aumerlex on Reddit for helping figure that out.