summaryrefslogtreecommitdiffstats
path: root/bmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'bmp.c')
-rw-r--r--bmp.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/bmp.c b/bmp.c
index 1712bc8..d753ef8 100644
--- a/bmp.c
+++ b/bmp.c
@@ -27,27 +27,23 @@ int fh_bmp_id(char *name)
{
int fd;
char id[2];
-
fd = open(name, O_RDONLY);
- if (fd == -1) {
- return(0);
- }
-
+ if (fd == -1) return(0);
read(fd, id, 2);
close(fd);
- if ( id[0]=='B' && id[1]=='M' ) {
- return(1);
- }
+ if ( id[0]=='B' && id[1]=='M' ) return(1);
return(0);
}
+
void fetch_pallete(int fd, struct color pallete[], int count)
{
unsigned char buff[4];
int i;
lseek(fd, BMP_COLOR_OFFSET, SEEK_SET);
- for (i=0; i<count; i++) {
+ for (i=0; i<count; i++)
+ {
read(fd, buff, 4);
pallete[i].red = buff[2];
pallete[i].green = buff[1];
@@ -56,6 +52,7 @@ void fetch_pallete(int fd, struct color pallete[], int count)
return;
}
+
int fh_bmp_load(char *name,unsigned char *buffer, unsigned char **alpha, int x,int y)
{
int fd, bpp, raster, i, j, k, skip;
@@ -203,12 +200,8 @@ int fh_bmp_getsize(char *name,int *x,int *y)
unsigned char size[4];
fd = open(name, O_RDONLY);
- if (fd == -1) {
- return(FH_ERROR_FILE);
- }
- if (lseek(fd, BMP_SIZE_OFFSET, SEEK_SET) == -1) {
- return(FH_ERROR_FORMAT);
- }
+ if (fd == -1) return(FH_ERROR_FILE);
+ if (lseek(fd, BMP_SIZE_OFFSET, SEEK_SET) == -1) return(FH_ERROR_FORMAT);
read(fd, size, 4);
*x = size[0] + (size[1]<<8) + (size[2]<<16) + (size[3]<<24);
OpenPOWER on IntegriCloud