diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/bmp.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index e55c2f9d1e..d2be8c9172 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -80,14 +80,6 @@ static long readlong(long *value) { | |||
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | 82 | ||
83 | /* Function to get a pixel from a line. (Tomas: maybe a better way?) */ | ||
84 | int getpix(int px, unsigned char *bmpbuf) { | ||
85 | int a = (px / 8); | ||
86 | int b = (7 - (px % 8)); | ||
87 | |||
88 | return (bmpbuf[a] & (1 << b)) != 0; | ||
89 | } | ||
90 | |||
91 | 83 | ||
92 | /****************************************************************************** | 84 | /****************************************************************************** |
93 | * read_bmp_file() | 85 | * read_bmp_file() |
@@ -172,6 +164,9 @@ int read_bmp_file(char* filename, | |||
172 | 164 | ||
173 | /* loop to read rows and put them to buffer */ | 165 | /* loop to read rows and put them to buffer */ |
174 | for (row = 0; row < bitmap_height; row++) { | 166 | for (row = 0; row < bitmap_height; row++) { |
167 | int bitsel = 1 << ((bitmap_height - row - 1) % 8); | ||
168 | int bytesel = bitmap_width * ((bitmap_height - row - 1) / 8); | ||
169 | |||
175 | /* read one row */ | 170 | /* read one row */ |
176 | ret = read(fd, bmpbuf, PaddedWidth); | 171 | ret = read(fd, bmpbuf, PaddedWidth); |
177 | if (ret != PaddedWidth) { | 172 | if (ret != PaddedWidth) { |
@@ -183,14 +178,11 @@ int read_bmp_file(char* filename, | |||
183 | 178 | ||
184 | /* loop though the pixels in this line. */ | 179 | /* loop though the pixels in this line. */ |
185 | for (col = 0; col < bitmap_width; col++) { | 180 | for (col = 0; col < bitmap_width; col++) { |
186 | ret = getpix(col, bmpbuf); | 181 | ret = (bmpbuf[col/8] & (1 << (7 - (col % 8)))) != 0; |
187 | if (ret == 1) { | 182 | if (ret == 1) |
188 | bitmap[bitmap_width * ((bitmap_height - row - 1) / 8) + col] | 183 | bitmap[bytesel + col] &= ~bitsel; |
189 | &= ~ 1 << ((bitmap_height - row - 1) % 8); | 184 | else |
190 | } else { | 185 | bitmap[bytesel + col] |= bitsel; |
191 | bitmap[bitmap_width * ((bitmap_height - row - 1) / 8) + col] | ||
192 | |= 1 << ((bitmap_height - row - 1) % 8); | ||
193 | } | ||
194 | } | 186 | } |
195 | } | 187 | } |
196 | 188 | ||
@@ -201,5 +193,4 @@ int read_bmp_file(char* filename, | |||
201 | *get_height = bitmap_height; | 193 | *get_height = bitmap_height; |
202 | 194 | ||
203 | return (PaddedHeight * bitmap_width); /* return the used buffer size. */ | 195 | return (PaddedHeight * bitmap_width); /* return the used buffer size. */ |
204 | |||
205 | } | 196 | } |