annotate Gui/bitmap/bmp/bmp.c @ 6486:c0d84f46d349

yvu9 support
author alex
date Fri, 21 Jun 2002 17:38:06 +0000
parents 3473ca9ef158
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
2 #ifndef __MY_BMP
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
3 #define __MY_BMP
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
4
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
5 /*
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
6 0.1 : BMP type.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
7 2.5 : File size.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
8 6.7 : Res.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
9 8.9 : Res.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
10 10.13 : Offset of bitmap.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
11 14.17 : Header size.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
12 18.21 : X size.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
13 22.25 : Y size.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14 26.27 : Number of planes.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15 28.29 : Number of bits per pixel.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
16 30.33 : Compression flag.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17 34.37 : Image data size in bytes.
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18 38.41 : Res
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19 42.45 : Res
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
20 46.49 : Res
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21 50.53 : Res
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
22 */
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23
2080
f91ad6d23ce9 gcc3 warning fixed
arpi
parents: 1693
diff changeset
24 #include <stdio.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
25 #include <stdlib.h>
2080
f91ad6d23ce9 gcc3 warning fixed
arpi
parents: 1693
diff changeset
26 #include <string.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
27
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
28 #include "bmp.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
29 #include "../bitmap.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31 int bmpRead( unsigned char * fname,txSample * bF )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
33 unsigned char bmpHeader[54];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 FILE * BMP;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
35 unsigned long i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
36 unsigned char * line;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
37 int linesize;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
38
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
39
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
40 if ( (BMP=fopen( fname,"rt" )) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
42 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] File not found ( %s ).\n",fname );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 return 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45 if ( (i=fread( bmpHeader,54,1,BMP )) != 1 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
47 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] Header read error ( %s ).\n",fname );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48 return 2;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 // memcpy( &bF->Size,&bmpHeader[2],4 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 memcpy( &bF->Width,&bmpHeader[18],4 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 memcpy( &bF->Height,&bmpHeader[22],4 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53 memcpy( &bF->BPP,&bmpHeader[28],2 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
54 // memcpy( &bF->ImageSize,&bmpHeader[34],4 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 bF->ImageSize=( bF->Width * bF->Height ) * ( bF->BPP / 8 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 if ( bF->BPP < 24 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
59 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] Sorry, this loader not supported 16 bit or less ...\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 return 3;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
63 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] filename: %s\n",fname );
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
64 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] size: %dx%d bits: %d\n",bF->Width,bF->Height,bF->BPP );
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
65 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] imagesize: %lu\n",bF->ImageSize );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 if ( ( bF->Image=malloc( bF->ImageSize ) ) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
69 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] Not enough memory for image buffer.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 return 4;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
73 if ( (i=fread( bF->Image,bF->ImageSize,1,BMP )) != 1 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
74 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
75 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] Image read error.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 return 5;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79 fclose( BMP );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81 linesize=bF->Width * ( bF->BPP / 8 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82 if ( (line=malloc( linesize )) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83 {
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 2082
diff changeset
84 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bmp] Not enough memory for flipping.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
85 return 6;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88 for ( i=0;i < bF->Height / 2;i++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90 memcpy( line,&bF->Image[ i * linesize ],linesize );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 memcpy( &bF->Image[ i * linesize ],&bF->Image[ ( bF->Height - i - 1 ) * linesize ],linesize );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 memcpy( &bF->Image[ ( bF->Height - i - 1 ) * linesize ],line,linesize );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94 free( line );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
95
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96 return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
97 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
98
2082
016f6d583733 missing newlines fixed
arpi
parents: 2080
diff changeset
99 #endif
016f6d583733 missing newlines fixed
arpi
parents: 2080
diff changeset
100