On Wed, 31 Mar 2004 18:04:08 +0200 Kristof Pelckmans <[EMAIL PROTECTED]> wrote:
> Hello,
Hi Kristof
> How can I obtain the current x, y resolution of the framebuffer device
> ? I have a 4:3 surface that I want to display on a 16:9 screen using
> SetScreenLocation.
This is how I do it in qingy (actually, you need only a subset of the
includes below, but I don't remember which ones):
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <sys/vt.h>
/* returns "<xres>x<yres>" */
/* fb_device should be something like /dev/fb0 */
char *get_fb_resolution(char *fb_device)
{
char *result, *temp1, *temp2;
struct fb_var_screeninfo fb_var;
int fb;
if (!fb_device) return NULL;
fb = open(fb_device, O_RDWR);
if (fb == -1)
return NULL;
if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
{
close(fb);
return NULL;
}
if (close(fb) == -1)
{ /* I don't see why this should fail, though */
fprintf(stderr, "fatal error: system too crappy!\n");
abort();
}
temp1 = int_to_str(fb_var.xres);
temp2 = int_to_str(fb_var.yres);
result = StrApp((char**)NULL, temp1, "x", temp2, (char*)NULL);
free(temp1); free(temp2);
return result;
}
Hope this works for you (it does on most systems, but not all)...
Happy coding
Michele Noberasco
--
I think I'm schizophrenic. One half of me's paranoid and the other
half's out to get him.
pgp00000.pgp
Description: PGP signature
