[Mplayer-cvslog] CVS: main/Gui/bitmap bitmap.c,1.9,1.10 bitmap.h,1.5,1.6

Zoltan Ponekker pontscho at mplayerhq.hu
Sat Nov 2 18:07:21 CET 2002


Update of /cvsroot/mplayer/main/Gui/bitmap
In directory mail:/var/tmp.root/cvs-serv31992/Gui/bitmap

Modified Files:
	bitmap.c bitmap.h 
Log Message:
cleanup - round 2.

Index: bitmap.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/bitmap/bitmap.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- bitmap.c	10 Sep 2002 12:38:19 -0000	1.9
+++ bitmap.c	2 Nov 2002 17:07:18 -0000	1.10
@@ -3,7 +3,93 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <png.h>
+
+#include "../../mp_msg.h"
 #include "bitmap.h"
+
+int pngRead( unsigned char * fname,txSample * bf )
+{
+ unsigned char   header[8];
+ png_structp     png;
+ png_infop       info;
+ png_infop       endinfo;
+ png_bytep     * row_p;
+ png_bytep       palette = NULL;
+ int             color;
+ png_uint_32     i;
+ 
+ FILE *fp=fopen( fname,"rb" );
+ if ( !fp ) 
+  {
+   mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s ).\n",fname );
+   return 1;
+  }
+
+ fread( header,1,8,fp );
+ if ( !png_check_sig( header,8 ) ) return 1;
+
+ png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
+ info=png_create_info_struct( png );
+ endinfo=png_create_info_struct( png );
+
+ png_init_io( png,fp );
+ png_set_sig_bytes( png,8 );
+ png_read_info( png,info );
+ png_get_IHDR( png,info,&bf->Width,&bf->Height,&bf->BPP,&color,NULL,NULL,NULL );
+
+ row_p=(png_bytep *)malloc( sizeof( png_bytep ) * bf->Height );
+ if ( !row_p )
+  {
+   mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png]  Not enough memory for row buffer.\n" );
+   return 2;
+  }
+ bf->Image=(png_bytep)malloc( png_get_rowbytes( png,info ) * bf->Height );
+ if ( !bf->Image )
+  {
+   mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png]  Not enough memory for image buffer.\n" );
+   return 2;
+  }
+ for ( i=0; i < bf->Height; i++ ) row_p[i]=&bf->Image[png_get_rowbytes( png,info ) * i];
+
+ png_read_image( png,row_p );
+ free( row_p );
+
+#if 0
+ if ( color == PNG_COLOR_TYPE_PALETTE )
+  {
+   int cols;
+   png_get_PLTE( png,info,(png_colorp *)&palette,&cols );
+  }
+#endif
+
+ if ( color&PNG_COLOR_MASK_ALPHA )
+  {
+   if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA ) bf->BPP*=2;
+     else bf->BPP*=4;
+  }
+  else
+   {
+    if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY ) bf->BPP*=1;
+      else bf->BPP*=3;
+   }
+
+ png_read_end( png,endinfo );
+ png_destroy_read_struct( &png,&info,&endinfo );
+
+ if ( fclose( fp ) != 0 )
+  {
+   free( bf->Image );
+   free( palette );
+   return 1;
+  }
+ bf->ImageSize=bf->Width * bf->Height * ( bf->BPP / 8 );
+
+ mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
+ mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png]  size: %dx%d bits: %d\n",bf->Width,bf->Height,bf->BPP );
+ mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png]  imagesize: %lu\n",bf->ImageSize );
+ return 0;
+}
 
 int conv24to32( txSample * bf )
 {

Index: bitmap.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/bitmap/bitmap.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- bitmap.h	4 Sep 2002 09:36:03 -0000	1.5
+++ bitmap.h	2 Nov 2002 17:07:18 -0000	1.6
@@ -11,9 +11,6 @@
  char *        Image;
 } txSample;
 
-#include "png/png.h"
-#include "../../mp_msg.h"
-
 extern int bpRead( char * fname, txSample * bf );
 extern int conv24to32( txSample * bf );
 extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit );




More information about the MPlayer-cvslog mailing list