Subversion Repositories HelenOS-historic

Rev

Rev 1547 | Rev 1673 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1547 Rev 1555
Line 54... Line 54...
54
        *num += **data - '0';
54
        *num += **data - '0';
55
        (*data)++;
55
        (*data)++;
56
    }
56
    }
57
}
57
}
58
 
58
 
-
 
59
int ppm_get_data(unsigned char *data, size_t dtsz, int *width, int *height)
-
 
60
{
-
 
61
    /* Read magic */
-
 
62
    if (data[0] != 'P' || data[1] != '6')
-
 
63
        return EINVAL;
-
 
64
 
-
 
65
    data+=2;
-
 
66
    skip_whitespace(&data);
-
 
67
    read_num(&data, width);
-
 
68
    skip_whitespace(&data);
-
 
69
    read_num(&data,height);
-
 
70
 
-
 
71
    return 0;
-
 
72
}
-
 
73
 
59
/** Draw PPM pixmap
74
/** Draw PPM pixmap
60
 *
75
 *
61
 * @param data Pointer to PPM data
76
 * @param data Pointer to PPM data
62
 * @param datasz Maximum data size
77
 * @param datasz Maximum data size
63
 * @param x Coordinate of upper left corner
78
 * @param x Coordinate of upper left corner
64
 * @param y Coordinate of upper left corner
79
 * @param y Coordinate of upper left corner
65
 * @param maxwidth Maximum allowed width for picture
80
 * @param maxwidth Maximum allowed width for picture
66
 * @param maxheight Maximum allowed height for picture
81
 * @param maxheight Maximum allowed height for picture
67
 * @param putpixel Putpixel function used to print bitmap
82
 * @param putpixel Putpixel function used to print bitmap
68
 */
83
 */
69
int draw_ppm(unsigned char *data, size_t datasz, unsigned int sx,
84
int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx,
70
         unsigned int sy,
85
         unsigned int sy,
71
         unsigned int maxwidth, unsigned int maxheight,
86
         unsigned int maxwidth, unsigned int maxheight,
72
         void (*putpixel)(int,unsigned int, unsigned int, int),int vp)
87
         void (*putpixel)(int,unsigned int, unsigned int, int),int vp)
73
{
88
{
74
    unsigned int width, height;
89
    unsigned int width, height;
Line 102... Line 117...
102
        /* Crop picture if we don't fit into region */
117
        /* Crop picture if we don't fit into region */
103
        if (i % width > maxwidth || i/width > maxheight) {
118
        if (i % width > maxwidth || i/width > maxheight) {
104
            data += 3;
119
            data += 3;
105
            continue;
120
            continue;
106
        }
121
        }
107
        color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[0]*coef;
122
        color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[2]*coef;
108
       
123
       
109
        (*putpixel)(vp, sx+(i % width), sy+(i / width), color);
124
        (*putpixel)(vp, sx+(i % width), sy+(i / width), color);
110
        data += 3;
125
        data += 3;
111
    }
126
    }
112
}
127
}