Raspberry Piに関する話題 #01

(0) どうしてRaspberry Piに興味を持つことになったのか

(1)

フォーマット変更

2024.04.17(水) #1

2024.04.17(水) #2

2024.04.17(水) #3

2024.04.18(木) #1

2024.04.18(木) #2

2024.04.18(木) #3

2024.04.18(木) #4

2024.04.18(木) #5

2024.04.19(金) #1

2024.04.19(金) #2

2024.04.20(土) #1

2024.04.21(日) #1

2024.04.22(月) #1

#include <X11/Xlib.h>
#include <stdio.h>

int main()
{
    Display *dis = XOpenDisplay(NULL);
    Window win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 100, 100, 256, 256, 4, 0xffffff, 0x000000);
    XMapWindow(dis, win);
    XFlush(dis);
    getchar();
    XDestroyWindow(dis, win);
    XCloseDisplay(dis);
    return 0;
}

2024.04.25(木) #1

#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main()
{
    Display *dis = XOpenDisplay(NULL);
    Window win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 100, 100, 256, 256, 4, 0xffffff, 0);
    XSetWindowAttributes att[1]; att->backing_store = WhenMapped;
    XChangeWindowAttributes(dis, win, CWBackingStore, att);
    XSelectInput(dis, win, ExposureMask);
    XMapWindow(dis, win);
    XFlush(dis);
    XEvent ev[1];
    do { XNextEvent(dis, ev); } while (ev->type != Expose);

//  printf("depth=%d\n", DefaultDepth(dis, DefaultScreen(dis))); // 24 !!

    XImage img[1];
    int32_t *buf = malloc(256 * 256 * 4);
    img->format = ZPixmap;
    img->data = (char *)buf;
    img->width = 256;
    img->height = 256;
    img->xoffset = 0;
    img->byte_order = LSBFirst;
    img->bitmap_bit_order = LSBFirst;
    img->bits_per_pixel = 32;
    img->bytes_per_line = 256 * 4;
    img->bitmap_unit = 32;
    img->bitmap_pad = 32;
    img->depth = DefaultDepth(dis, DefaultScreen(dis));

    GC gc = XCreateGC(dis, DefaultRootWindow(dis), 0, 0);
    XSetGraphicsExposures(dis, gc, False);

    int x, y, c = 0;
    for (y = 0; y < 256; y++) { // r
        for (x = 0; x < 256; x++) { // g
            buf[x + y * 256] = c;
            c += 0x100;
        }
    }

    XPutImage(dis, win, gc, img, 0, 0, 0, 0, 256, 256);
    XFlush(dis);

    getchar();
    XDestroyWindow(dis, win);
    XCloseDisplay(dis);
    return 0;
}

2024.04.26(金) #1

2024.05.04(土) #1

2024.05.06(月) #1

こめんと欄


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS