annotate gui/bitmap.c @ 23193:7857af1ca50b

Remove libpng dependency for Gui, use libavcodec instead
author reimar
date Wed, 02 May 2007 14:39:55 +0000
parents 17bf4f4b0715
children c627c0ec88cf
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 "mp_msg.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
6 #include "help_mp.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
7 #include "bitmap.h"
23193
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
8 #ifdef USE_LIBAVCODEC_SO
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
9 #include <ffmpeg/avcodec.h>
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
10 #else
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
11 #include "libavcodec/avcodec.h"
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
12 #endif
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
13 #include "libvo/fastmemcpy.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
14
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
15 int pngRead( unsigned char * fname,txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
16 {
23193
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
17 int decode_ok;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
18 void *data;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
19 int len;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
20 AVCodecContext *avctx;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
21 AVFrame *frame;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 FILE *fp=fopen( fname,"rb" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 if ( !fp )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s )\n",fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 return 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29
23193
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
30 fseek(fp, 0, SEEK_END);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
31 len = ftell(fp);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
32 if (len > 50 * 1024 * 1024) return 2;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
33 data = malloc(len + FF_INPUT_BUFFER_PADDING_SIZE);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
34 fseek(fp, 0, SEEK_SET);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
35 fread(data, len, 1, fp);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
36 fclose(fp);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
37 avctx = avcodec_alloc_context();
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
38 frame = avcodec_alloc_frame();
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
39 avcodec_open(avctx, &png_decoder);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
40 avcodec_decode_video(avctx, frame, &decode_ok, data, len);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
41 memset(bf, 0, sizeof(*bf));
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
42 switch (avctx->pix_fmt) {
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
43 case PIX_FMT_GRAY8: bf->BPP = 8; break;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
44 case PIX_FMT_GRAY16BE: bf->BPP = 16; break;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
45 case PIX_FMT_RGB24: bf->BPP = 24; break;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
46 case PIX_FMT_RGB32: bf->BPP = 32; break;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
47 default: bf->BPP = 0; break;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
48 }
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
49 if (decode_ok && bf->BPP) {
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
50 int bpl;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
51 bf->Width = avctx->width; bf->Height = avctx->height;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
52 bpl = bf->Width * (bf->BPP / 8);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
53 bf->ImageSize = bpl * bf->Height;
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
54 bf->Image = malloc(bf->ImageSize);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
55 memcpy_pic(bf->Image, frame->data[0], bpl, bf->Height, bpl, frame->linesize[0]);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
56 }
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
57 avcodec_close(avctx);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
58 av_freep(&frame);
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
59 av_freep(&avctx);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 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
63 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] imagesize: %lu\n",bf->ImageSize );
23193
7857af1ca50b Remove libpng dependency for Gui, use libavcodec instead
reimar
parents: 23077
diff changeset
64 return !(decode_ok && bf->BPP);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 int conv24to32( txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 unsigned char * tmpImage;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 int i,c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 if ( bf->BPP == 24 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 tmpImage=bf->Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 bf->ImageSize=bf->Width * bf->Height * 4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 bf->BPP=32;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] not enough memory for image\n" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 return 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 memset( bf->Image,0,bf->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
85 bf->Image[c++]=tmpImage[i++]; //red
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 bf->Image[c++]=tmpImage[i++]; //green
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 bf->Image[c++]=tmpImage[i++]; c++; //blue
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 free( tmpImage );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 }
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 void bgr2rgb( txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 unsigned char c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 for ( i=0;i < (int)bf->ImageSize;i+=4 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 c=bf->Image[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 bf->Image[i]=bf->Image[i+2];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 bf->Image[i+2]=c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 void Normalize( txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 #ifndef WORDS_BIGENDIAN
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i+3]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 #else
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 unsigned char tmp[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 unsigned char * fExist( unsigned char * fname )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 FILE * fl;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 unsigned char ext[][6] = { ".png\0",".PNG\0" };
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 fl=fopen( fname,"rb" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 if ( fl != NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 fclose( fl );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 return fname;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 for ( i=0;i<2;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133 snprintf( tmp,511,"%s%s",fname,ext[i] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 fl=fopen( tmp,"rb" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 if ( fl != NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 fclose( fl );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 return tmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 return NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 int bpRead( char * fname, txSample * bf )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 fname=fExist( fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 if ( fname == NULL ) return -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 if ( pngRead( fname,bf ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 mp_dbg( MSGT_GPLAYER,MSGL_FATAL,"[bitmap] unknown file type ( %s )\n",fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151 return -5;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153 if ( bf->BPP < 24 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 if ( conv24to32( bf ) ) return -8;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 #ifdef WORDS_BIGENDIAN
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 swab(bf->Image, bf->Image, bf->ImageSize);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 bgr2rgb( bf );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 Normalize( bf );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 void Convert32to1( txSample * in,txSample * out,int adaptivlimit )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
168 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 out->Width=in->Width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 out->Height=in->Height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 out->BPP=1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 out->ImageSize=(out->Width * out->Height + 7) / 8;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 out->Image=calloc( 1,out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotEnoughMemoryC32To1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 buf=(unsigned int *)in->Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 for ( b=0,i=0;i < (int)(out->Width * out->Height);i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 if ( (int)buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 else { tmp=tmp >> 1; buf[i]=nothaveshape=0; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183 if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 if ( b ) out->Image[c]=tmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 if ( nothaveshape ) { free( out->Image ); out->Image=NULL; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 void Convert1to32( txSample * in,txSample * out )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 if ( in->Image == NULL ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 out->Width=in->Width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 out->Height=in->Height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 out->BPP=32;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 out->ImageSize=out->Width * out->Height * 4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 out->Image=calloc( 1,out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
199 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotEnoughMemoryC1To32 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 buf=(unsigned int *)out->Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203 for ( c=0,i=0;i < (int)(in->Width * in->Height / 8);i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 tmp=in->Image[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 for ( b=0;b<8;b++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 buf[c]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 if ( tmp&0x1 ) buf[c]=0xffffffff;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 c++; tmp=tmp>>1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
214 }