indent
This commit is contained in:
+362
-270
@@ -1,4 +1,4 @@
|
||||
/* $Id: fb.c,v 1.2 2002/07/18 15:01:31 ukai Exp $ */
|
||||
/* $Id: fb.c,v 1.3 2002/07/18 15:10:52 ukai Exp $ */
|
||||
/**************************************************************************
|
||||
fb.c 0.2 Copyright (C) 2002, hito
|
||||
**************************************************************************/
|
||||
@@ -21,11 +21,12 @@
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
static struct fb_cmap* fb_cmap_create(struct fb_fix_screeninfo*, struct fb_var_screeninfo *);
|
||||
static struct fb_cmap *fb_cmap_create(struct fb_fix_screeninfo *,
|
||||
struct fb_var_screeninfo *);
|
||||
static void fb_cmap_destroy(struct fb_cmap *cmap);
|
||||
static int fb_fscrn_get(int fbfp, struct fb_fix_screeninfo *scinfo);
|
||||
static void *fb_mmap(int fbfp, struct fb_fix_screeninfo *scinfo);
|
||||
static int fb_munmap(void* buf,struct fb_fix_screeninfo *scinfo);
|
||||
static int fb_munmap(void *buf, struct fb_fix_screeninfo *scinfo);
|
||||
static int fb_vscrn_get(int fbfp, struct fb_var_screeninfo *scinfo);
|
||||
|
||||
static struct fb_fix_screeninfo fscinfo;
|
||||
@@ -33,61 +34,63 @@ static struct fb_var_screeninfo vscinfo;
|
||||
static struct fb_cmap *cmap = NULL;
|
||||
static int is_open = FALSE;
|
||||
static int fbfp = -1;
|
||||
static unsigned char *buf=NULL;
|
||||
static unsigned char *buf = NULL;
|
||||
|
||||
int fb_open(void){
|
||||
char *fbdev = {FB_DEFDEV};
|
||||
int
|
||||
fb_open(void)
|
||||
{
|
||||
char *fbdev = { FB_DEFDEV };
|
||||
|
||||
if(is_open == TRUE)
|
||||
if (is_open == TRUE)
|
||||
return 1;
|
||||
|
||||
if(getenv(FB_ENV)){
|
||||
fbdev=getenv(FB_ENV);
|
||||
if (getenv(FB_ENV)) {
|
||||
fbdev = getenv(FB_ENV);
|
||||
}
|
||||
|
||||
if((fbfp = open(fbdev,O_RDWR))==-1){
|
||||
fprintf(stderr, "open %s error\n",fbdev);
|
||||
if ((fbfp = open(fbdev, O_RDWR)) == -1) {
|
||||
fprintf(stderr, "open %s error\n", fbdev);
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
if(fb_fscrn_get(fbfp,&fscinfo)){
|
||||
if (fb_fscrn_get(fbfp, &fscinfo)) {
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
if(fb_vscrn_get(fbfp,&vscinfo)){
|
||||
if (fb_vscrn_get(fbfp, &vscinfo)) {
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
if((cmap = fb_cmap_create(&fscinfo,&vscinfo)) == (struct fb_cmap*) -1){
|
||||
if ((cmap = fb_cmap_create(&fscinfo, &vscinfo)) == (struct fb_cmap *)-1) {
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
if(!(buf = fb_mmap(fbfp,&fscinfo))){
|
||||
if (!(buf = fb_mmap(fbfp, &fscinfo))) {
|
||||
fprintf(stderr, "Can't allocate memory.\n");
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
if(fscinfo.type!=FB_TYPE_PACKED_PIXELS){
|
||||
if (fscinfo.type != FB_TYPE_PACKED_PIXELS) {
|
||||
fprintf(stderr, "This type of framebuffer is not supported.\n");
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
/*
|
||||
if(fscinfo.visual == FB_VISUAL_PSEUDOCOLOR){
|
||||
#if 0
|
||||
if (fscinfo.visual == FB_VISUAL_PSEUDOCOLOR) {
|
||||
printf("FB_VISUAL_PSEUDOCOLOR\n");
|
||||
if(vscinfo.bits_per_pixel!=8){
|
||||
if (vscinfo.bits_per_pixel != 8) {
|
||||
fprintf(stderr, "未対応フレームバッファ\n");
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
if(fb_cmap_get(fbfp,cmap)){
|
||||
if (fb_cmap_get(fbfp, cmap)) {
|
||||
fprintf(stderr, "カラーマップ獲得失敗\n");
|
||||
// fb_cmap_destroy(cmap);
|
||||
goto ERR_END;
|
||||
}
|
||||
// fb_cmap_disp(cmap);
|
||||
|
||||
if(cmap->len <(LINUX_LOGO_COLORS + LOGO_COLOR_OFFSET)){
|
||||
if (cmap->len < (LINUX_LOGO_COLORS + LOGO_COLOR_OFFSET)) {
|
||||
fprintf(stderr, "色の割付領域が不足しています\n");
|
||||
goto ERR_END;
|
||||
}
|
||||
@@ -95,31 +98,33 @@ int fb_open(void){
|
||||
cmap->start = LOGO_COLOR_OFFSET;
|
||||
cmap->len = LINUX_LOGO_COLORS;
|
||||
|
||||
for(lp = 0; lp < LINUX_LOGO_COLORS; lp++){
|
||||
if(cmap->red){
|
||||
*(cmap->red+lp) = (linux_logo_red[lp]<<CHAR_BIT)+linux_logo_red[lp];
|
||||
for (lp = 0; lp < LINUX_LOGO_COLORS; lp++) {
|
||||
if (cmap->red) {
|
||||
*(cmap->red + lp) =
|
||||
(linux_logo_red[lp] << CHAR_BIT) + linux_logo_red[lp];
|
||||
}
|
||||
if(cmap->green){
|
||||
*(cmap->green+lp)= (linux_logo_green[lp]<<CHAR_BIT)+linux_logo_green[lp];
|
||||
if (cmap->green) {
|
||||
*(cmap->green + lp) =
|
||||
(linux_logo_green[lp] << CHAR_BIT) + linux_logo_green[lp];
|
||||
}
|
||||
if(cmap->blue){
|
||||
*(cmap->blue+lp)= (linux_logo_blue[lp]<<CHAR_BIT)+linux_logo_blue[lp];
|
||||
if (cmap->blue) {
|
||||
*(cmap->blue + lp) =
|
||||
(linux_logo_blue[lp] << CHAR_BIT) + linux_logo_blue[lp];
|
||||
}
|
||||
}
|
||||
if(fb_cmap_set(fbfp,cmap)){
|
||||
if (fb_cmap_set(fbfp, cmap)) {
|
||||
fb_cmap_destroy(cmap);
|
||||
fprintf(stderr, "カラーマップ獲得失敗\n");
|
||||
goto ERR_END;
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
if(!(fscinfo.visual == FB_VISUAL_TRUECOLOR &&
|
||||
if (!(fscinfo.visual == FB_VISUAL_TRUECOLOR &&
|
||||
(vscinfo.bits_per_pixel == 15 ||
|
||||
vscinfo.bits_per_pixel == 16 ||
|
||||
vscinfo.bits_per_pixel == 24 ||
|
||||
vscinfo.bits_per_pixel == 32))){
|
||||
fprintf(stderr,"This type of framebuffer is not supported.\n");
|
||||
vscinfo.bits_per_pixel == 24 || vscinfo.bits_per_pixel == 32))) {
|
||||
fprintf(stderr, "This type of framebuffer is not supported.\n");
|
||||
goto ERR_END;
|
||||
}
|
||||
|
||||
@@ -131,151 +136,175 @@ int fb_open(void){
|
||||
return 1;
|
||||
}
|
||||
|
||||
void fb_close(void)
|
||||
void
|
||||
fb_close(void)
|
||||
{
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return;
|
||||
|
||||
if(cmap != NULL){
|
||||
if (cmap != NULL) {
|
||||
fb_cmap_destroy(cmap);
|
||||
cmap = NULL;
|
||||
}
|
||||
if(buf != NULL){
|
||||
fb_munmap(buf,&fscinfo);
|
||||
if (buf != NULL) {
|
||||
fb_munmap(buf, &fscinfo);
|
||||
buf = NULL;
|
||||
}
|
||||
|
||||
if(fbfp >= 0){
|
||||
if (fbfp >= 0) {
|
||||
close(fbfp);
|
||||
}
|
||||
|
||||
is_open = FALSE;
|
||||
}
|
||||
|
||||
void fb_pset(int x, int y, int r, int g, int b)
|
||||
void
|
||||
fb_pset(int x, int y, int r, int g, int b)
|
||||
{
|
||||
unsigned long work;
|
||||
int offset;
|
||||
static size_t size = 0;
|
||||
|
||||
if(is_open != TRUE || x >= vscinfo.xres || y >= vscinfo.yres)
|
||||
if (is_open != TRUE || x >= vscinfo.xres || y >= vscinfo.yres)
|
||||
return;
|
||||
|
||||
if(size == 0)
|
||||
if (size == 0)
|
||||
size = (vscinfo.bits_per_pixel + 7) / CHAR_BIT;
|
||||
|
||||
offset = fscinfo.line_length * y + size * x;
|
||||
|
||||
if(offset >= fscinfo.smem_len)
|
||||
if (offset >= fscinfo.smem_len)
|
||||
return;
|
||||
|
||||
work=
|
||||
((r >> (CHAR_BIT - vscinfo.red.length )) << vscinfo.red.offset)+
|
||||
((g >> (CHAR_BIT - vscinfo.green.length)) << vscinfo.green.offset)+
|
||||
((b >> (CHAR_BIT - vscinfo.blue.length )) << vscinfo.blue.offset);
|
||||
work =
|
||||
((r >> (CHAR_BIT - vscinfo.red.length)) << vscinfo.red.offset) +
|
||||
((g >> (CHAR_BIT - vscinfo.green.length)) << vscinfo.green.offset) +
|
||||
((b >> (CHAR_BIT - vscinfo.blue.length)) << vscinfo.blue.offset);
|
||||
memcpy(buf + offset, &work, size);
|
||||
}
|
||||
|
||||
int fb_get_color(int x, int y, int *r, int *g, int *b)
|
||||
int
|
||||
fb_get_color(int x, int y, int *r, int *g, int *b)
|
||||
{
|
||||
unsigned long work = 0;
|
||||
int offset;
|
||||
static size_t size = 0;
|
||||
|
||||
if(is_open != TRUE || x >= vscinfo.xres || y >= vscinfo.yres)
|
||||
if (is_open != TRUE || x >= vscinfo.xres || y >= vscinfo.yres)
|
||||
return 1;
|
||||
|
||||
if(size == 0)
|
||||
if (size == 0)
|
||||
size = (vscinfo.bits_per_pixel + 7) / CHAR_BIT;
|
||||
|
||||
offset = fscinfo.line_length * y + size * x;
|
||||
if(offset >= fscinfo.smem_len)
|
||||
if (offset >= fscinfo.smem_len)
|
||||
return 1;
|
||||
|
||||
memcpy(&work, buf + offset, size);
|
||||
|
||||
*r = ((work >> vscinfo.red.offset) & (0x000000ff >> (CHAR_BIT - vscinfo.red.length)))
|
||||
*r = ((work >> vscinfo.red.
|
||||
offset) & (0x000000ff >> (CHAR_BIT - vscinfo.red.length)))
|
||||
<< (CHAR_BIT - vscinfo.red.length);
|
||||
*g = ((work >> vscinfo.green.offset) & (0x000000ff >> (CHAR_BIT - vscinfo.green.length)))
|
||||
<<(CHAR_BIT - vscinfo.green.length);
|
||||
*b = ((work >> vscinfo.blue.offset) & (0x000000ff >> (CHAR_BIT - vscinfo.blue.length)))
|
||||
*g = ((work >> vscinfo.green.
|
||||
offset) & (0x000000ff >> (CHAR_BIT - vscinfo.green.length)))
|
||||
<< (CHAR_BIT - vscinfo.green.length);
|
||||
*b = ((work >> vscinfo.blue.
|
||||
offset) & (0x000000ff >> (CHAR_BIT - vscinfo.blue.length)))
|
||||
<< (CHAR_BIT - vscinfo.blue.length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fb_clear(void)
|
||||
void
|
||||
fb_clear(void)
|
||||
{
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return;
|
||||
|
||||
memset(buf, 0, (vscinfo.xres * vscinfo.yres * vscinfo.bits_per_pixel) / CHAR_BIT);
|
||||
memset(buf, 0,
|
||||
(vscinfo.xres * vscinfo.yres * vscinfo.bits_per_pixel) / CHAR_BIT);
|
||||
}
|
||||
|
||||
int fb_width(void)
|
||||
int
|
||||
fb_width(void)
|
||||
{
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return 0;
|
||||
|
||||
return vscinfo.xres;
|
||||
}
|
||||
|
||||
int fb_height(void)
|
||||
int
|
||||
fb_height(void)
|
||||
{
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return 0;
|
||||
|
||||
return vscinfo.yres;
|
||||
}
|
||||
|
||||
void fb_cmap_disp(void)
|
||||
void
|
||||
fb_cmap_disp(void)
|
||||
{
|
||||
int lp;
|
||||
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return;
|
||||
|
||||
printf("cmap DUMP\n");
|
||||
printf("start :[%08x]\n", cmap->start);
|
||||
printf("len :[%08x]\n", cmap->len);
|
||||
printf("red :[%8p]\n", cmap->red);
|
||||
if(cmap->red){
|
||||
for(lp=0;lp<cmap->len;lp++){
|
||||
if((lp+1)%16==0) printf("%04x\n",*(cmap->red+lp));
|
||||
else printf("%04x ",*(cmap->red+lp));
|
||||
if (cmap->red) {
|
||||
for (lp = 0; lp < cmap->len; lp++) {
|
||||
if ((lp + 1) % 16 == 0)
|
||||
printf("%04x\n", *(cmap->red + lp));
|
||||
else
|
||||
printf("%04x ", *(cmap->red + lp));
|
||||
}
|
||||
if(lp%16) printf("\n");
|
||||
if (lp % 16)
|
||||
printf("\n");
|
||||
}
|
||||
printf("green :[%8p]\n",cmap->green);
|
||||
if(cmap->green){
|
||||
for(lp=0;lp<cmap->len;lp++){
|
||||
if((lp+1)%16==0) printf("%04x\n",*(cmap->green+lp));
|
||||
else printf("%04x ",*(cmap->green+lp));
|
||||
printf("green :[%8p]\n", cmap->green);
|
||||
if (cmap->green) {
|
||||
for (lp = 0; lp < cmap->len; lp++) {
|
||||
if ((lp + 1) % 16 == 0)
|
||||
printf("%04x\n", *(cmap->green + lp));
|
||||
else
|
||||
printf("%04x ", *(cmap->green + lp));
|
||||
}
|
||||
if(lp%16) printf("\n");
|
||||
if (lp % 16)
|
||||
printf("\n");
|
||||
}
|
||||
printf("blue :[%8p]\n",cmap->blue);
|
||||
if(cmap->blue){
|
||||
for(lp=0;lp<cmap->len;lp++){
|
||||
if((lp+1)%16==0) printf("%04x\n",*(cmap->blue+lp));
|
||||
else printf("%04x ",*(cmap->blue+lp));
|
||||
printf("blue :[%8p]\n", cmap->blue);
|
||||
if (cmap->blue) {
|
||||
for (lp = 0; lp < cmap->len; lp++) {
|
||||
if ((lp + 1) % 16 == 0)
|
||||
printf("%04x\n", *(cmap->blue + lp));
|
||||
else
|
||||
printf("%04x ", *(cmap->blue + lp));
|
||||
}
|
||||
if(lp%16) printf("\n");
|
||||
if (lp % 16)
|
||||
printf("\n");
|
||||
}
|
||||
printf("transp :[%8p]\n",cmap->transp);
|
||||
if(cmap->transp){
|
||||
for(lp=0;lp<cmap->len;lp++){
|
||||
if((lp+1)%16==0) printf("%04x\n",*(cmap->transp+lp));
|
||||
else printf("%04x ",*(cmap->transp+lp));
|
||||
printf("transp :[%8p]\n", cmap->transp);
|
||||
if (cmap->transp) {
|
||||
for (lp = 0; lp < cmap->len; lp++) {
|
||||
if ((lp + 1) % 16 == 0)
|
||||
printf("%04x\n", *(cmap->transp + lp));
|
||||
else
|
||||
printf("%04x ", *(cmap->transp + lp));
|
||||
}
|
||||
if(lp%16) printf("\n");
|
||||
if (lp % 16)
|
||||
printf("\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void fb_fscrn_disp(void)
|
||||
void
|
||||
fb_fscrn_disp(void)
|
||||
{
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return;
|
||||
|
||||
printf("scinfo[%8p] DUMP\n", &fscinfo);
|
||||
@@ -283,288 +312,351 @@ void fb_fscrn_disp(void)
|
||||
printf("smem_start :[%08lx]\n", fscinfo.smem_start);
|
||||
printf("smem_len :[%d]\n", fscinfo.smem_len);
|
||||
printf("type :[%d] ", fscinfo.type);
|
||||
switch(fscinfo.type){
|
||||
switch (fscinfo.type) {
|
||||
case FB_TYPE_PACKED_PIXELS:
|
||||
printf("FB_TYPE_PACKED_PIXELS\n");break;
|
||||
printf("FB_TYPE_PACKED_PIXELS\n");
|
||||
break;
|
||||
case FB_TYPE_PLANES:
|
||||
printf("FB_TYPE_PLANES\n");break;
|
||||
printf("FB_TYPE_PLANES\n");
|
||||
break;
|
||||
case FB_TYPE_INTERLEAVED_PLANES:
|
||||
printf("FB_TYPE_INTERLEAVED_PLANES\n");break;
|
||||
printf("FB_TYPE_INTERLEAVED_PLANES\n");
|
||||
break;
|
||||
case FB_TYPE_TEXT:
|
||||
printf("FB_TYPE_TEXT\n");break;
|
||||
default:printf("Unknown type.\n");
|
||||
printf("FB_TYPE_TEXT\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown type.\n");
|
||||
}
|
||||
printf("type_aux :[%d] ",fscinfo.type_aux);
|
||||
switch(fscinfo.type_aux){
|
||||
printf("type_aux :[%d] ", fscinfo.type_aux);
|
||||
switch (fscinfo.type_aux) {
|
||||
case FB_AUX_TEXT_MDA:
|
||||
printf("FB_AUX_TEXT_MDA\n");break;
|
||||
printf("FB_AUX_TEXT_MDA\n");
|
||||
break;
|
||||
case FB_AUX_TEXT_CGA:
|
||||
printf("FB_AUX_TEXT_CGA\n");break;
|
||||
printf("FB_AUX_TEXT_CGA\n");
|
||||
break;
|
||||
case FB_AUX_TEXT_S3_MMIO:
|
||||
printf("FB_AUX_TEXT_S3_MMIO\n");break;
|
||||
printf("FB_AUX_TEXT_S3_MMIO\n");
|
||||
break;
|
||||
case FB_AUX_TEXT_MGA_STEP16:
|
||||
printf("FB_AUX_TEXT_MGA_STEP16\n");break;
|
||||
printf("FB_AUX_TEXT_MGA_STEP16\n");
|
||||
break;
|
||||
case FB_AUX_TEXT_MGA_STEP8:
|
||||
printf("FB_AUX_TEXT_MGA_STEP8\n");break;
|
||||
default:printf("Unknown type_aux.\n");
|
||||
printf("FB_AUX_TEXT_MGA_STEP8\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown type_aux.\n");
|
||||
}
|
||||
printf("visual :[%d] ",fscinfo.visual);
|
||||
switch(fscinfo.visual){
|
||||
printf("visual :[%d] ", fscinfo.visual);
|
||||
switch (fscinfo.visual) {
|
||||
case FB_VISUAL_MONO01:
|
||||
printf("FB_VISUAL_MONO01\n");break;
|
||||
printf("FB_VISUAL_MONO01\n");
|
||||
break;
|
||||
case FB_VISUAL_MONO10:
|
||||
printf("FB_VISUAL_MONO10\n");break;
|
||||
printf("FB_VISUAL_MONO10\n");
|
||||
break;
|
||||
case FB_VISUAL_TRUECOLOR:
|
||||
printf("FB_VISUAL_TRUECOLOR\n");break;
|
||||
printf("FB_VISUAL_TRUECOLOR\n");
|
||||
break;
|
||||
case FB_VISUAL_PSEUDOCOLOR:
|
||||
printf("FB_VISUAL_PSEUDOCOLOR\n");break;
|
||||
printf("FB_VISUAL_PSEUDOCOLOR\n");
|
||||
break;
|
||||
case FB_VISUAL_DIRECTCOLOR:
|
||||
printf("FB_VISUAL_DIRECTCOLOR\n");break;
|
||||
printf("FB_VISUAL_DIRECTCOLOR\n");
|
||||
break;
|
||||
case FB_VISUAL_STATIC_PSEUDOCOLOR:
|
||||
printf("FB_VISUAL_STATIC_PSEUDOCOLOR\n");break;
|
||||
default:printf("Unknown Visual mode.\n");
|
||||
printf("FB_VISUAL_STATIC_PSEUDOCOLOR\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Visual mode.\n");
|
||||
}
|
||||
printf("xpanstep :[%d]\n",fscinfo.xpanstep);
|
||||
printf("ypanstep :[%d]\n",fscinfo.ypanstep);
|
||||
printf("ywrapstep :[%d]\n",fscinfo.ywrapstep);
|
||||
printf("line_length :[%d]\n",fscinfo.line_length);
|
||||
printf("mmio_start :[%08lx]\n",fscinfo.mmio_start);
|
||||
printf("mmio_len :[%d]\n",fscinfo.mmio_len);
|
||||
printf("accel :[%d] ",fscinfo.accel);
|
||||
switch(fscinfo.accel){
|
||||
printf("xpanstep :[%d]\n", fscinfo.xpanstep);
|
||||
printf("ypanstep :[%d]\n", fscinfo.ypanstep);
|
||||
printf("ywrapstep :[%d]\n", fscinfo.ywrapstep);
|
||||
printf("line_length :[%d]\n", fscinfo.line_length);
|
||||
printf("mmio_start :[%08lx]\n", fscinfo.mmio_start);
|
||||
printf("mmio_len :[%d]\n", fscinfo.mmio_len);
|
||||
printf("accel :[%d] ", fscinfo.accel);
|
||||
switch (fscinfo.accel) {
|
||||
case FB_ACCEL_NONE:
|
||||
printf("FB_ACCEL_NONE\n");break;
|
||||
printf("FB_ACCEL_NONE\n");
|
||||
break;
|
||||
case FB_ACCEL_ATARIBLITT:
|
||||
printf("FB_ACCEL_ATARIBLITT\n");break;
|
||||
printf("FB_ACCEL_ATARIBLITT\n");
|
||||
break;
|
||||
case FB_ACCEL_AMIGABLITT:
|
||||
printf("FB_ACCEL_AMIGABLITT\n");break;
|
||||
printf("FB_ACCEL_AMIGABLITT\n");
|
||||
break;
|
||||
case FB_ACCEL_S3_TRIO64:
|
||||
printf("FB_ACCEL_S3_TRIO64\n");break;
|
||||
printf("FB_ACCEL_S3_TRIO64\n");
|
||||
break;
|
||||
case FB_ACCEL_NCR_77C32BLT:
|
||||
printf("FB_ACCEL_NCR_77C32BLT\n");break;
|
||||
printf("FB_ACCEL_NCR_77C32BLT\n");
|
||||
break;
|
||||
case FB_ACCEL_S3_VIRGE:
|
||||
printf("FB_ACCEL_S3_VIRGE\n");break;
|
||||
printf("FB_ACCEL_S3_VIRGE\n");
|
||||
break;
|
||||
case FB_ACCEL_ATI_MACH64GX:
|
||||
printf("FB_ACCEL_ATI_MACH64GX\n");break;
|
||||
printf("FB_ACCEL_ATI_MACH64GX\n");
|
||||
break;
|
||||
case FB_ACCEL_DEC_TGA:
|
||||
printf("FB_ACCEL_DEC_TGA\n");break;
|
||||
printf("FB_ACCEL_DEC_TGA\n");
|
||||
break;
|
||||
case FB_ACCEL_ATI_MACH64CT:
|
||||
printf("FB_ACCEL_ATI_MACH64CT\n");break;
|
||||
printf("FB_ACCEL_ATI_MACH64CT\n");
|
||||
break;
|
||||
case FB_ACCEL_ATI_MACH64VT:
|
||||
printf("FB_ACCEL_ATI_MACH64VT\n");break;
|
||||
printf("FB_ACCEL_ATI_MACH64VT\n");
|
||||
break;
|
||||
case FB_ACCEL_ATI_MACH64GT:
|
||||
printf("FB_ACCEL_ATI_MACH64GT\n");break;
|
||||
printf("FB_ACCEL_ATI_MACH64GT\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_CREATOR:
|
||||
printf("FB_ACCEL_SUN_CREATOR\n");break;
|
||||
printf("FB_ACCEL_SUN_CREATOR\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_CGSIX:
|
||||
printf("FB_ACCEL_SUN_CGSIX\n");break;
|
||||
printf("FB_ACCEL_SUN_CGSIX\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_LEO:
|
||||
printf("FB_ACCEL_SUN_LEO\n");break;
|
||||
printf("FB_ACCEL_SUN_LEO\n");
|
||||
break;
|
||||
case FB_ACCEL_IMS_TWINTURBO:
|
||||
printf("FB_ACCEL_IMS_TWINTURBO\n");break;
|
||||
printf("FB_ACCEL_IMS_TWINTURBO\n");
|
||||
break;
|
||||
case FB_ACCEL_3DLABS_PERMEDIA2:
|
||||
printf("FB_ACCEL_3DLABS_PERMEDIA2\n");break;
|
||||
printf("FB_ACCEL_3DLABS_PERMEDIA2\n");
|
||||
break;
|
||||
case FB_ACCEL_MATROX_MGA2064W:
|
||||
printf("FB_ACCEL_MATROX_MGA2064W\n");break;
|
||||
printf("FB_ACCEL_MATROX_MGA2064W\n");
|
||||
break;
|
||||
case FB_ACCEL_MATROX_MGA1064SG:
|
||||
printf("FB_ACCEL_MATROX_MGA1064SG\n");break;
|
||||
printf("FB_ACCEL_MATROX_MGA1064SG\n");
|
||||
break;
|
||||
case FB_ACCEL_MATROX_MGA2164W:
|
||||
printf("FB_ACCEL_MATROX_MGA2164W\n");break;
|
||||
printf("FB_ACCEL_MATROX_MGA2164W\n");
|
||||
break;
|
||||
case FB_ACCEL_MATROX_MGA2164W_AGP:
|
||||
printf("FB_ACCEL_MATROX_MGA2164W_AGP\n");break;
|
||||
printf("FB_ACCEL_MATROX_MGA2164W_AGP\n");
|
||||
break;
|
||||
case FB_ACCEL_MATROX_MGAG100:
|
||||
printf("FB_ACCEL_MATROX_MGAG100\n");break;
|
||||
printf("FB_ACCEL_MATROX_MGAG100\n");
|
||||
break;
|
||||
case FB_ACCEL_MATROX_MGAG200:
|
||||
printf("FB_ACCEL_MATROX_MGAG200\n");break;
|
||||
printf("FB_ACCEL_MATROX_MGAG200\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_CG14:
|
||||
printf("FB_ACCEL_SUN_CG14\n");break;
|
||||
printf("FB_ACCEL_SUN_CG14\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_BWTWO:
|
||||
printf("FB_ACCEL_SUN_BWTWO\n");break;
|
||||
printf("FB_ACCEL_SUN_BWTWO\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_CGTHREE:
|
||||
printf("FB_ACCEL_SUN_CGTHREE\n");break;
|
||||
printf("FB_ACCEL_SUN_CGTHREE\n");
|
||||
break;
|
||||
case FB_ACCEL_SUN_TCX:
|
||||
printf("FB_ACCEL_SUN_TCX\n");break;
|
||||
default:printf("Unknown Visual mode.\n");
|
||||
printf("FB_ACCEL_SUN_TCX\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Visual mode.\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void fb_vscrn_disp(void)
|
||||
void
|
||||
fb_vscrn_disp(void)
|
||||
{
|
||||
if(is_open != TRUE)
|
||||
if (is_open != TRUE)
|
||||
return;
|
||||
printf("vscinfo DUMP\n");
|
||||
printf("xres :[%d]\n",vscinfo.xres);
|
||||
printf("yres :[%d]\n",vscinfo.yres);
|
||||
printf("xres_virtual :[%d]\n",vscinfo.xres_virtual);
|
||||
printf("yres_virtual :[%d]\n",vscinfo.yres_virtual);
|
||||
printf("xoffset :[%d]\n",vscinfo.xoffset);
|
||||
printf("yoffset :[%d]\n",vscinfo.yoffset);
|
||||
printf("bits_per_pixel :[%d]\n",vscinfo.bits_per_pixel);
|
||||
printf("grayscale :[%d]\n",vscinfo.grayscale);
|
||||
printf("red.offset :[%d]\n",vscinfo.red.offset);
|
||||
printf("red.length :[%d]\n",vscinfo.red.length);
|
||||
printf("red.msb_right :[%d]\n",vscinfo.red.msb_right);
|
||||
printf("green.offset :[%d]\n",vscinfo.green.offset);
|
||||
printf("green.length :[%d]\n",vscinfo.green.length);
|
||||
printf("green.msb_right :[%d]\n",vscinfo.green.msb_right);
|
||||
printf("blue.offset :[%d]\n",vscinfo.blue.offset);
|
||||
printf("blue.length :[%d]\n",vscinfo.blue.length);
|
||||
printf("blue.msb_right :[%d]\n",vscinfo.blue.msb_right);
|
||||
printf("transp.offset :[%d]\n",vscinfo.transp.offset);
|
||||
printf("transp.length :[%d]\n",vscinfo.transp.length);
|
||||
printf("transp.msb_right:[%d]\n",vscinfo.transp.msb_right);
|
||||
printf("nonstd :[%d]\n",vscinfo.nonstd);
|
||||
printf("activate :[%d]\n",vscinfo.activate);
|
||||
printf("height :[%d]\n",vscinfo.height);
|
||||
printf("width :[%d]\n",vscinfo.width);
|
||||
printf("accel_flags :[%d]\n",vscinfo.accel_flags);
|
||||
printf("pixclock :[%d]\n",vscinfo.pixclock);
|
||||
printf("left_margin :[%d]\n",vscinfo.left_margin);
|
||||
printf("right_margin :[%d]\n",vscinfo.right_margin);
|
||||
printf("upper_margin :[%d]\n",vscinfo.upper_margin);
|
||||
printf("lower_margin :[%d]\n",vscinfo.lower_margin);
|
||||
printf("hsync_len :[%d]\n",vscinfo.hsync_len);
|
||||
printf("vsync_len :[%d]\n",vscinfo.vsync_len);
|
||||
printf("sync :[%d]\n",vscinfo.sync);
|
||||
printf("vmode :[%d]\n",vscinfo.vmode);
|
||||
printf("xres :[%d]\n", vscinfo.xres);
|
||||
printf("yres :[%d]\n", vscinfo.yres);
|
||||
printf("xres_virtual :[%d]\n", vscinfo.xres_virtual);
|
||||
printf("yres_virtual :[%d]\n", vscinfo.yres_virtual);
|
||||
printf("xoffset :[%d]\n", vscinfo.xoffset);
|
||||
printf("yoffset :[%d]\n", vscinfo.yoffset);
|
||||
printf("bits_per_pixel :[%d]\n", vscinfo.bits_per_pixel);
|
||||
printf("grayscale :[%d]\n", vscinfo.grayscale);
|
||||
printf("red.offset :[%d]\n", vscinfo.red.offset);
|
||||
printf("red.length :[%d]\n", vscinfo.red.length);
|
||||
printf("red.msb_right :[%d]\n", vscinfo.red.msb_right);
|
||||
printf("green.offset :[%d]\n", vscinfo.green.offset);
|
||||
printf("green.length :[%d]\n", vscinfo.green.length);
|
||||
printf("green.msb_right :[%d]\n", vscinfo.green.msb_right);
|
||||
printf("blue.offset :[%d]\n", vscinfo.blue.offset);
|
||||
printf("blue.length :[%d]\n", vscinfo.blue.length);
|
||||
printf("blue.msb_right :[%d]\n", vscinfo.blue.msb_right);
|
||||
printf("transp.offset :[%d]\n", vscinfo.transp.offset);
|
||||
printf("transp.length :[%d]\n", vscinfo.transp.length);
|
||||
printf("transp.msb_right:[%d]\n", vscinfo.transp.msb_right);
|
||||
printf("nonstd :[%d]\n", vscinfo.nonstd);
|
||||
printf("activate :[%d]\n", vscinfo.activate);
|
||||
printf("height :[%d]\n", vscinfo.height);
|
||||
printf("width :[%d]\n", vscinfo.width);
|
||||
printf("accel_flags :[%d]\n", vscinfo.accel_flags);
|
||||
printf("pixclock :[%d]\n", vscinfo.pixclock);
|
||||
printf("left_margin :[%d]\n", vscinfo.left_margin);
|
||||
printf("right_margin :[%d]\n", vscinfo.right_margin);
|
||||
printf("upper_margin :[%d]\n", vscinfo.upper_margin);
|
||||
printf("lower_margin :[%d]\n", vscinfo.lower_margin);
|
||||
printf("hsync_len :[%d]\n", vscinfo.hsync_len);
|
||||
printf("vsync_len :[%d]\n", vscinfo.vsync_len);
|
||||
printf("sync :[%d]\n", vscinfo.sync);
|
||||
printf("vmode :[%d]\n", vscinfo.vmode);
|
||||
return;
|
||||
}
|
||||
|
||||
/********* static functions **************/
|
||||
|
||||
/*
|
||||
(struct fb_cmap)デバイスに依存しないカラーマップ情報
|
||||
|
||||
fb_cmap_create() 新規のカラーマップ情報
|
||||
fb_cmap_destroy() カラーマップ情報の破棄
|
||||
fb_cmap_disp() 情報の表示
|
||||
fb_cmap_get() 情報の獲得
|
||||
fb_cmap_set() 情報の設定
|
||||
*/
|
||||
* (struct fb_cmap)デバイスに依存しないカラーマップ情報
|
||||
*
|
||||
* fb_cmap_create() 新規のカラーマップ情報
|
||||
* fb_cmap_destroy() カラーマップ情報の破棄
|
||||
* fb_cmap_disp() 情報の表示
|
||||
* fb_cmap_get() 情報の獲得
|
||||
* fb_cmap_set() 情報の設定
|
||||
*/
|
||||
|
||||
#define LUT_MAX (256)
|
||||
|
||||
static struct fb_cmap* fb_cmap_create(struct fb_fix_screeninfo* fscinfo,
|
||||
static struct fb_cmap *
|
||||
fb_cmap_create(struct fb_fix_screeninfo *fscinfo,
|
||||
struct fb_var_screeninfo *vscinfo)
|
||||
{
|
||||
struct fb_cmap* cmap;
|
||||
int cmaplen=LUT_MAX;
|
||||
struct fb_cmap *cmap;
|
||||
int cmaplen = LUT_MAX;
|
||||
|
||||
/* カラーマップの存在チェック */
|
||||
if(fscinfo->visual==FB_VISUAL_MONO01 ||
|
||||
fscinfo->visual==FB_VISUAL_MONO10 ||
|
||||
fscinfo->visual==FB_VISUAL_TRUECOLOR) return NULL;
|
||||
if (fscinfo->visual == FB_VISUAL_MONO01 ||
|
||||
fscinfo->visual == FB_VISUAL_MONO10 ||
|
||||
fscinfo->visual == FB_VISUAL_TRUECOLOR)
|
||||
return NULL;
|
||||
|
||||
cmap=(struct fb_cmap*)malloc(sizeof(struct fb_cmap));
|
||||
if(!cmap){
|
||||
cmap = (struct fb_cmap *)malloc(sizeof(struct fb_cmap));
|
||||
if (!cmap) {
|
||||
perror("cmap malloc error\n");
|
||||
return (struct fb_cmap*)-1;
|
||||
return (struct fb_cmap *)-1;
|
||||
}
|
||||
memset(cmap,0,sizeof(struct fb_cmap));
|
||||
memset(cmap, 0, sizeof(struct fb_cmap));
|
||||
|
||||
/* 各分色が存在しそうだったらカラーマップ用の領域を確保 */
|
||||
if(vscinfo->red.length){
|
||||
cmap->red=(__u16*)malloc(sizeof(__u16)*cmaplen);
|
||||
if(!cmap->red){
|
||||
if (vscinfo->red.length) {
|
||||
cmap->red = (__u16 *) malloc(sizeof(__u16) * cmaplen);
|
||||
if (!cmap->red) {
|
||||
perror("red lut malloc error\n");
|
||||
return (struct fb_cmap*)-1;
|
||||
return (struct fb_cmap *)-1;
|
||||
}
|
||||
}
|
||||
if(vscinfo->green.length){
|
||||
cmap->green=(__u16*)malloc(sizeof(__u16)*cmaplen);
|
||||
if(!cmap->green){
|
||||
if(vscinfo->red.length) free(cmap->red);
|
||||
if (vscinfo->green.length) {
|
||||
cmap->green = (__u16 *) malloc(sizeof(__u16) * cmaplen);
|
||||
if (!cmap->green) {
|
||||
if (vscinfo->red.length)
|
||||
free(cmap->red);
|
||||
perror("green lut malloc error\n");
|
||||
return (struct fb_cmap*)-1;
|
||||
return (struct fb_cmap *)-1;
|
||||
}
|
||||
}
|
||||
if(vscinfo->blue.length){
|
||||
cmap->blue=(__u16*)malloc(sizeof(__u16)*cmaplen);
|
||||
if(!cmap->blue){
|
||||
if(vscinfo->red.length) free(cmap->red);
|
||||
if(vscinfo->green.length) free(cmap->green);
|
||||
if (vscinfo->blue.length) {
|
||||
cmap->blue = (__u16 *) malloc(sizeof(__u16) * cmaplen);
|
||||
if (!cmap->blue) {
|
||||
if (vscinfo->red.length)
|
||||
free(cmap->red);
|
||||
if (vscinfo->green.length)
|
||||
free(cmap->green);
|
||||
perror("blue lut malloc error\n");
|
||||
return (struct fb_cmap*)-1;
|
||||
return (struct fb_cmap *)-1;
|
||||
}
|
||||
}
|
||||
if(vscinfo->transp.length){
|
||||
cmap->transp=(__u16*)malloc(sizeof(__u16)*cmaplen);
|
||||
if(!cmap->transp){
|
||||
if(vscinfo->red.length) free(cmap->red);
|
||||
if(vscinfo->green.length) free(cmap->green);
|
||||
if(vscinfo->blue.length) free(cmap->blue);
|
||||
if (vscinfo->transp.length) {
|
||||
cmap->transp = (__u16 *) malloc(sizeof(__u16) * cmaplen);
|
||||
if (!cmap->transp) {
|
||||
if (vscinfo->red.length)
|
||||
free(cmap->red);
|
||||
if (vscinfo->green.length)
|
||||
free(cmap->green);
|
||||
if (vscinfo->blue.length)
|
||||
free(cmap->blue);
|
||||
perror("transp lut malloc error\n");
|
||||
return (struct fb_cmap*)-1;
|
||||
return (struct fb_cmap *)-1;
|
||||
}
|
||||
}
|
||||
cmap->len=cmaplen;
|
||||
cmap->len = cmaplen;
|
||||
return cmap;
|
||||
}
|
||||
|
||||
static void fb_cmap_destroy(struct fb_cmap* cmap)
|
||||
static void
|
||||
fb_cmap_destroy(struct fb_cmap *cmap)
|
||||
{
|
||||
if(cmap->red) free(cmap->red);
|
||||
if(cmap->green) free(cmap->green);
|
||||
if(cmap->blue) free(cmap->blue);
|
||||
if(cmap->transp) free(cmap->transp);
|
||||
if (cmap->red)
|
||||
free(cmap->red);
|
||||
if (cmap->green)
|
||||
free(cmap->green);
|
||||
if (cmap->blue)
|
||||
free(cmap->blue);
|
||||
if (cmap->transp)
|
||||
free(cmap->transp);
|
||||
free(cmap);
|
||||
}
|
||||
|
||||
/*
|
||||
static int fb_cmap_get(int fbfp,struct fb_cmap* cmap)
|
||||
#if 0
|
||||
static int
|
||||
fb_cmap_get(int fbfp, struct fb_cmap *cmap)
|
||||
{
|
||||
if(ioctl(fbfp,FBIOGETCMAP,cmap)){
|
||||
if (ioctl(fbfp, FBIOGETCMAP, cmap)) {
|
||||
perror("ioctl FBIOGETCMAP error\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fb_cmap_set(int fbfp,struct fb_cmap* cmap)
|
||||
static int
|
||||
fb_cmap_set(int fbfp, struct fb_cmap *cmap)
|
||||
{
|
||||
if(ioctl(fbfp,FBIOPUTCMAP,cmap)){
|
||||
if (ioctl(fbfp, FBIOPUTCMAP, cmap)) {
|
||||
perror("ioctl FBIOPUTCMAP error\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
/*
|
||||
フレームバッファに対するアクセス
|
||||
* フレームバッファに対するアクセス
|
||||
*
|
||||
* fb_mmap() フレームバッファのメモリ上へのマップ
|
||||
* fb_munmap() フレームバッファのメモリ上からのアンマップ
|
||||
*/
|
||||
|
||||
fb_mmap() フレームバッファのメモリ上へのマップ
|
||||
fb_munmap() フレームバッファのメモリ上からのアンマップ
|
||||
*/
|
||||
|
||||
static void *fb_mmap(int fbfp, struct fb_fix_screeninfo* scinfo)
|
||||
static void *
|
||||
fb_mmap(int fbfp, struct fb_fix_screeninfo *scinfo)
|
||||
{
|
||||
void *buf;
|
||||
if((buf=(unsigned char*)
|
||||
mmap(NULL, scinfo->smem_len, PROT_READ|PROT_WRITE,MAP_SHARED, fbfp, (off_t)0))
|
||||
==MAP_FAILED){
|
||||
if ((buf = (unsigned char *)
|
||||
mmap(NULL, scinfo->smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfp,
|
||||
(off_t) 0))
|
||||
== MAP_FAILED) {
|
||||
perror("mmap error");
|
||||
return NULL;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int fb_munmap(void* buf,struct fb_fix_screeninfo* scinfo)
|
||||
static int
|
||||
fb_munmap(void *buf, struct fb_fix_screeninfo *scinfo)
|
||||
{
|
||||
return munmap(buf,scinfo->smem_len);
|
||||
return munmap(buf, scinfo->smem_len);
|
||||
}
|
||||
|
||||
/*
|
||||
(struct fb_fix_screeninfo)デバイスに依存しない固定された情報
|
||||
|
||||
fb_fscrn_disp() 情報の表示
|
||||
fb_fscrn_get() 情報の獲得
|
||||
*/
|
||||
|
||||
|
||||
static int fb_fscrn_get(int fbfp,struct fb_fix_screeninfo* scinfo)
|
||||
* (struct fb_fix_screeninfo)デバイスに依存しない固定された情報
|
||||
*
|
||||
* fb_fscrn_disp() 情報の表示
|
||||
* fb_fscrn_get() 情報の獲得
|
||||
*/
|
||||
static int
|
||||
fb_fscrn_get(int fbfp, struct fb_fix_screeninfo *scinfo)
|
||||
{
|
||||
if(ioctl(fbfp,FBIOGET_FSCREENINFO,scinfo)){
|
||||
if (ioctl(fbfp, FBIOGET_FSCREENINFO, scinfo)) {
|
||||
perror("ioctl FBIOGET_FSCREENINFO error\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -572,30 +664,30 @@ static int fb_fscrn_get(int fbfp,struct fb_fix_screeninfo* scinfo)
|
||||
}
|
||||
|
||||
/*
|
||||
(struct fb_var_screeninfo)デバイスに依存しない変更可能な情報
|
||||
|
||||
fb_vscrn_disp() 情報の表示
|
||||
fb_vscrn_get() 情報の獲得
|
||||
fb_vscrn_set() 情報の設定
|
||||
*/
|
||||
|
||||
|
||||
static int fb_vscrn_get(int fbfp,struct fb_var_screeninfo* scinfo)
|
||||
* (struct fb_var_screeninfo)デバイスに依存しない変更可能な情報
|
||||
*
|
||||
* fb_vscrn_disp() 情報の表示
|
||||
* fb_vscrn_get() 情報の獲得
|
||||
* fb_vscrn_set() 情報の設定
|
||||
*/
|
||||
static int
|
||||
fb_vscrn_get(int fbfp, struct fb_var_screeninfo *scinfo)
|
||||
{
|
||||
if(ioctl(fbfp,FBIOGET_VSCREENINFO,scinfo)){
|
||||
if (ioctl(fbfp, FBIOGET_VSCREENINFO, scinfo)) {
|
||||
perror("ioctl FBIOGET_VSCREENINFO error\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
static int fb_vscrn_set(int fbfp,struct fb_var_screeninfo* scinfo)
|
||||
#if 0
|
||||
static int
|
||||
fb_vscrn_set(int fbfp, struct fb_var_screeninfo *scinfo)
|
||||
{
|
||||
if(ioctl(fbfp,FBIOPUT_VSCREENINFO,scinfo)){
|
||||
if (ioctl(fbfp, FBIOPUT_VSCREENINFO, scinfo)) {
|
||||
perror("ioctl FBIOPUT_VSCREENINFO error\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
+33
-25
@@ -1,4 +1,4 @@
|
||||
/* $Id: fb_gdkpixbuf.c,v 1.4 2002/07/18 15:01:31 ukai Exp $ */
|
||||
/* $Id: fb_gdkpixbuf.c,v 1.5 2002/07/18 15:12:06 ukai Exp $ */
|
||||
/**************************************************************************
|
||||
fb_gdkpixbuf.c 0.2 Copyright (C) 2002, hito
|
||||
**************************************************************************/
|
||||
@@ -6,22 +6,23 @@
|
||||
#include "fb.h"
|
||||
#include "fb_img.h"
|
||||
|
||||
static void set_prm(IMAGE *img);
|
||||
static void set_prm(IMAGE * img);
|
||||
|
||||
IMAGE *fb_load_image(char *filename, int w, int h)
|
||||
IMAGE *
|
||||
fb_load_image(char *filename, int w, int h)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
IMAGE *img;
|
||||
|
||||
if(filename == NULL)
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
|
||||
img = malloc(sizeof(*img));
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file(filename);
|
||||
if(pixbuf == NULL){
|
||||
if (pixbuf == NULL) {
|
||||
free(img);
|
||||
return NULL;
|
||||
}
|
||||
@@ -34,21 +35,22 @@ IMAGE *fb_load_image(char *filename, int w, int h)
|
||||
return img;
|
||||
}
|
||||
|
||||
int fb_draw_image(IMAGE *img, int x, int y, int sx, int sy, int width, int height)
|
||||
int
|
||||
fb_draw_image(IMAGE * img, int x, int y, int sx, int sy, int width, int height)
|
||||
{
|
||||
int i, j, r, g, b, offset, bpp;
|
||||
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return 1;
|
||||
|
||||
bpp = img->rowstride / img->width;
|
||||
for(j = sy; j < sy + height && j < img->height; j++){
|
||||
for (j = sy; j < sy + height && j < img->height; j++) {
|
||||
offset = j * img->rowstride + bpp * sx;
|
||||
for(i = sx; i < sx + width && i < img->width; i++, offset += bpp){
|
||||
for (i = sx; i < sx + width && i < img->width; i++, offset += bpp) {
|
||||
r = img->pixels[offset];
|
||||
g = img->pixels[offset + 1];
|
||||
b = img->pixels[offset + 2];
|
||||
if(img->alpha && img->pixels[offset + 3] == 0)
|
||||
if (img->alpha && img->pixels[offset + 3] == 0)
|
||||
fb_pset(i + x - sx, j + y - sy, bg_r, bg_g, bg_b);
|
||||
else
|
||||
fb_pset(i + x - sx, j + y - sy, r, g, b);
|
||||
@@ -57,17 +59,19 @@ int fb_draw_image(IMAGE *img, int x, int y, int sx, int sy, int width, int heigh
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fb_resize_image(IMAGE *img, int width, int height)
|
||||
int
|
||||
fb_resize_image(IMAGE * img, int width, int height)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
if(width < 1 || height < 1 || img == NULL)
|
||||
if (width < 1 || height < 1 || img == NULL)
|
||||
return 1;
|
||||
|
||||
if(width == img->width && height == img->height)
|
||||
if (width == img->width && height == img->height)
|
||||
return 0;
|
||||
|
||||
pixbuf = gdk_pixbuf_scale_simple(img->pixbuf, width, height, GDK_INTERP_HYPER);
|
||||
if(pixbuf == NULL)
|
||||
pixbuf =
|
||||
gdk_pixbuf_scale_simple(img->pixbuf, width, height, GDK_INTERP_HYPER);
|
||||
if (pixbuf == NULL)
|
||||
return 1;
|
||||
gdk_pixbuf_finalize(img->pixbuf);
|
||||
|
||||
@@ -76,29 +80,31 @@ int fb_resize_image(IMAGE *img, int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fb_free_image(IMAGE *img)
|
||||
void
|
||||
fb_free_image(IMAGE * img)
|
||||
{
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return;
|
||||
|
||||
gdk_pixbuf_finalize(img->pixbuf);
|
||||
free(img);
|
||||
}
|
||||
|
||||
IMAGE *fb_dup_image(IMAGE *img)
|
||||
IMAGE *
|
||||
fb_dup_image(IMAGE * img)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
IMAGE *new_img;
|
||||
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return NULL;
|
||||
|
||||
new_img = malloc(sizeof(*img));
|
||||
if(new_img == NULL)
|
||||
if (new_img == NULL)
|
||||
return NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_copy(img->pixbuf);
|
||||
if(pixbuf == NULL){
|
||||
if (pixbuf == NULL) {
|
||||
free(new_img);
|
||||
return NULL;
|
||||
}
|
||||
@@ -108,16 +114,18 @@ IMAGE *fb_dup_image(IMAGE *img)
|
||||
return new_img;
|
||||
}
|
||||
|
||||
int fb_rotate_image(IMAGE *img, int angle)
|
||||
int
|
||||
fb_rotate_image(IMAGE * img, int angle)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void set_prm(IMAGE *img)
|
||||
static void
|
||||
set_prm(IMAGE * img)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return;
|
||||
pixbuf = img->pixbuf;
|
||||
|
||||
|
||||
+7
-5
@@ -1,4 +1,4 @@
|
||||
/* $Id: fb_img.c,v 1.2 2002/07/18 15:01:31 ukai Exp $ */
|
||||
/* $Id: fb_img.c,v 1.3 2002/07/18 15:13:13 ukai Exp $ */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
@@ -10,19 +10,21 @@
|
||||
static int bg_r = 0, bg_g = 0, bg_b = 0;
|
||||
|
||||
#if defined(USE_IMLIB2)
|
||||
#include "w3mimg/fb/fb_imlib2.c"
|
||||
#include "w3mimg/fb/fb_imlib2.c"
|
||||
#elif defined(USE_GDKPIXBUF)
|
||||
#include "w3mimg/fb/fb_gdkpixbuf.c"
|
||||
#include "w3mimg/fb/fb_gdkpixbuf.c"
|
||||
#else
|
||||
#error no Imlib2 and GdkPixbuf support
|
||||
#endif
|
||||
|
||||
int fb_draw_image_simple(IMAGE *img, int x, int y)
|
||||
int
|
||||
fb_draw_image_simple(IMAGE * img, int x, int y)
|
||||
{
|
||||
return fb_draw_image(img, x, y, 0, 0, img->width, img->height);
|
||||
}
|
||||
|
||||
void fb_set_bg(int r, int g, int b)
|
||||
void
|
||||
fb_set_bg(int r, int g, int b)
|
||||
{
|
||||
bg_r = r;
|
||||
bg_g = g;
|
||||
|
||||
+41
-30
@@ -1,4 +1,4 @@
|
||||
/* $Id: fb_imlib2.c,v 1.4 2002/07/18 15:01:31 ukai Exp $ */
|
||||
/* $Id: fb_imlib2.c,v 1.5 2002/07/18 15:14:21 ukai Exp $ */
|
||||
/**************************************************************************
|
||||
fb_imlib2.c 0.2 Copyright (C) 2002, hito
|
||||
**************************************************************************/
|
||||
@@ -6,22 +6,23 @@
|
||||
#include "fb.h"
|
||||
#include "fb_img.h"
|
||||
|
||||
static void set_prm(IMAGE *img);
|
||||
static void set_prm(IMAGE * img);
|
||||
|
||||
IMAGE *fb_load_image(char *filename, int w, int h)
|
||||
IMAGE *
|
||||
fb_load_image(char *filename, int w, int h)
|
||||
{
|
||||
Imlib_Image image;
|
||||
IMAGE *img;
|
||||
|
||||
if(filename == NULL)
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
|
||||
img = malloc(sizeof(*img));
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return NULL;
|
||||
|
||||
image = imlib_load_image(filename);
|
||||
if(image == NULL){
|
||||
if (image == NULL) {
|
||||
free(img);
|
||||
return NULL;
|
||||
}
|
||||
@@ -36,22 +37,23 @@ IMAGE *fb_load_image(char *filename, int w, int h)
|
||||
return img;
|
||||
}
|
||||
|
||||
int fb_draw_image(IMAGE *img, int x, int y, int sx, int sy, int width, int height)
|
||||
int
|
||||
fb_draw_image(IMAGE * img, int x, int y, int sx, int sy, int width, int height)
|
||||
{
|
||||
int i, j, r, g, b, a = 0, offset;
|
||||
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return 1;
|
||||
|
||||
for(j = sy; j < sy + height && j < img->height; j++){
|
||||
for (j = sy; j < sy + height && j < img->height; j++) {
|
||||
offset = j * img->width;
|
||||
for(i = sx; i < sx + width && i < img->width; i++){
|
||||
for (i = sx; i < sx + width && i < img->width; i++) {
|
||||
a = (img->data[offset + i] >> 24) & 0x000000ff;
|
||||
r = (img->data[offset + i] >> 16) & 0x000000ff;
|
||||
g = (img->data[offset + i] >> 8) & 0x000000ff;
|
||||
b = (img->data[offset + i] ) & 0x000000ff;
|
||||
b = (img->data[offset + i]) & 0x000000ff;
|
||||
|
||||
if(a == 0)
|
||||
if (a == 0)
|
||||
fb_pset(i + x - sx, j + y - sy, bg_r, bg_g, bg_b);
|
||||
else
|
||||
fb_pset(i + x - sx, j + y - sy, r, g, b);
|
||||
@@ -60,18 +62,21 @@ int fb_draw_image(IMAGE *img, int x, int y, int sx, int sy, int width, int heigh
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fb_resize_image(IMAGE *img, int width, int height)
|
||||
int
|
||||
fb_resize_image(IMAGE * img, int width, int height)
|
||||
{
|
||||
Imlib_Image image;
|
||||
|
||||
if(width < 1 || height < 1 || img == NULL)
|
||||
if (width < 1 || height < 1 || img == NULL)
|
||||
return 1;
|
||||
|
||||
if(width == img->width && height == img->height)
|
||||
if (width == img->width && height == img->height)
|
||||
return 0;
|
||||
|
||||
image = imlib_create_cropped_scaled_image(0, 0, img->width, img->height, width, height);
|
||||
if(image == NULL)
|
||||
image =
|
||||
imlib_create_cropped_scaled_image(0, 0, img->width, img->height, width,
|
||||
height);
|
||||
if (image == NULL)
|
||||
return 1;
|
||||
|
||||
imlib_context_set_image(img->image);
|
||||
@@ -82,9 +87,10 @@ int fb_resize_image(IMAGE *img, int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fb_free_image(IMAGE *img)
|
||||
void
|
||||
fb_free_image(IMAGE * img)
|
||||
{
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return;
|
||||
|
||||
imlib_context_set_image(img->image);
|
||||
@@ -92,22 +98,23 @@ void fb_free_image(IMAGE *img)
|
||||
free(img);
|
||||
}
|
||||
|
||||
IMAGE *fb_dup_image(IMAGE *img)
|
||||
IMAGE *
|
||||
fb_dup_image(IMAGE * img)
|
||||
{
|
||||
Imlib_Image image;
|
||||
IMAGE *new_img;
|
||||
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return NULL;
|
||||
|
||||
new_img = malloc(sizeof(*img));
|
||||
if(new_img == NULL)
|
||||
if (new_img == NULL)
|
||||
return NULL;
|
||||
|
||||
imlib_context_set_image(img->image);
|
||||
image = imlib_clone_image();
|
||||
|
||||
if(image == NULL){
|
||||
if (image == NULL) {
|
||||
free(new_img);
|
||||
return NULL;
|
||||
}
|
||||
@@ -117,20 +124,23 @@ IMAGE *fb_dup_image(IMAGE *img)
|
||||
return new_img;
|
||||
}
|
||||
|
||||
int fb_rotate_image(IMAGE *img, int angle)
|
||||
int
|
||||
fb_rotate_image(IMAGE * img, int angle)
|
||||
{
|
||||
int orientation;
|
||||
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return 1;
|
||||
|
||||
imlib_context_set_image(img->image);
|
||||
|
||||
if(angle == 90){
|
||||
if (angle == 90) {
|
||||
orientation = 1;
|
||||
}else if(angle == -90){
|
||||
}
|
||||
else if (angle == -90) {
|
||||
orientation = 3;
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -139,9 +149,10 @@ int fb_rotate_image(IMAGE *img, int angle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_prm(IMAGE *img)
|
||||
static void
|
||||
set_prm(IMAGE * img)
|
||||
{
|
||||
if(img == NULL)
|
||||
if (img == NULL)
|
||||
return;
|
||||
|
||||
imlib_context_set_image(img->image);
|
||||
|
||||
+4
-3
@@ -1,8 +1,10 @@
|
||||
/* $Id: w3mimg.c,v 1.1 2002/07/18 06:07:39 ukai Exp $ */
|
||||
/* $Id: w3mimg.c,v 1.2 2002/07/18 15:14:36 ukai Exp $ */
|
||||
|
||||
#include "w3mimg/w3mimg.h"
|
||||
|
||||
w3mimg_op *w3mimg_open() {
|
||||
w3mimg_op *
|
||||
w3mimg_open()
|
||||
{
|
||||
w3mimg_op *w_op = NULL;
|
||||
#ifdef USE_W3MIMG_X11
|
||||
if (w_op == NULL)
|
||||
@@ -14,4 +16,3 @@ w3mimg_op *w3mimg_open() {
|
||||
#endif
|
||||
return w_op;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
/* $Id: w3mimg.h,v 1.2 2002/07/18 06:07:25 ukai Exp $ */
|
||||
/* $Id: w3mimg.h,v 1.3 2002/07/18 15:14:51 ukai Exp $ */
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_W3MIMG_FB
|
||||
@@ -17,18 +17,18 @@ typedef struct _w3mimg_op {
|
||||
int width, height; /* window width, height */
|
||||
int offset_x, offset_y; /* offset */
|
||||
|
||||
int (*init)(struct _w3mimg_op *self);
|
||||
int (*finish)(struct _w3mimg_op *self);
|
||||
int (*active)(struct _w3mimg_op *self);
|
||||
void (*set_background)(struct _w3mimg_op *self, char *background);
|
||||
void (*sync)(struct _w3mimg_op *self);
|
||||
void (*close)(struct _w3mimg_op *self);
|
||||
int (*init) (struct _w3mimg_op * self);
|
||||
int (*finish) (struct _w3mimg_op * self);
|
||||
int (*active) (struct _w3mimg_op * self);
|
||||
void (*set_background) (struct _w3mimg_op * self, char *background);
|
||||
void (*sync) (struct _w3mimg_op * self);
|
||||
void (*close) (struct _w3mimg_op * self);
|
||||
|
||||
int (*load_image)(struct _w3mimg_op *self, W3MImage *img, char *fname,
|
||||
int (*load_image) (struct _w3mimg_op * self, W3MImage * img, char *fname,
|
||||
int w, int h);
|
||||
int (*show_image)(struct _w3mimg_op *self, W3MImage *img,
|
||||
int (*show_image) (struct _w3mimg_op * self, W3MImage * img,
|
||||
int sx, int sy, int sw, int sh, int x, int y);
|
||||
void (*free_image)(struct _w3mimg_op *self, W3MImage *img);
|
||||
void (*free_image) (struct _w3mimg_op * self, W3MImage * img);
|
||||
} w3mimg_op;
|
||||
|
||||
#ifdef USE_W3MIMG_X11
|
||||
|
||||
+22
-23
@@ -1,4 +1,4 @@
|
||||
/* $Id: x11_w3mimg.c,v 1.3 2002/07/18 14:32:12 ukai Exp $ */
|
||||
/* $Id: x11_w3mimg.c,v 1.4 2002/07/18 15:15:32 ukai Exp $ */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -19,7 +19,7 @@ struct x11_info {
|
||||
};
|
||||
|
||||
static int
|
||||
x11_init(w3mimg_op *self)
|
||||
x11_init(w3mimg_op * self)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
if (self == NULL)
|
||||
@@ -27,21 +27,21 @@ x11_init(w3mimg_op *self)
|
||||
xi = (struct x11_info *)self->priv;
|
||||
if (xi == NULL)
|
||||
return 0;
|
||||
if (! xi->id) {
|
||||
if (!xi->id) {
|
||||
xi->id = Imlib_init(xi->display);
|
||||
if (! xi->id)
|
||||
if (!xi->id)
|
||||
return 0;
|
||||
}
|
||||
if (! xi->imageGC) {
|
||||
if (!xi->imageGC) {
|
||||
xi->imageGC = XCreateGC(xi->display, xi->parent, 0, NULL);
|
||||
if (! xi->imageGC)
|
||||
if (!xi->imageGC)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
x11_finish(w3mimg_op *self)
|
||||
x11_finish(w3mimg_op * self)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
if (self == NULL)
|
||||
@@ -57,7 +57,7 @@ x11_finish(w3mimg_op *self)
|
||||
}
|
||||
|
||||
static int
|
||||
x11_active(w3mimg_op *self)
|
||||
x11_active(w3mimg_op * self)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
if (self == NULL)
|
||||
@@ -65,13 +65,13 @@ x11_active(w3mimg_op *self)
|
||||
xi = (struct x11_info *)self->priv;
|
||||
if (xi == NULL)
|
||||
return 0;
|
||||
if (! xi->imageGC)
|
||||
if (!xi->imageGC)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_set_background(w3mimg_op *self, char *background)
|
||||
x11_set_background(w3mimg_op * self, char *background)
|
||||
{
|
||||
XColor screen_def, exact_def;
|
||||
struct x11_info *xi;
|
||||
@@ -110,7 +110,7 @@ x11_set_background(w3mimg_op *self, char *background)
|
||||
}
|
||||
|
||||
static void
|
||||
x11_sync(w3mimg_op *self)
|
||||
x11_sync(w3mimg_op * self)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
if (self == NULL)
|
||||
@@ -122,13 +122,13 @@ x11_sync(w3mimg_op *self)
|
||||
}
|
||||
|
||||
static void
|
||||
x11_close(w3mimg_op *self)
|
||||
x11_close(w3mimg_op * self)
|
||||
{
|
||||
/* XCloseDisplay(xi->display); */
|
||||
}
|
||||
|
||||
static int
|
||||
x11_load_image(w3mimg_op *self, W3MImage *img, char *fname, int w, int h)
|
||||
x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
ImlibImage *im;
|
||||
@@ -148,11 +148,11 @@ x11_load_image(w3mimg_op *self, W3MImage *img, char *fname, int w, int h)
|
||||
h = im->rgb_height;
|
||||
img->pixmap = (void *)XCreatePixmap(xi->display, xi->parent, w, h,
|
||||
DefaultDepth(xi->display, 0));
|
||||
if (! img->pixmap)
|
||||
if (!img->pixmap)
|
||||
return 0;
|
||||
XSetForeground(xi->display, xi->imageGC, xi->background_pixel);
|
||||
XFillRectangle(xi->display, (Pixmap)img->pixmap, xi->imageGC, 0, 0, w, h);
|
||||
Imlib_paste_image(xi->id, im, (Pixmap)img->pixmap, 0, 0, w, h);
|
||||
XFillRectangle(xi->display, (Pixmap) img->pixmap, xi->imageGC, 0, 0, w, h);
|
||||
Imlib_paste_image(xi->id, im, (Pixmap) img->pixmap, 0, 0, w, h);
|
||||
Imlib_kill_image(xi->id, im);
|
||||
img->width = w;
|
||||
img->height = h;
|
||||
@@ -160,8 +160,8 @@ x11_load_image(w3mimg_op *self, W3MImage *img, char *fname, int w, int h)
|
||||
}
|
||||
|
||||
static int
|
||||
x11_show_image(w3mimg_op *self, W3MImage *img, int sx, int sy, int sw, int sh,
|
||||
int x, int y)
|
||||
x11_show_image(w3mimg_op * self, W3MImage * img, int sx, int sy, int sw,
|
||||
int sh, int x, int y)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
if (self == NULL)
|
||||
@@ -170,16 +170,15 @@ x11_show_image(w3mimg_op *self, W3MImage *img, int sx, int sy, int sw, int sh,
|
||||
if (xi == NULL)
|
||||
return 0;
|
||||
|
||||
XCopyArea(xi->display, (Pixmap)img->pixmap, xi->window, xi->imageGC,
|
||||
XCopyArea(xi->display, (Pixmap) img->pixmap, xi->window, xi->imageGC,
|
||||
sx, sy,
|
||||
(sw ? sw : img->width),
|
||||
(sh ? sh : img->height),
|
||||
x + self->offset_x, y + self->offset_y);
|
||||
(sh ? sh : img->height), x + self->offset_x, y + self->offset_y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_free_image(w3mimg_op *self, W3MImage *img)
|
||||
x11_free_image(w3mimg_op * self, W3MImage * img)
|
||||
{
|
||||
struct x11_info *xi;
|
||||
if (self == NULL)
|
||||
@@ -188,7 +187,7 @@ x11_free_image(w3mimg_op *self, W3MImage *img)
|
||||
if (xi == NULL)
|
||||
return;
|
||||
if (img && img->pixmap) {
|
||||
XFreePixmap(xi->display, (Pixmap)img->pixmap);
|
||||
XFreePixmap(xi->display, (Pixmap) img->pixmap);
|
||||
img->pixmap = NULL;
|
||||
img->width = 0;
|
||||
img->height = 0;
|
||||
|
||||
Reference in New Issue
Block a user