KDK_EDID_GET_RATIO(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

🌸 KDK_EDID_GET_RATIO(3) — NAME 🌸

okay bestie, welcome to the libkyedid manual, section 3 🎀 — the one where we read the vibes of your monitor straight off its EDID.

kdk_edid_get_ratio — 获取图像高宽比 (a.k.a. grab the image aspect ratio, periodt ✨)


💖 SYNOPSIS 💖

#include <libkyedid.h>

extern char* kdk_edid_get_ratio(char *name);

Link with -lkyedid.

yeah so you gotta link with -lkyedid, no cap. don't forget it, that's the whole ballgame 🫶


🦋 Detailed Description 🦋

so like, the main character job of this interface? it's to obtain the image aspect ratio of the screen 💅 that's it, that's the function.

and the argument name? that's the current interface of the screen. like, the one you're asking about. you hand it over and it goes and finds the ratio for you. iconic behaviour honestly 👑


✨ RETURN VALUE ✨

  • on success — it returns the image aspect ratio, of type char* 🎉 and listen: that returned string needs to be released by free. not optional, not a suggestion, bestie. free it or it haunts you 💀
  • on error — it returns NULL. simple as that 🙈

🌈 EXAMPLES 🌈

here's the whole cute little program showing it off in context, lowkey the full tour of the library:

#include "libkyedid.h"
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char** name = kdk_edid_get_interface();
    size_t count = 0;
    while (name[count])
    {
        printf("当前接口 = %s0, name[count]);
        float gamma = kdk_edid_get_gamma(name[count]);
        printf("gamma = %0.2f0, gamma);
        float size = kdk_edid_get_size(name[count]);
        printf("size = %0.1f0, size);
        char *max_resolution = kdk_edid_get_max_resolution(name[count]);
        printf("max_resolution = %s0, max_resolution);
        free(max_resolution);
        char *model = kdk_edid_get_model(name[count]);
        printf("model = %s0, model);
        free(model);
        char *area = kdk_edid_get_visible_area(name[count]);
        printf("area = %s0, area);
        free(area);
        char *manufacturer = kdk_edid_get_manufacturer(name[count]);
        printf("manufacturer = %s0, manufacturer);
        free(manufacturer);
        int week = kdk_edid_get_week(name[count]);
        printf("week = %d0, week);
        int year = kdk_edid_get_year(name[count]);
        printf("year = %d0, year);
        int primary = kdk_edid_get_primary(name[count]);
        printf("%s0, primary == 1 ? "是" : "否");

        char *resolution = kdk_edid_get_resolution(name[count]);
        printf("resolution = %s0, resolution);
        free(resolution);

        char *ratio = kdk_edid_get_ratio(name[count]);
        printf("ratio = %s0, ratio);
        free(ratio);

        char *character = kdk_edid_get_character(name[count]);
        printf("character = %s0, character);
        free(character);

        printf("---------------------------------------0);
        count ++;
    }
    kdk_edid_freeall(name);
    return 0;
}

see how kdk_edid_get_ratio() gets its free(ratio) right after? yeah. that's the move. every char* you get back from this library gets freed, and kdk_edid_freeall(name) at the end cleans up the whole interface list 🧚


👑 CONFORMING TO 👑

these functions are as per the withdrawn POSIX.1e draft specification, fr fr. and then the following functions are Linux extensions (iykyk):

  • kdk_edid_get_interface()
  • kdk_edid_get_gamma()
  • kdk_edid_get_size()
  • kdk_edid_get_max_resolution()
  • kdk_edid_get_model()
  • kdk_edid_get_visible_area()
  • kdk_edid_get_manufacturer()
  • kdk_edid_get_week()
  • kdk_edid_get_year()
  • kdk_edid_get_primary()
  • kdk_edid_get_resolution()
  • kdk_edid_get_character()
  • kdk_edid_freeall()

💜 SEE ALSO 💜

go read the whole friend group, they're all icons:


and that's the page, bestie 💖 this one's from the Linux Programmer's Manual, dated Fri Aug 25 2023 — so go forth, get that ratio, free that string, and slay 🌟🦋💅

📦 where this page comes from