Changeset 5d4e90f0 in mainline for uspace/srv/fb/ppm.c


Ignore:
Timestamp:
2007-09-27T12:35:36Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bcf23cf
Parents:
8c20b26
Message:

Header cleanup.
Move off_t, size_t and ssize_t into sys/types.h.
Get rid off the non-standard and dummy types.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fb/ppm.c

    r8c20b26 r5d4e90f0  
    2727 */
    2828
    29 #include <types.h>
     29#include <sys/types.h>
    3030#include <errno.h>
    3131
     
    3535{
    3636retry:
    37         while (**data == ' ' || **data == '\t' || **data == '\n' || **data == '\r')
     37        while (**data == ' ' || **data == '\t' || **data == '\n' ||
     38            **data == '\r')
    3839                (*data)++;
    3940        if (**data == '#') {
     
    5758}
    5859
    59 int ppm_get_data(unsigned char *data, size_t dtsz, unsigned int *width, unsigned int *height)
     60int ppm_get_data(unsigned char *data, size_t dtsz, unsigned int *width,
     61    unsigned int *height)
    6062{
    6163        /* Read magic */
     
    8284 * @param putpixel Putpixel function used to print bitmap
    8385 */
    84 int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx,
    85              unsigned int sy,
    86              unsigned int maxwidth, unsigned int maxheight,
    87              putpixel_cb_t putpixel, void *vport)
     86int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx,
     87    unsigned int sy, unsigned int maxwidth, unsigned int maxheight,
     88    putpixel_cb_t putpixel, void *vport)
    8889{
    8990        unsigned int width, height;
     
    106107        data++;
    107108
    108         if (maxcolor == 0 || maxcolor > 255 || width*height > datasz) {
     109        if (maxcolor == 0 || maxcolor > 255 || width * height > datasz) {
    109110                return EINVAL;
    110111        }
    111         coef = 255/maxcolor;
    112         if (coef*maxcolor > 255)
     112        coef = 255 / maxcolor;
     113        if (coef * maxcolor > 255)
    113114                coef -= 1;
    114115       
    115         for (i=0; i < width*height; i++) {
     116        for (i = 0; i < width * height; i++) {
    116117                /* Crop picture if we don't fit into region */
    117                 if (i % width > maxwidth || i/width > maxheight) {
     118                if (i % width > maxwidth || i / width > maxheight) {
    118119                        data += 3;
    119120                        continue;
    120121                }
    121                 color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[2]*coef;
     122                color = ((data[0] * coef) << 16) + ((data[1] * coef) << 8) +
     123                    data[2] * coef;
    122124               
    123                 (*putpixel)(vport, sx+(i % width), sy+(i / width), color);
     125                (*putpixel)(vport, sx + (i % width), sy + (i / width), color);
    124126                data += 3;
    125127        }
Note: See TracChangeset for help on using the changeset viewer.