summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-08-16 14:57:15 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-08-16 14:57:15 +0000
commitfab528e574994c74a17862300bbf63abd0061704 (patch)
tree8e93c1e100177c2a124a31f233ea8342692dd3d4 /apps
parent6c5714a6ee97a0ac94d69bdfb1f239d445458b21 (diff)
downloadrockbox-fab528e574994c74a17862300bbf63abd0061704.tar.gz
rockbox-fab528e574994c74a17862300bbf63abd0061704.zip
pluginlib_bmp: fix bug that bitmap isn't saved correctly if width is not a multiple of 4. optimize a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22346 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-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 @@
35 */ 35 */
36int save_bmp_file( char* filename, struct bitmap *bm ) 36int save_bmp_file( char* filename, struct bitmap *bm )
37{ 37{
38 /* I'm not really sure about this one :) */ 38 int line_width = (bm->width*3+3) & ~3;
39 int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0); 39 int padsize = line_width - bm->width*3;
40 40
41 const unsigned char header[] = 41 const unsigned char header[] =
42 { 42 {
@@ -77,10 +77,10 @@ int save_bmp_file( char* filename, struct bitmap *bm )
77 }; 77 };
78 rb->write( fh, c, 3 ); 78 rb->write( fh, c, 3 );
79 } 79 }
80 for( x = 0; x < 3*bm->width - line_width; x++ ) 80 if(padsize != 0)
81 { 81 {
82 unsigned char c = 0; 82 unsigned int c = 0; /* padsize is at most 3. */
83 rb->write( fh, &c, 1 ); 83 rb->write( fh, &c, padsize );
84 } 84 }
85 } 85 }
86 rb->close( fh ); 86 rb->close( fh );