annotate gui/bitmap.c @ 23185:3d2aedade36f

dvdnav:// depends on our fork of libdvdnav
author nicodvb
date Tue, 01 May 2007 20:02:05 +0000
parents 17bf4f4b0715
children 7857af1ca50b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
2 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
3 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
4
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
5 #include <png.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
6
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
7 #include "mp_msg.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
8 #include "help_mp.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
9 #include "bitmap.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
10
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
11 int pngRead( unsigned char * fname,txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
12 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
13 unsigned char header[8];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
14 png_structp png;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
15 png_infop info;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
16 png_infop endinfo;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
17 png_bytep * row_p;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18 png_bytep palette = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
19 int color;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 png_uint_32 i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 FILE *fp=fopen( fname,"rb" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 if ( !fp )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s )\n",fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 return 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29 fread( header,1,8,fp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30 if ( !png_check_sig( header,8 ) ) return 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33 info=png_create_info_struct( png );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34 endinfo=png_create_info_struct( png );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36 png_init_io( png,fp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
37 png_set_sig_bytes( png,8 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
38 png_read_info( png,info );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
39 png_get_IHDR( png,info,&bf->Width,&bf->Height,&bf->BPP,&color,NULL,NULL,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
41 row_p=malloc( sizeof( png_bytep ) * bf->Height );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42 if ( !row_p )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
43 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
44 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] not enough memory for row buffer\n" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45 return 2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 bf->Image=(png_bytep)malloc( png_get_rowbytes( png,info ) * bf->Height );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48 if ( !bf->Image )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] not enough memory for image buffer\n" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51 return 2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53 for ( i=0; i < bf->Height; i++ ) row_p[i]=&bf->Image[png_get_rowbytes( png,info ) * i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 png_read_image( png,row_p );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 free( row_p );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 #if 0
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59 if ( color == PNG_COLOR_TYPE_PALETTE )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61 int cols;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 png_get_PLTE( png,info,(png_colorp *)&palette,&cols );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 if ( color&PNG_COLOR_MASK_ALPHA )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA ) bf->BPP*=2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 else bf->BPP*=4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 else
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY ) bf->BPP*=1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 else bf->BPP*=3;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 png_read_end( png,endinfo );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 png_destroy_read_struct( &png,&info,&endinfo );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 if ( fclose( fp ) != 0 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 free( bf->Image );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 free( palette );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 return 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
85 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 bf->ImageSize=bf->Width * bf->Height * ( bf->BPP / 8 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] size: %dx%d bits: %d\n",bf->Width,bf->Height,bf->BPP );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] imagesize: %lu\n",bf->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 int conv24to32( txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 unsigned char * tmpImage;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 int i,c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 if ( bf->BPP == 24 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 tmpImage=bf->Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 bf->ImageSize=bf->Width * bf->Height * 4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 bf->BPP=32;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] not enough memory for image\n" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 return 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 memset( bf->Image,0,bf->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 bf->Image[c++]=tmpImage[i++]; //red
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 bf->Image[c++]=tmpImage[i++]; //green
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 bf->Image[c++]=tmpImage[i++]; c++; //blue
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 free( tmpImage );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 void bgr2rgb( txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 unsigned char c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 for ( i=0;i < (int)bf->ImageSize;i+=4 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 c=bf->Image[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 bf->Image[i]=bf->Image[i+2];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 bf->Image[i+2]=c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 void Normalize( txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 #ifndef WORDS_BIGENDIAN
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i+3]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 #else
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 unsigned char tmp[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 unsigned char * fExist( unsigned char * fname )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 FILE * fl;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 unsigned char ext[][6] = { ".png\0",".PNG\0" };
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 fl=fopen( fname,"rb" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153 if ( fl != NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 fclose( fl );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 return fname;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 for ( i=0;i<2;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 snprintf( tmp,511,"%s%s",fname,ext[i] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161 fl=fopen( tmp,"rb" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 if ( fl != NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 fclose( fl );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 return tmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
168 return NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 int bpRead( char * fname, txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 fname=fExist( fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 if ( fname == NULL ) return -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 if ( pngRead( fname,bf ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 mp_dbg( MSGT_GPLAYER,MSGL_FATAL,"[bitmap] unknown file type ( %s )\n",fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 return -5;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 if ( bf->BPP < 24 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183 return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 if ( conv24to32( bf ) ) return -8;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 #ifdef WORDS_BIGENDIAN
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 swab(bf->Image, bf->Image, bf->ImageSize);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 bgr2rgb( bf );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 Normalize( bf );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 void Convert32to1( txSample * in,txSample * out,int adaptivlimit )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 out->Width=in->Width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 out->Height=in->Height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 out->BPP=1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
199 out->ImageSize=(out->Width * out->Height + 7) / 8;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 out->Image=calloc( 1,out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotEnoughMemoryC32To1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 buf=(unsigned int *)in->Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 for ( b=0,i=0;i < (int)(out->Width * out->Height);i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 if ( (int)buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 else { tmp=tmp >> 1; buf[i]=nothaveshape=0; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 if ( b ) out->Image[c]=tmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 if ( nothaveshape ) { free( out->Image ); out->Image=NULL; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
214 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
215 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 void Convert1to32( txSample * in,txSample * out )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
218 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
219 if ( in->Image == NULL ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
220 out->Width=in->Width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221 out->Height=in->Height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
222 out->BPP=32;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 out->ImageSize=out->Width * out->Height * 4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
224 out->Image=calloc( 1,out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
225 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotEnoughMemoryC1To32 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
227 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 buf=(unsigned int *)out->Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
230 for ( c=0,i=0;i < (int)(in->Width * in->Height / 8);i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
231 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 tmp=in->Image[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233 for ( b=0;b<8;b++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
234 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235 buf[c]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 if ( tmp&0x1 ) buf[c]=0xffffffff;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 c++; tmp=tmp>>1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 }