1

我正在尝试将 x11 移植到 arm 处理器。所以我将 Imlib2 库用于 jpeg 图片。我已经成功地将带有 x windows 的 Imlib2 库交叉编译到 arm。我的示例程序也成功构建。但是当我运行二进制 jpeg 时显示不正确。(它显示图像上传错误);

#

include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <Imlib2.h>
int main(int argc, char **argv)
{
    Imlib_Image img;
    Display *dpy;
    Pixmap pix;
    Window root;
    Screen *scn;
    int width, height;
    const char *filename = NULL;

    if (argc < 2)
        return 0;
    filename = argv[1];

    img = imlib_load_image(filename);
    printf("img values %x",img);

    if (!img) {
        fprintf(stderr, "%s:Unable to load image\n", filename);
        return 0;
    }
    imlib_context_set_image(img);
    width = imlib_image_get_width();
    height = imlib_image_get_height();

    dpy = XOpenDisplay(NULL);
    if (!dpy)
        return 0;
    scn = DefaultScreenOfDisplay(dpy);
    root = DefaultRootWindow(dpy);

    pix = XCreatePixmap(dpy, root, width, height,
        DefaultDepthOfScreen(scn));
printf("caal");
    imlib_context_set_display(dpy);
    imlib_context_set_visual(DefaultVisualOfScreen(scn));
    imlib_context_set_colormap(DefaultColormapOfScreen(scn));
    imlib_context_set_drawable(pix);

    imlib_render_image_on_drawable(0, 0);

    Window w = XCreateSimpleWindow(dpy, root, 0, 0, width, height, 0, None, None);
    XSelectInput(dpy, w, ExposureMask); 
    XMapWindow(dpy, w);
    //XCopyPlane(dpy, pix, w, gc, 0, 0, width, height, 0, 0, DefaultDepthOfScreen(scn));
    XFlush(dpy);




    XSetWindowBackgroundPixmap(dpy, w, pix);
    XClearWindow(dpy, root);

    XEvent ev;
    while (XNextEvent(dpy, &ev)) { 

        if( ev.type == Expose )
        {
            //XCopyPlane(dpy, pix, w, gc, 0, 0, width, height, 0, 0, DefaultDepthOfScreen(scn));
            printf("Expose called\n");
        }
    }
    sleep(20);

    XFreePixmap(dpy, pix);
    imlib_free_image();
    XCloseDisplay(dpy);
    return 0;

    fprintf(stderr, "usage: %s <image_file>\n", argv[0]);
    return 1;
}
4

0 回答 0