annotate Gui/bitmap.c @ 6464:60211818e5b9

Applied Cygwin patch by Sylvain Petreolle <spetreolle@yahoo.fr>, adjusted for coding style.
author diego
date Wed, 19 Jun 2002 23:44:42 +0000
parents dcf195b784bf
children 634d93c68912
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1
2080
f91ad6d23ce9 gcc3 warning fixed
arpi
parents: 1693
diff changeset
2 #include <stdio.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
3 #include <stdlib.h>
2080
f91ad6d23ce9 gcc3 warning fixed
arpi
parents: 1693
diff changeset
4 #include <string.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
5
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
6 #include "bitmap.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
7
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
8 #define BMP 1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
9 #define TGA 2
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
10 #define PNG 3
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
11 #define TGAPACKED 4
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
12
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
13 extern char * strcat( char * dest,const char * src );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15 int conv24to32( txSample * bf )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
16 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17 unsigned char * tmpImage;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18 int i,c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
20 if ( bf->BPP == 24 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
22 tmpImage=bf->Image;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23 bf->ImageSize=bf->Width * bf->Height * 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
24 bf->BPP=32;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
25 if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
26 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
27 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Not enough memory for image.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
28 return 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
29 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30 memset( bf->Image,0,bf->ImageSize );
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
31 for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32 {
6054
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
33 #ifndef WORDS_BIGENDIAN
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
34 bf->Image[c++]=tmpImage[i++]; //red
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
35 bf->Image[c++]=tmpImage[i++]; //green
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
36 bf->Image[c++]=tmpImage[i++]; c++; //blue
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
37 #else
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
38 unsigned char t=tmpImage[i++];
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
39 bf->Image[c++]=tmpImage[i++]; //green
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
40 bf->Image[c++]=t; c++; //red
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
41 bf->Image[c++]=tmpImage[i++]; //blue
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
42 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44 free( tmpImage );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
47 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 void bgr2rgb( txSample * bf )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 unsigned char c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
54 for ( i=0;i < (int)bf->ImageSize;i+=4 )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56 c=bf->Image[i];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 bf->Image[i]=bf->Image[i+2];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58 bf->Image[i+2]=c;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62 void Normalize( txSample * bf )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
64 int i;
6054
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
65 #ifndef WORDS_BIGENDIAN
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
66 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i+3]=0;
6054
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
67 #else
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
68 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i]=0;
35689e1e6745 bigendian fix by Colin Leroy <colin@colino.net>
arpi
parents: 4818
diff changeset
69 #endif
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 unsigned char tmp[512];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
73
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
74 unsigned char * fExist( unsigned char * fname )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
75 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 FILE * fl;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77 unsigned char ext[][6] = { ".tga\0",".TGA\0",".png\0",".PNG\0",".bmp\0",".BMP\0" };
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80 fl=fopen( fname,"rb" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81 if ( fl != NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83 fclose( fl );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
84 return fname;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
85 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 for ( i=0;i<10;i++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88 strcpy( tmp,fname );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 strcat( tmp,ext[i] );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90 fl=fopen( tmp,"rb" );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 if ( fl != NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93 fclose( fl );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94 return tmp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
95 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
97 return NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
98 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
99
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
100 int aComp( unsigned char * b1,unsigned char * b2,int size )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
101 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
102 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
103 for( i=0;i<size;i++ ) if ( b1[i] != b2[i] ) return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
104 return 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
105 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
106
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
107 int GetFileType( char * fname )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
108 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
109 FILE * fl;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
110 unsigned char buffer[10];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
111 unsigned char bmp[2] = { 0x42,0x4d };
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112 unsigned char tga[7] = { 0x00,0x02,0x00,0x00,0x00,0x00,0x00 };
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
113 unsigned char ptga[7] = { 0x00,0x0a,0x00,0x00,0x00,0x00,0x00 };
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
114 unsigned char png[8] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a };
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
115
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
116 if ( ( fl=fopen( fname,"rb" ) ) == NULL ) return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
117 fread( buffer,1,10,fl );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 fclose( fl );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
119
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
120 if ( aComp( buffer,bmp,2 ) ) return BMP; // --- bmp
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
121 if ( aComp( &buffer[1],tga,8 ) ) return TGA; // --- tga
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
122 if ( aComp( &buffer[1],ptga,7 ) ) return TGAPACKED; // --- tga
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
123 if ( aComp( buffer,png,8 ) ) return PNG; // --- png
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
124 return 0; // --- others
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
125 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
126
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
127 int bpRead( char * fname, txSample * bf )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129 int bgr = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
130 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 fname=fExist( fname );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 if ( fname == NULL ) return -2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
134 switch ( GetFileType( fname ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
135 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
136 case BMP:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
137 i=bmpRead( fname,bf );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
138 switch ( i )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
139 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
140 case 0: break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
141 case 3: return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
142 default: return -3;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
143 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
144 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
145 case TGA:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
146 i=tgaRead( fname,bf );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
147 switch ( i )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
148 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
149 case 0: break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
150 case 3: return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
151 default: return -4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
152 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
153 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
154 case PNG:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
155 if ( pngRead( fname,bf ) ) return -5;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
156 bgr=1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
157 break;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
158 case TGAPACKED:
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
159 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] sorry, packed TGA not supported.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
160 return -6;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
161 default:
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
162 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
163 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Unknown file type ( %s ).\n",fname );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
164 return -7;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
165 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
166 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
167 if ( bf->BPP < 24 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
168 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
169 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] sorry, 16 or less bitmaps not supported.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
170 return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
171 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
172 if ( conv24to32( bf ) ) return -8;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
173 if ( bgr ) bgr2rgb( bf );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
174 Normalize( bf );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
175 return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
176 }
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
177
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
178 void Convert32to1( txSample * in,txSample * out,int adaptivlimit )
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
179 {
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
180 out->Width=in->Width;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
181 out->Height=in->Height;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
182 out->BPP=1;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
183 out->ImageSize=out->Width * out->Height / 8;
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
184 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize );
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
185 out->Image=(char *)calloc( 1,out->ImageSize );
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
186 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"nem van ram baze\n" );
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
187 {
6145
26cb8736927b Gui and 64-bit issues patch from Gui and 64-bit issues
pontscho
parents: 6054
diff changeset
188 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1;
26cb8736927b Gui and 64-bit issues patch from Gui and 64-bit issues
pontscho
parents: 6054
diff changeset
189 buf=(unsigned int *)in->Image;
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
190 for ( b=0,i=0;i < (int)(out->Width * out->Height);i++ )
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
191 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
192 if ( (int)buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128;
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
193 else { tmp=tmp >> 1; buf[i]=nothaveshape=0; }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
194 if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
195 }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
196 if ( b ) out->Image[c]=tmp;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
197 if ( nothaveshape ) { free( out->Image ); out->Image=NULL; }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
198 }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
199 }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
200
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
201 void Convert1to32( txSample * in,txSample * out )
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
202 {
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
203 if ( in->Image == NULL ) return;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
204 out->Width=in->Width;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
205 out->Height=in->Height;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
206 out->BPP=32;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
207 out->ImageSize=out->Width * out->Height * 4;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
208 out->Image=(char *)calloc( 1,out->ImageSize );
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
209 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize );
6159
dcf195b784bf applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents: 6145
diff changeset
210 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"nem van ram baze\n" );
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
211 {
6145
26cb8736927b Gui and 64-bit issues patch from Gui and 64-bit issues
pontscho
parents: 6054
diff changeset
212 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0;
26cb8736927b Gui and 64-bit issues patch from Gui and 64-bit issues
pontscho
parents: 6054
diff changeset
213 buf=(unsigned int *)out->Image;
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2717
diff changeset
214 for ( c=0,i=0;i < (int)(in->Width * in->Height / 8);i++ )
2717
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
215 {
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
216 tmp=in->Image[i];
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
217 for ( b=0;b<8;b++ )
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
218 {
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
219 buf[c]=0;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
220 if ( tmp&0x1 ) buf[c]=0xffffffff;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
221 c++; tmp=tmp>>1;
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
222 }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
223 }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
224 }
5fa8c079ee3c fix small xshape bug
pontscho
parents: 2080
diff changeset
225 }