使用 imLIb2 读取 Rgb 图像时出错

erorr reading Rgb Images uisng imLIb2

我正在尝试使用 imLIb2 读取原始 RGBA 图像(https://docs.enlightenment.org/api/imlib2/html/ -> 根据此页面,他们似乎接受图像的 RGBA 数据)

    #include <Imlib2.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    /* an image handle */
    Imlib_Image image;

    /* load the image */
    Imlib_Load_Error error;
    image = imlib_load_image_with_error_return("rgba.raw", &error);

    printf("load error:%d", error);

    if (image)
    {
        imlib_context_set_image(image);
        
        imlib_image_set_format("png");
        /* save the image */
        imlib_save_image("working.png");
    }
    else
    {
        printf("not loaded\n");
    }
}

加载其他图像格式(如 png 和 Jpeg)工作正常,但在尝试加载 RGBA 图像时出现错误“IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT”。有人可以告诉我是否遗漏了什么或者应该向 RGBA 图像添加一些 header 或者我应该在打开 RGBA 图像之前调用更多函数吗?

如果 Imlib2 不支持读取 RgbA 图像,是否有任何替代方法 C-library 可以读取 rgb 图像并像函数一样进行缩放?

如果有人面临同样的问题,那么这个

感谢@mark-setchell 的贡献!!

magickcore Api 是一个替代的 C 库,可用于在原始 RGB 上执行函数。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <magick/ImageMagick.h>

int main(int argc, char **argv)
{
    ExceptionInfo
        exception;

    Image
        *image,
        *images,
        *resize_image,
        *thumbnails;

    ImageInfo
        *image_info;

    /*
      Initialize the image info structure and read an image.
    */
    
    InitializeMagick(NULL);
    GetExceptionInfo(&exception);
    image_info = CloneImageInfo((ImageInfo *)NULL);
    image_info->size = "1920x1080";
    image_info->depth = 8;
    (void)strcpy(image_info->filename, "image.rgba");
    images = ReadImage(image_info, &exception);

    if (images == (Image *)NULL)
        exit(1);

    resize_image = MinifyImage(images, &exception);

    if (resize_image == (Image *)NULL)
        printf("error \n");

    DestroyImageInfo(image_info);
    
    DestroyMagick();
    return (0);
}

要读取原始图像,必须为图像指定深度和 WxH。以上是将尺寸减半的一个非常小的例子。 (https://imagemagick.org/script/magick-core.php).