Mercurial > mplayer.hg
comparison Gui/bitmap/bitmap.c @ 4818:3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
author | pontscho |
---|---|
date | Sat, 23 Feb 2002 15:12:55 +0000 |
parents | 5fa8c079ee3c |
children | 35689e1e6745 |
comparison
equal
deleted
inserted
replaced
4817:1e46f40dcd0e | 4818:3473ca9ef158 |
---|---|
2 #include <stdio.h> | 2 #include <stdio.h> |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 #include <string.h> | 4 #include <string.h> |
5 | 5 |
6 #include "bitmap.h" | 6 #include "bitmap.h" |
7 #include "../error.h" | |
8 | 7 |
9 #define BMP 1 | 8 #define BMP 1 |
10 #define TGA 2 | 9 #define TGA 2 |
11 #define PNG 3 | 10 #define PNG 3 |
12 #define TGAPACKED 4 | 11 #define TGAPACKED 4 |
23 tmpImage=bf->Image; | 22 tmpImage=bf->Image; |
24 bf->ImageSize=bf->Width * bf->Height * 4; | 23 bf->ImageSize=bf->Width * bf->Height * 4; |
25 bf->BPP=32; | 24 bf->BPP=32; |
26 if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL ) | 25 if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL ) |
27 { | 26 { |
28 #ifdef DEBUG | 27 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Not enough memory for image.\n" ); |
29 dbprintf( 4,"[bitmap] Not enough memory for image.\n" ); | |
30 #endif | |
31 return 1; | 28 return 1; |
32 } | 29 } |
33 memset( bf->Image,0,bf->ImageSize ); | 30 memset( bf->Image,0,bf->ImageSize ); |
34 for ( c=0,i=0;i < bf->Width * bf->Height * 3; ) | 31 for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); ) |
35 { | 32 { |
36 bf->Image[c++]=tmpImage[i++]; | 33 bf->Image[c++]=tmpImage[i++]; |
37 bf->Image[c++]=tmpImage[i++]; | 34 bf->Image[c++]=tmpImage[i++]; |
38 bf->Image[c++]=tmpImage[i++]; c++; | 35 bf->Image[c++]=tmpImage[i++]; c++; |
39 } | 36 } |
45 void bgr2rgb( txSample * bf ) | 42 void bgr2rgb( txSample * bf ) |
46 { | 43 { |
47 unsigned char c; | 44 unsigned char c; |
48 int i; | 45 int i; |
49 | 46 |
50 for ( i=0;i < bf->ImageSize;i+=4 ) | 47 for ( i=0;i < (int)bf->ImageSize;i+=4 ) |
51 { | 48 { |
52 c=bf->Image[i]; | 49 c=bf->Image[i]; |
53 bf->Image[i]=bf->Image[i+2]; | 50 bf->Image[i]=bf->Image[i+2]; |
54 bf->Image[i+2]=c; | 51 bf->Image[i+2]=c; |
55 } | 52 } |
56 } | 53 } |
57 | 54 |
58 void Normalize( txSample * bf ) | 55 void Normalize( txSample * bf ) |
59 { | 56 { |
60 int i; | 57 int i; |
61 | 58 for ( i=0;i < (int)bf->ImageSize;i+=4 ) bf->Image[i+3]=0; |
62 for ( i=0;i < bf->ImageSize;i+=4 ) bf->Image[i+3]=0; | |
63 } | 59 } |
64 | 60 |
65 unsigned char tmp[512]; | 61 unsigned char tmp[512]; |
66 | 62 |
67 unsigned char * fExist( unsigned char * fname ) | 63 unsigned char * fExist( unsigned char * fname ) |
147 case PNG: | 143 case PNG: |
148 if ( pngRead( fname,bf ) ) return -5; | 144 if ( pngRead( fname,bf ) ) return -5; |
149 bgr=1; | 145 bgr=1; |
150 break; | 146 break; |
151 case TGAPACKED: | 147 case TGAPACKED: |
152 #ifdef DEBUG | 148 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] sorry, packed TGA not supported.\n" ); |
153 dbprintf( 4,"[bitmap] sorry, packed TGA not supported.\n" ); | |
154 #endif | |
155 return -6; | 149 return -6; |
156 default: | 150 default: |
157 { | 151 { |
158 #ifdef DEBUG | 152 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Unknown file type ( %s ).\n",fname ); |
159 dbprintf( 4,"[bitmap] Unknown file type ( %s ).\n",fname ); | |
160 #endif | |
161 return -7; | 153 return -7; |
162 } | 154 } |
163 } | 155 } |
164 if ( bf->BPP < 24 ) | 156 if ( bf->BPP < 24 ) |
165 { | 157 { |
166 #ifdef DEBUG | 158 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] sorry, 16 or less bitmaps not supported.\n" ); |
167 dbprintf( 4,"[bitmap] sorry, 16 or less bitmaps not supported.\n" ); | |
168 #endif | |
169 return -1; | 159 return -1; |
170 } | 160 } |
171 if ( conv24to32( bf ) ) return -8; | 161 if ( conv24to32( bf ) ) return -8; |
172 if ( bgr ) bgr2rgb( bf ); | 162 if ( bgr ) bgr2rgb( bf ); |
173 Normalize( bf ); | 163 Normalize( bf ); |
178 { | 168 { |
179 out->Width=in->Width; | 169 out->Width=in->Width; |
180 out->Height=in->Height; | 170 out->Height=in->Height; |
181 out->BPP=1; | 171 out->BPP=1; |
182 out->ImageSize=out->Width * out->Height / 8; | 172 out->ImageSize=out->Width * out->Height / 8; |
183 dbprintf( 4,"[c1to32] imagesize: %d\n",out->ImageSize ); | 173 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize ); |
184 out->Image=(char *)calloc( 1,out->ImageSize ); | 174 out->Image=(char *)calloc( 1,out->ImageSize ); |
185 if ( out->Image == NULL ) dbprintf( 4,"nem van ram baze\n" ); | 175 if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"nem van ram baze\n" ); |
186 { | 176 { |
187 int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; | 177 int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; |
188 buf=(unsigned long *)in->Image; | 178 buf=(unsigned long *)in->Image; |
189 for ( b=0,i=0;i < out->Width * out->Height;i++ ) | 179 for ( b=0,i=0;i < (int)(out->Width * out->Height);i++ ) |
190 { | 180 { |
191 if ( buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128; | 181 if ( (int)buf[i] != adaptivlimit ) tmp=( tmp >> 1 )|128; |
192 else { tmp=tmp >> 1; buf[i]=nothaveshape=0; } | 182 else { tmp=tmp >> 1; buf[i]=nothaveshape=0; } |
193 if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; } | 183 if ( b++ == 7 ) { out->Image[c++]=tmp; tmp=b=0; } |
194 } | 184 } |
195 if ( b ) out->Image[c]=tmp; | 185 if ( b ) out->Image[c]=tmp; |
196 if ( nothaveshape ) { free( out->Image ); out->Image=NULL; } | 186 if ( nothaveshape ) { free( out->Image ); out->Image=NULL; } |
203 out->Width=in->Width; | 193 out->Width=in->Width; |
204 out->Height=in->Height; | 194 out->Height=in->Height; |
205 out->BPP=32; | 195 out->BPP=32; |
206 out->ImageSize=out->Width * out->Height * 4; | 196 out->ImageSize=out->Width * out->Height * 4; |
207 out->Image=(char *)calloc( 1,out->ImageSize ); | 197 out->Image=(char *)calloc( 1,out->ImageSize ); |
208 dbprintf( 4,"[c32to1] imagesize: %d\n",out->ImageSize ); | 198 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize ); |
209 if ( out->Image == NULL ) dbprintf( 4,"nem van ram baze\n" ); | 199 if ( (int)out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"nem van ram baze\n" ); |
210 { | 200 { |
211 int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; | 201 int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; |
212 buf=(unsigned long *)out->Image; | 202 buf=(unsigned long *)out->Image; |
213 for ( c=0,i=0;i < in->Width * in->Height / 8;i++ ) | 203 for ( c=0,i=0;i < (int)(in->Width * in->Height / 8);i++ ) |
214 { | 204 { |
215 tmp=in->Image[i]; | 205 tmp=in->Image[i]; |
216 for ( b=0;b<8;b++ ) | 206 for ( b=0;b<8;b++ ) |
217 { | 207 { |
218 buf[c]=0; | 208 buf[c]=0; |