From f691833dd39284ef97d97ae7e8c52f82558804aa Mon Sep 17 00:00:00 2001 From: pontscho Date: Mon, 5 Nov 2001 17:00:42 +0000 Subject: fix small xshape bug git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2718 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Gui/bitmap.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Gui/bitmap.h | 2 ++ Gui/bitmap/bitmap.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Gui/bitmap/bitmap.h | 2 ++ Gui/skin/skin.c | 13 ++++++++++++- 5 files changed, 114 insertions(+), 1 deletion(-) (limited to 'Gui') diff --git a/Gui/bitmap.c b/Gui/bitmap.c index f47858095b..657c1f3330 100644 --- a/Gui/bitmap.c +++ b/Gui/bitmap.c @@ -173,3 +173,52 @@ int bpRead( char * fname, txSample * bf ) Normalize( bf ); return 0; } + +void Convert32to1( txSample * in,txSample * out,int adaptivlimit ) +{ + out->Width=in->Width; + out->Height=in->Height; + out->BPP=1; + out->ImageSize=out->Width * out->Height / 8; + dbprintf( 4,"[c1to32] imagesize: %d\n",out->ImageSize ); + out->Image=(char *)calloc( 1,out->ImageSize ); + if ( out->Image == NULL ) dbprintf( 4,"nem van ram baze\n" ); + { + int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; + buf=(unsigned long *)in->Image; + for ( b=0,i=0;i < out->Width * out->Height;i++ ) + { + if ( buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128; + else { tmp=tmp >> 1; buf[i]=nothaveshape=0; } + if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; } + } + if ( b ) out->Image[c]=tmp; + if ( nothaveshape ) { free( out->Image ); out->Image=NULL; } + } +} + +void Convert1to32( txSample * in,txSample * out ) +{ + if ( in->Image == NULL ) return; + out->Width=in->Width; + out->Height=in->Height; + out->BPP=32; + out->ImageSize=out->Width * out->Height * 4; + out->Image=(char *)calloc( 1,out->ImageSize ); + dbprintf( 4,"[c32to1] imagesize: %d\n",out->ImageSize ); + if ( out->Image == NULL ) dbprintf( 4,"nem van ram baze\n" ); + { + int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; + buf=(unsigned long *)out->Image; + for ( c=0,i=0;i < in->Width * in->Height / 8;i++ ) + { + tmp=in->Image[i]; + for ( b=0;b<8;b++ ) + { + buf[c]=0; + if ( tmp&0x1 ) buf[c]=0xffffffff; + c++; tmp=tmp>>1; + } + } + } +} diff --git a/Gui/bitmap.h b/Gui/bitmap.h index 9a6d5ebf18..6daa2927a1 100644 --- a/Gui/bitmap.h +++ b/Gui/bitmap.h @@ -17,5 +17,7 @@ typedef struct _txSample extern int bpRead( char * fname, txSample * bf ); extern int conv24to32( txSample * bf ); +extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit ); +extern void Convert1to32( txSample * in,txSample * out ); #endif diff --git a/Gui/bitmap/bitmap.c b/Gui/bitmap/bitmap.c index f47858095b..657c1f3330 100644 --- a/Gui/bitmap/bitmap.c +++ b/Gui/bitmap/bitmap.c @@ -173,3 +173,52 @@ int bpRead( char * fname, txSample * bf ) Normalize( bf ); return 0; } + +void Convert32to1( txSample * in,txSample * out,int adaptivlimit ) +{ + out->Width=in->Width; + out->Height=in->Height; + out->BPP=1; + out->ImageSize=out->Width * out->Height / 8; + dbprintf( 4,"[c1to32] imagesize: %d\n",out->ImageSize ); + out->Image=(char *)calloc( 1,out->ImageSize ); + if ( out->Image == NULL ) dbprintf( 4,"nem van ram baze\n" ); + { + int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; + buf=(unsigned long *)in->Image; + for ( b=0,i=0;i < out->Width * out->Height;i++ ) + { + if ( buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128; + else { tmp=tmp >> 1; buf[i]=nothaveshape=0; } + if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; } + } + if ( b ) out->Image[c]=tmp; + if ( nothaveshape ) { free( out->Image ); out->Image=NULL; } + } +} + +void Convert1to32( txSample * in,txSample * out ) +{ + if ( in->Image == NULL ) return; + out->Width=in->Width; + out->Height=in->Height; + out->BPP=32; + out->ImageSize=out->Width * out->Height * 4; + out->Image=(char *)calloc( 1,out->ImageSize ); + dbprintf( 4,"[c32to1] imagesize: %d\n",out->ImageSize ); + if ( out->Image == NULL ) dbprintf( 4,"nem van ram baze\n" ); + { + int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; + buf=(unsigned long *)out->Image; + for ( c=0,i=0;i < in->Width * in->Height / 8;i++ ) + { + tmp=in->Image[i]; + for ( b=0;b<8;b++ ) + { + buf[c]=0; + if ( tmp&0x1 ) buf[c]=0xffffffff; + c++; tmp=tmp>>1; + } + } + } +} diff --git a/Gui/bitmap/bitmap.h b/Gui/bitmap/bitmap.h index 9a6d5ebf18..6daa2927a1 100644 --- a/Gui/bitmap/bitmap.h +++ b/Gui/bitmap/bitmap.h @@ -17,5 +17,7 @@ typedef struct _txSample extern int bpRead( char * fname, txSample * bf ); extern int conv24to32( txSample * bf ); +extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit ); +extern void Convert1to32( txSample * in,txSample * out ); #endif diff --git a/Gui/skin/skin.c b/Gui/skin/skin.c index e5ba002699..21666db7b6 100644 --- a/Gui/skin/skin.c +++ b/Gui/skin/skin.c @@ -132,6 +132,7 @@ int __base( char * in ) defList->main.width=defList->main.Bitmap.Width; defList->main.height=defList->main.Bitmap.Height; #ifdef HAVE_XSHAPE +/* defList->main.Mask.Width=defList->main.Bitmap.Width; defList->main.Mask.Height=defList->main.Bitmap.Height; defList->main.Mask.BPP=1; @@ -148,7 +149,17 @@ int __base( char * in ) if ( b++ == 7 ) { defList->main.Mask.Image[c++]=tmp; tmp=b=0; } } if ( b ) defList->main.Mask.Image[c]=tmp; - if ( nothaveshape ) { free( defList->main.Mask.Image ); defList->main.Mask.Image=NULL; } +// if ( nothaveshape ) { free( defList->main.Mask.Image ); defList->main.Mask.Image=NULL; } + } +*/ + Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff ); + { + if ( defList->main.Mask.Image != NULL ) + { + txSample d; + Convert1to32( &defList->main.Mask,&d ); + tgaWriteTexture( "debug.tga",&d ); + } } #ifdef DEBUG dbprintf( 3,"[skin] mask: %dx%d\n",defList->main.Mask.Width,defList->main.Mask.Height ); -- cgit v1.2.3