comparison Gui/bitmap.c @ 10169:46badb3d0b1c

simplyfied it and fixed some 10ls (but sadly xshape still don't works)
author alex
date Fri, 23 May 2003 17:23:35 +0000
parents 22572f1dafa3
children c30e193ac112
comparison
equal deleted inserted replaced
10168:22572f1dafa3 10169:46badb3d0b1c
106 return 1; 106 return 1;
107 } 107 }
108 memset( bf->Image,0,bf->ImageSize ); 108 memset( bf->Image,0,bf->ImageSize );
109 for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); ) 109 for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); )
110 { 110 {
111 #ifndef WORDS_BIGENDIAN
112 bf->Image[c++]=tmpImage[i++]; //red 111 bf->Image[c++]=tmpImage[i++]; //red
113 bf->Image[c++]=tmpImage[i++]; //green 112 bf->Image[c++]=tmpImage[i++]; //green
114 bf->Image[c++]=tmpImage[i++]; c++; //blue 113 bf->Image[c++]=tmpImage[i++]; c++; //blue
115 #else
116 unsigned char t=tmpImage[i++];
117 bf->Image[c++]=tmpImage[i++]; //green
118 bf->Image[c++]=t; c++; //red
119 bf->Image[c++]=tmpImage[i++]; //blue
120 #endif
121 } 114 }
122 free( tmpImage ); 115 free( tmpImage );
123 } 116 }
124 return 0; 117 return 0;
125 } 118 }
186 if ( bf->BPP < 24 ) 179 if ( bf->BPP < 24 )
187 { 180 {
188 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" ); 181 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" );
189 return -1; 182 return -1;
190 } 183 }
184 if ( conv24to32( bf ) ) return -8;
191 #ifdef WORDS_BIGENDIAN 185 #ifdef WORDS_BIGENDIAN
192 if (bf->BPP == 32) 186 swab(bf->Image, bf->Image, bf->ImageSize);
193 swab(bf->Image, bf->Image, bf->ImageSize);
194 #endif 187 #endif
195 if ( conv24to32( bf ) ) return -8;
196 bgr2rgb( bf ); 188 bgr2rgb( bf );
197 Normalize( bf ); 189 Normalize( bf );
198 return 0; 190 return 0;
199 } 191 }
200 192
202 { 194 {
203 out->Width=in->Width; 195 out->Width=in->Width;
204 out->Height=in->Height; 196 out->Height=in->Height;
205 out->BPP=1; 197 out->BPP=1;
206 out->ImageSize=(out->Width * out->Height + 7) / 8; 198 out->ImageSize=(out->Width * out->Height + 7) / 8;
207 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize ); 199 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize );
208 out->Image=(char *)calloc( 1,out->ImageSize ); 200 out->Image=(char *)calloc( 1,out->ImageSize );
209 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[c32to1] Not enough memory for image.\n" ); 201 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[c32to1] Not enough memory for image.\n" );
210 { 202 {
211 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; 203 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1;
212 buf=(unsigned int *)in->Image; 204 buf=(unsigned int *)in->Image;
227 out->Width=in->Width; 219 out->Width=in->Width;
228 out->Height=in->Height; 220 out->Height=in->Height;
229 out->BPP=32; 221 out->BPP=32;
230 out->ImageSize=out->Width * out->Height * 4; 222 out->ImageSize=out->Width * out->Height * 4;
231 out->Image=(char *)calloc( 1,out->ImageSize ); 223 out->Image=(char *)calloc( 1,out->ImageSize );
232 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize ); 224 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize );
233 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[c1to32] Not enough memory for image.\n" ); 225 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[c1to32] Not enough memory for image.\n" );
234 { 226 {
235 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; 227 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0;
236 buf=(unsigned int *)out->Image; 228 buf=(unsigned int *)out->Image;
237 for ( c=0,i=0;i < (int)(in->Width * in->Height / 8);i++ ) 229 for ( c=0,i=0;i < (int)(in->Width * in->Height / 8);i++ )