forked from len0rd/rockbox
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
This commit is contained in:
parent
6c5714a6ee
commit
fab528e574
1 changed files with 5 additions and 5 deletions
|
|
@ -35,8 +35,8 @@
|
||||||
*/
|
*/
|
||||||
int save_bmp_file( char* filename, struct bitmap *bm )
|
int save_bmp_file( char* filename, struct bitmap *bm )
|
||||||
{
|
{
|
||||||
/* I'm not really sure about this one :) */
|
int line_width = (bm->width*3+3) & ~3;
|
||||||
int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0);
|
int padsize = line_width - bm->width*3;
|
||||||
|
|
||||||
const unsigned char header[] =
|
const unsigned char header[] =
|
||||||
{
|
{
|
||||||
|
|
@ -77,10 +77,10 @@ int save_bmp_file( char* filename, struct bitmap *bm )
|
||||||
};
|
};
|
||||||
rb->write( fh, c, 3 );
|
rb->write( fh, c, 3 );
|
||||||
}
|
}
|
||||||
for( x = 0; x < 3*bm->width - line_width; x++ )
|
if(padsize != 0)
|
||||||
{
|
{
|
||||||
unsigned char c = 0;
|
unsigned int c = 0; /* padsize is at most 3. */
|
||||||
rb->write( fh, &c, 1 );
|
rb->write( fh, &c, padsize );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rb->close( fh );
|
rb->close( fh );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue