1
mirror of https://github.com/mpv-player/mpv synced 2025-03-23 00:14:24 +01:00

some fixes and bigendian fix for 32bpp pngs

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10169 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
alex 2003-05-23 17:04:24 +00:00
parent d9beced7e6
commit 13d89cd03d
2 changed files with 11 additions and 8 deletions

@ -1,4 +1,3 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -164,7 +163,7 @@ unsigned char * fExist( unsigned char * fname )
} }
for ( i=0;i<2;i++ ) for ( i=0;i<2;i++ )
{ {
sprintf( tmp,"%s%s",fname,ext[i] ); snprintf( tmp,511,"%s%s",fname,ext[i] );
fl=fopen( tmp,"rb" ); fl=fopen( tmp,"rb" );
if ( fl != NULL ) if ( fl != NULL )
{ {
@ -186,9 +185,13 @@ int bpRead( char * fname, txSample * bf )
} }
if ( bf->BPP < 24 ) if ( bf->BPP < 24 )
{ {
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] sorry, 16 or less bitmaps not supported.\n" ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" );
return -1; return -1;
} }
#ifdef WORDS_BIGENDIAN
if (bf->BPP == 32)
swab(bf->Image, bf->Image, bf->ImageSize);
#endif
if ( conv24to32( bf ) ) return -8; if ( conv24to32( bf ) ) return -8;
bgr2rgb( bf ); bgr2rgb( bf );
Normalize( bf ); Normalize( bf );
@ -203,7 +206,7 @@ void Convert32to1( txSample * in,txSample * out,int adaptivlimit )
out->ImageSize=(out->Width * out->Height + 7) / 8; out->ImageSize=(out->Width * out->Height + 7) / 8;
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c1to32] imagesize: %d\n",out->ImageSize );
out->Image=(char *)calloc( 1,out->ImageSize ); out->Image=(char *)calloc( 1,out->ImageSize );
if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"nem van ram baze\n" ); if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[c32to1] Not enough memory for image.\n" );
{ {
int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1;
buf=(unsigned int *)in->Image; buf=(unsigned int *)in->Image;
@ -227,7 +230,7 @@ void Convert1to32( txSample * in,txSample * out )
out->ImageSize=out->Width * out->Height * 4; out->ImageSize=out->Width * out->Height * 4;
out->Image=(char *)calloc( 1,out->ImageSize ); out->Image=(char *)calloc( 1,out->ImageSize );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[c32to1] imagesize: %d\n",out->ImageSize );
if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"nem van ram baze\n" ); if ( out->Image == NULL ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[c1to32] Not enough memory for image.\n" );
{ {
int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0; int i,b,c=0; unsigned int * buf = NULL; unsigned char tmp = 0;
buf=(unsigned int *)out->Image; buf=(unsigned int *)out->Image;

@ -1,5 +1,5 @@
#ifndef __MYSAMPLE #ifndef __BITMAP_H
#define __MYSAMPLE #define __BITMAP_H
typedef struct _txSample typedef struct _txSample
{ {
@ -15,4 +15,4 @@ extern int conv24to32( txSample * bf );
extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit ); extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit );
extern void Convert1to32( txSample * in,txSample * out ); extern void Convert1to32( txSample * in,txSample * out );
#endif #endif /* __BITMAP_H */