summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lib/pluginlib_bmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/pluginlib_bmp.c')
-rw-r--r--apps/plugins/lib/pluginlib_bmp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c
index 00c8cbbec0..8520a8b17f 100644
--- a/apps/plugins/lib/pluginlib_bmp.c
+++ b/apps/plugins/lib/pluginlib_bmp.c
@@ -35,8 +35,8 @@
*/
int save_bmp_file( char* filename, struct bitmap *bm )
{
- /* I'm not really sure about this one :) */
- int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0);
+ int line_width = (bm->width*3+3) & ~3;
+ int padsize = line_width - bm->width*3;
const unsigned char header[] =
{
@@ -77,10 +77,10 @@ int save_bmp_file( char* filename, struct bitmap *bm )
};
rb->write( fh, c, 3 );
}
- for( x = 0; x < 3*bm->width - line_width; x++ )
+ if(padsize != 0)
{
- unsigned char c = 0;
- rb->write( fh, &c, 1 );
+ unsigned int c = 0; /* padsize is at most 3. */
+ rb->write( fh, &c, padsize );
}
}
rb->close( fh );