26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
|
#include <types.h> |
#include <sys/types.h> |
#include <errno.h> |
|
#include "ppm.h" |
34,7 → 34,8 |
static void skip_whitespace(unsigned char **data) |
{ |
retry: |
while (**data == ' ' || **data == '\t' || **data == '\n' || **data == '\r') |
while (**data == ' ' || **data == '\t' || **data == '\n' || |
**data == '\r') |
(*data)++; |
if (**data == '#') { |
while (1) { |
56,7 → 57,8 |
} |
} |
|
int ppm_get_data(unsigned char *data, size_t dtsz, unsigned int *width, unsigned int *height) |
int ppm_get_data(unsigned char *data, size_t dtsz, unsigned int *width, |
unsigned int *height) |
{ |
/* Read magic */ |
if (data[0] != 'P' || data[1] != '6') |
82,8 → 84,7 |
* @param putpixel Putpixel function used to print bitmap |
*/ |
int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx, |
unsigned int sy, |
unsigned int maxwidth, unsigned int maxheight, |
unsigned int sy, unsigned int maxwidth, unsigned int maxheight, |
putpixel_cb_t putpixel, void *vport) |
{ |
unsigned int width, height; |
118,7 → 119,8 |
data += 3; |
continue; |
} |
color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[2]*coef; |
color = ((data[0] * coef) << 16) + ((data[1] * coef) << 8) + |
data[2] * coef; |
|
(*putpixel)(vport, sx+(i % width), sy+(i / width), color); |
data += 3; |