return 0;
}
if(a!=8 && (b==2 || b==6)) {
- printf("Bpp %d in mode %d not supported!\n", a);
+ printf("Bpp %d in mode %d not supported!\n", b, a);
return 0;
}
if(c!=0) {
}
if(!png_read_header(fi, &header)) {
+ fclose(fi);
return 0;
}
long idatsize = 0;
{
int x,y;
- int srcwidth = width * (bpp/8);
- int linelen = 1 + ((srcwidth+3)&~3);
+ int bypp = bpp/8;
+ int srcwidth = width * bypp;
+ int linelen = 1 + srcwidth;
+ if(bypp==2)
+ linelen = 1 + ((srcwidth+1)&~1);
+ else if(bypp==3)
+ linelen = 1 + ((srcwidth+2)/3)*3;
+ else if(bypp==4)
+ linelen = 1 + ((srcwidth+3)&~3);
unsigned char* line = (unsigned char*)malloc(linelen);
unsigned char* bestline = (unsigned char*)malloc(linelen);
memset(line, 0, linelen);