summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-03-21 21:20:19 +0000
committerOle Loots <ole@monochrom.net>2012-03-21 21:20:19 +0000
commit0797bf5a5731b2c8d55105b453530584ea4e1f5b (patch)
tree30910fd24fd2cff97db169e9de215d2215138912
parent36dd0cc346494ddf6c6a63351c16b5d90ca8be1b (diff)
downloadnetsurf-0797bf5a5731b2c8d55105b453530584ea4e1f5b.tar.gz
netsurf-0797bf5a5731b2c8d55105b453530584ea4e1f5b.tar.bz2
Be a bit more verbose and strict.
svn path=/trunk/netsurf/; revision=13547
-rwxr-xr-xatari/bitmap.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/atari/bitmap.c b/atari/bitmap.c
index f991d9fc7..696bc68b1 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -59,13 +59,14 @@ void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int st
{
struct bitmap * bitmap;
- LOG(("width %d, height %d, state %u",w, h, state ));
+ LOG(("width %d (rowstride: %d, bpp: %d), height %d, state %u",w, rowstride,
+ bpp, h, state ));
if( rowstride == 0) {
rowstride = bpp * w;
}
- assert( rowstride >= w * bpp );
+ assert( rowstride >= (w * bpp) );
bitmap = calloc(1 , sizeof(struct bitmap) );
if (bitmap) {
if( pixdata == NULL) {
@@ -108,7 +109,7 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
bitmap->opaque = false;
} else {
int oldsize = bitmap->rowstride * bitmap->height;
- bool doalloc = ( state == BITMAP_GROW) ? (newsize > oldsize) : (newsize != oldsize);
+ bool doalloc = (state & BITMAP_GROW) ? (newsize > oldsize) : (newsize != oldsize);
if( newsize > oldsize )
assert( doalloc == true );
if( doalloc ) {
@@ -145,6 +146,7 @@ void bitmap_to_mfdb(void * bitmap, MFDB * out)
if( oldstride != dststride * bm->bpp )
{
+ assert( oldstride <= dststride );
/* we need to convert the img to new rowstride */
tmp = bm->pixdata;
bm->pixdata = calloc(1, dststride * bm->bpp * bm->height );
@@ -180,7 +182,7 @@ void bitmap_to_mfdb(void * bitmap, MFDB * out)
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
-unsigned char *bitmap_get_buffer(void *bitmap)
+unsigned char * bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
@@ -373,6 +375,12 @@ int bitmap_get_height(void *bitmap)
return(bm->height);
}
+
+/**
+*
+* Gets the number of BYTES per pixel.
+*
+*/
size_t bitmap_get_bpp(void *bitmap)
{
struct bitmap *bm = bitmap;